How to visualize an existed map in rviz2?
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 nav2mapserver doc, write a mapserverparams.yaml file containing the map yaml (named myhome.yaml), run `ros2 run nav2util lifecyclebringup mapserverto start the map_server lifecycle node, then run
ros2 run nav2mapserver mapserver _params:=mapserverparams.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 nav2bringup, and set a map param: `ros2 launch nav2bringup bringuplaunch.py map:=myhome.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 mapserver service after launch the mapserver: 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 the /map topic is receiving message:
[map_server-1] [INFO] [1645088924.738930802] [map_server]: Handling LoadMap request
[map_server-1] [INFO] [map_io]: Loading yaml file: /home/lin/two_wheel_robot/src/two_wheeled_robot/maps/cafe_world/cafe_world.yaml
[map_server-1] [DEBUG] [map_io]: resolution: 0.05
[map_server-1] [DEBUG] [map_io]: origin[0]: -5
[map_server-1] [DEBUG] [map_io]: origin[1]: -11.1
[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: /home/lin/two_wheel_robot/src/two_wheeled_robot/maps/cafe_world/cafe_world.pgm
[map_server-1] [DEBUG] [map_io]: Read map /home/lin/two_wheel_robot/src/two_wheeled_robot/maps/cafe_world/cafe_world.pgm: 184 X 429 map @ 0.05 m/cell
But still no visible map in rviz2. What is missing? Thanks a lot if anyone could help me!
Asked by Tudala on 2022-02-17 04:11:22 UTC
Comments
I am having same issue on Humble. Did you ever get this fixed?
Asked by billy on 2023-01-23 03:08:32 UTC