How to visualize an existed map in rviz2?

asked 2022-02-17 03:11:22 -0500

Tudala gravatar image

Hello all, what I want to do is visualize an existed map (transfered by a floor plant draw) in rviz2, without robot. I tried following method:


The first method I tried is following the nav2_map_server doc, write a map_server_params.yaml file containing the map yaml (named my_home.yaml), run ros2 run nav2_util lifecycle_bringup map_server to start the map_server lifecycle node, then run ros2 run nav2_map_server map_server __params:=map_server_params.yaml.How ever It raise the error:

[ERROR] [1645087776.595143296] []: Caught exception in callback for transition 10
[ERROR] [1645087776.595162645] []: Original error: yaml_filename
[WARN] [1645087776.595190082] []: Error occurred while doing error handling.
[FATAL] [1645087776.595209115] [map_server]: Lifecycle node map_server does not have error state implemented
[WARN] [1645087776.595906518] [rcl_lifecycle]: No transition matching 3 found for current state unconfigured
[ERROR] [1645087776.595984134] []: Unable to start transition 3 from current state unconfigured: Transition is not registered., at /tmp/binarydeb/ros-foxy-rcl-lifecycle-1.1.13/src/rcl_lifecycle.c:350

I tried changing the yaml_filename param to full path, an changing the path in the yaml file to the full path, but no luck.


The second method I tried is launch the nav2_bringup, and set a map param: ros2 launch nav2_bringup bringup_launch.py map:=my_home.yaml. It seems the map is loaded succesfully:

[lifecycle_manager-3] [INFO] [1645088410.308616683] [lifecycle_manager_localization]: Creating
[lifecycle_manager-3] [INFO] [1645088410.317071819] [lifecycle_manager_localization]: Creating and initializing lifecycle service clients
[lifecycle_manager-3] [INFO] [1645088410.318294290] [lifecycle_manager_localization]: Starting managed nodes bringup...
[lifecycle_manager-3] [INFO] [1645088410.318324958] [lifecycle_manager_localization]: Configuring map_server
[map_server-1] [INFO] [1645088410.334743479] [map_server]: 
[map_server-1]  map_server lifecycle node launched. 
[map_server-1]  Waiting on external lifecycle transitions to activate
[map_server-1]  See https://design.ros2.org/articles/node_lifecycle.html for more information.
[map_server-1] [INFO] [1645088410.336777343] [map_server]: Creating
[map_server-1] [INFO] [1645088410.337357245] [map_server]: Configuring
[map_server-1] [INFO] [map_io]: Loading yaml file: my_home.yaml
[map_server-1] [DEBUG] [map_io]: resolution: 0.05
[map_server-1] [DEBUG] [map_io]: origin[0]: -13.9
[map_server-1] [DEBUG] [map_io]: origin[1]: -35.4
[map_server-1] [DEBUG] [map_io]: origin[2]: 0
[map_server-1] [DEBUG] [map_io]: free_thresh: 0.25
[map_server-1] [DEBUG] [map_io]: occupied_thresh: 0.65
[map_server-1] [DEBUG] [map_io]: mode: trinary
[map_server-1] [DEBUG] [map_io]: negate: 0
[map_server-1] [INFO] [map_io]: Loading image_file: ./my_home.pgm
[amcl-2] [INFO] [1645088410.343344408] [amcl]: 
[amcl-2]    amcl lifecycle node launched. 
[amcl-2]    Waiting on external lifecycle transitions to activate
[amcl-2]    See https://design.ros2.org/articles/node_lifecycle.html for more information.
[amcl-2] [INFO] [1645088410.343481786] [amcl]: Creating
[waypoint_follower-8] [INFO] [1645088410.346237158] [waypoint_follower]: 
[waypoint_follower-8]   waypoint_follower lifecycle node launched. 
[waypoint_follower-8]   Waiting on external lifecycle transitions to activate
[waypoint_follower-8]   See https://design.ros2.org/articles/node_lifecycle.html for more information.
[waypoint_follower-8] [INFO] [1645088410.346497268] [waypoint_follower]: Creating
[map_server-1] [DEBUG] [map_io]: Read map ./my_home.pgm: 291 X 198 map @ 0.05 m/cell

However, after openning the rviz2, and add the map plugin, the map is still not visible. I change the Fiexd Frame to "map", and set the map topic to /map, still get "No map received" under Map-Status tag.


The third way is call the map_server service after launch the map_server: ros2 service call /map_server/load_map nav2_msgs/srv/LoadMap "{map_url: {path_to_file}/my_home.yaml}". Again, it seems the map is readed, and ... (more)

edit retag flag offensive close merge delete

Comments

I am having same issue on Humble. Did you ever get this fixed?

billy gravatar image billy  ( 2023-01-23 02:08:32 -0500 )edit