Robotics StackExchange | Archived questions

How can I visualize a map on rviz2? (ros2 eloquent)

I am running "nav2mapserver" togheter with "rviz2". I used the "nav2util" to call the mapserver. Following the output of the terminals.

Terminal 1:

lorenzoteo@lorenzoteo-HP-ZBook-15v-G5:~$ ros2 run nav2_util lifecycle_bringup map_server

Terminal 2:

lorenzoteo@lorenzoteo-HP-ZBook-15v-G5:~$ ros2 run rviz2 rviz2
[INFO] [rviz2]: Stereo is NOT SUPPORTED
[INFO] [rviz2]: OpenGl version: 3.1 (GLSL 1.4)
[INFO] [rviz2]: Stereo is NOT SUPPORTED

Terminal 3:

lorenzoteo@lorenzoteo-HP-ZBook-15v-G5:~$ ros2 run nav2_map_server map_server --ros-args --params-file /home/lorenzoteo/Downloads/map_server_params.yaml
[INFO] [map_server]: Creating
[INFO] [map_server]: Configuring
[INFO] [map_server]: OccGridLoader: Creating
[INFO] [map_server]: OccGridLoader: Configuring
[INFO] [map_server]: Loading yaml file: /home/lorenzoteo/Downloads/map.yaml
[INFO] [map_server]: Loading image_file: /home/lorenzoteo/Downloads/map.png
[INFO] [map_server]: Activating
[INFO] [map_server]: OccGridLoader: Activating

I have attached the rviz window setup in which I cannot see the map even if I select the map topic.

C:\fakepath\Screenshot from 2020-02-10 15-54-27.png

EDIT

I found that with a configuration file (for rviz2) of a tutorial it displays the map. Why? The file could be found here: https://github.com/ros-planning/navigation2/blob/master/nav2_bringup/bringup/rviz/nav2_default_view.rviz

Asked by lorenzo on 2020-02-10 10:00:42 UTC

Comments

Do you see the map topic being published before you run rviz?

If so, make sure your QoS settings are correct.

Asked by stevemacenski on 2020-02-10 10:57:50 UTC

What are QoS settings?

Asked by lorenzo on 2020-02-10 11:41:44 UTC

https://design.ros2.org/articles/qos.html

Asked by stevemacenski on 2020-02-10 11:58:20 UTC

Even if I run it alone it doesn't publish the topic /map. See the edit.

Asked by lorenzo on 2020-02-11 02:54:23 UTC

With your edit: again, pelase look at the QoS settings. You are required to understand QoS and their interactions as part of working with ROS2.

Asked by stevemacenski on 2020-02-11 14:28:12 UTC

Thank you so much Steve. I read the QoS and understood

Asked by lorenzo on 2020-02-12 03:22:56 UTC

Stevemacenski, Thanks for pointing to a very generic article about QoS that was so generic to be not very helpful. and then you closed the question. How about something like the map server should have x profile or have history value of x depth value of y reliability value of x and durability value of v. Also how does Qos affect the map server not publishing the map? I could see maybe rviz2 not displaying because its not getting a map that is fresh enough. That could be a QoS issue. But the mapserver not publishing the topic at all points to something else. I repeated lorenzo's steps and then ran ros2 topic info /map and I see subscribers=1 publishers=0. that tells me mapserver is not working.

Sorry but I am a bit jaded since I saw these claims about how ros2 was so much better and I have been struggling to just complete a basic slam and navigate. I am facing my 5th major issue of not being able to show my map in rviz2.

Asked by ed on 2020-11-26 15:23:46 UTC

Hi, have you solved this question? Facing the same problem after 2 years.

Asked by Tudala on 2022-02-12 23:44:47 UTC

I was facing the same issue. Adding to @stevemacenski's answer, make sure that the "QOS" settings on RVIZ are same as those on the topic publishing your map.

For example, my map was being published on the "/map" topic.

Just after starting the map server and rviz2, I ran ros2 topic info --verbose /map. This gave me the following output:

Type: nav_msgs/msg/OccupancyGrid

Publisher count: 1

Node name: map_server
Node namespace: /
Topic type: nav_msgs/msg/OccupancyGrid
Endpoint type: PUBLISHER
GID: 01.0f.01.db.b1.33.d5.e9.01.00.00.00.00.00.20.03.00.00.00.00.00.00.00.00
QoS profile:
  Reliability: RELIABLE
  History (Depth): UNKNOWN
  Durability: TRANSIENT_LOCAL
  Lifespan: Infinite
  Deadline: Infinite
  Liveliness: AUTOMATIC
  Liveliness lease duration: Infinite

Subscription count: 0

Make sure that all QOS profile settings in RVIZ match what is shown above (under Map -> Update Topic in RVIZ)

Asked by Speedracer1702 on 2023-02-09 12:16:35 UTC

Answers