Export 2D map from Rviz and/or RTAB-Map
I've been working through my undergrad thesis based on ROS and RTAB-Map (questions about it here and here and need a little more help with one last issue. My thesis tutor is asking me whether he can use maps generated with RTAB-Map in Player/Stage, and since I'm still new with the software, I expect that the answer would be yes, but that I would need to export the 2D projection first and I don't know how to do that and what image format to expect from this.
Could anyone shed some light on this, please?
Asked by kenshin23 on 2015-09-04 15:19:37 UTC
Answers
Hello,
I assume that you want to use the map generated by RTAB-Map for simulation experiments using Stage. It is possible to create a .world
for Stage referencing an image (e.g. black pixels are walls). Here is an example to generate such images from an already built database. Using IROS14-kinect-challenge.db from this RTAB-Map's tutorial:
$ roscore
$ rosrun rtabmap_ros rtabmap _database_path:=IROS14-kinect-challenge.db
$ rosrun map_server map_saver map:=proj_map
$ rosservice call /publish_map 1 1 0
This takes some time for rtabmap node to build the projection map, but you should see this in the terminal of the map_saver:
[ INFO] [1441403556.668234515]: Waiting for the map
[ INFO] [1441403565.477020944]: Received a 508 X 420 map @ 0.050 m/pix
[ INFO] [1441403565.477108000]: Writing map occupancy data to map.pgm
[ INFO] [1441403565.482476945]: Writing map occupancy data to map.yaml
[ INFO] [1441403565.482683795]: Done
You may need to convert the PGM to a BMP for stage and change all the grey pixels to white. The map.pgm:
map.yaml:
image: map.pgm
resolution: 0.050000
origin: [-9.033475, -11.844757, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196
cheers
Asked by matlabbe on 2015-09-04 17:17:25 UTC
Comments
Is this method still legit? Because I followed as described, but when I call the rosservice I get the following output:
[ INFO] [1527228147.803636036]: rtabmap: Publishing map... WARN CoreWrapper.cpp:2333::publishMapCallback() No subscribers, don't need to publish!
Asked by arseen on 2018-05-25 01:03:36 UTC
Yes, is map_server subscribed to right topic? If rtabmap node is in rtabmap namespace (like when using rtabmap.launch) you may subscribe to /rtabmap/grid_map
instead.
Asked by matlabbe on 2018-05-25 15:07:21 UTC
Thanks! It works now. Another question, that kinda relates to this one .. Is it possible to use the rtabmap db to create a .world file to use in gazeboo? For simulation purposes?
Asked by arseen on 2018-05-28 05:43:23 UTC
Comments