how to load a map in rviz

asked 2020-03-21 07:41:50 -0500

sinou00 gravatar image

hello, I loaded a map in gazebo but in rviz i dont have the same. So how can i load my map in rviz? i am working in ubuntu. thanks in advance for youre answers

edit retag flag offensive close merge delete


Gazebo is a simulator, rviz a visualization software. In rviz you only get the data the robot perceives (sensors) or has in its databse. You need to SLAM/map the gazebo world to make its robot perception equivalent available in rviz. So the robot needs to "scan" the gazebo world, translate it into some kind of map format, and publish it (via a map server in many cases). Most of the time this is done via SLAM, and after that, the generated map is used for navigation. There are also possibilities to SLAM and navigate at once, but that is more advanced.

Dragonslayer gravatar image Dragonslayer  ( 2020-03-21 11:04:04 -0500 )edit

thank you. I already have a generated map i just want to be shown in rviz

sinou00 gravatar image sinou00  ( 2020-03-22 07:26:23 -0500 )edit

if it is a .yaml file format (which will also have .pgm beside it) u can go into the file directory folder and then do rosrun map_server map_server NAME_OF_FILE.yaml

AK3874 gravatar image AK3874  ( 2020-03-22 15:28:13 -0500 )edit

ak3847 is correct. However, as with that setup your ready for navigation anyway, you might want to check out the different localization nodes, which include map_server functionality themselfs. ros_rtabmap for example is used for mapping, which you have already done, and can then be switched to localization mode. But even in slam mode it serves the building map to rviz and in localization mode as well. If you used gmapping to build the map, I think you could use amcl to provide the map via map_server and it will as well localize. Usually mapping is done to be able to use pathplanning and localization for navigation.

Dragonslayer gravatar image Dragonslayer  ( 2020-03-25 12:24:01 -0500 )edit