Dynamically adding a line to gazebo
I came a cross this video which shows a statically added line for a robot to follow.
However, I'm looking for a solution that will allow me to dynamically add lines to my gazebo model for the same purpose. This is because my gazebo model has a lot of obstacles and I'm looking for a technique that will allow me to "draw" lines where I need them. As mentioned previously, the aim is to define a virtual line/path for the robot to follow.
I would appreciate insights into if this is possbile and how I can go about it ?
Asked by sisko on 2021-07-12 19:16:41 UTC
Answers
The first method that comes to mind that I know would work, but might not necessarily be the most elegant solution, would be to create a "line_segment" gazebo model, of some characteristic unit length, make it static, and just give it a visual tag (no collision or inertial needed). Then write a node that dynamically spawns this model, as needed, in the desired locations. This is a bit clunky because it will spin up a separate process for each line segment model, but for a simple box model, should work pretty well. You could dynamically generate the model's SDF file as well to accept variable length line segments.
A second option, that may work a bit better if your input is a hand-drawn line (i.e. as an image), you could look at the projector plugin. This has the caveat that it will also project the line onto your robot as your robot drives underneath the projector.
A more elegant solution might be to write a Gazebo plugin and take advantage of some of the rendering API. You could probably use the DynamicLines or perhaps the Road2d class to achieve what you are looking to do. I have no experience with this, so I'm not 100% sure it would work with the simulated camera,
Asked by shonigmann on 2021-07-14 17:08:42 UTC
Comments