This is a fork of Stephen Brawner's collision_map_creator_plugin for Gazebo with the major difference that you can choose which entity to treat as ground (useful for table-top robotics), e.g. by speciying collision entity or setting a minimum height.
mkdir build
cd build
cmake ..
make
...
<plugin filename="libcollision_map_creator.so" name="collision_map_creator"/>
</world>
</sdf>
Run the Gazebo simulation, but make sure to copy the libcollision_map_creator.so
to a folder inside your GAZEBO_PLUGIN_PATH
, or add the build folder to that path before running, e.g.:
GAZEBO_PLUGIN_PATH=PATH/TO/collision_map_creator_plugin/build/ gazebo <worldfile>
$ ./request_publisher "(-10,-10)(10,10)" 10 0.01 $(pwd)/map.png 255 office_desk::link::collision
This will create a PNG file called ./map.png
which contains the bird's-eye view from 10 meters above of the area specified by the bounds (-10,-10)(10,10)
at a resolution of 0.01 meter per pixel. The collision entity office_desk::link::collision
is treated as the ground and represented by white color in the image. Everything else is colored in black (255 - 255 = 0).
$ ./request_publisher "(-10,10)(10,10)" 10 0.01 $(pwd)/map.png 255 office_desk::link::collision 0.8
The last parameter tells the plugin to consider only the parts of the entity office_desk::link::collision
that lie between 0.8 and 10 meters as ground. The default value is 0.
- Region of interest with corner coordinates (meter):
(lowerleft.x, lowerleft.y)(upperright.x, upperright.y)
- Height from which map is created (meter)
- Resolution (meter per pixel)
- Path where the png file will be stored. (Hint: this is relative to Gazebo's working directory, e.g.
~/.ros/
or use a full path.) - (optional) threshold: which value to use for objects (default:
255
) - (optional) ground entity name: which Gazebo entity to treat as ground (default:
ground_plane::link::collision
) - (optional) minimum height (meter): everything below this height will also be treated as obstacles (default:
0
)
Coordinates are with respect to the collision object's reference coordinate system:
You will find a world example in world/simple.world
with three primitives which can be run as follows:
$ gazebo /path/to/repository/world/simple.world
Gazebo screenshot of simple.world
./request_publisher "(-5,-3)(4,5)" 0.1 0.04 $(pwd)/map.png 255 ground_plane::link::collision
The created images are flipped, because the y-axis points down in images.
Furthermore, the height was chosen to be 10 cm which is a common LiDAR height and thus, the footprint of the sphere at this height is much smaller.
The following created image is flipped afterwards for correct visualization (e.g. by $ convert map.png -flip map_flip.png
):