RViz did not receive map

Hi community!
I have done bunch of search in the forum about the visualizing the map in the RVIZ , and I tried the solutions that suggested but none of them helped me out, that’s why I ended up here I will provide tha last suggestion here with o/p:
Note that I also change durability policy to transient .

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():

    map_file = os.path.join(get_package_share_directory(
        "map_server"), "config", "/home/user/map2.yaml")
    rviz_file = os.path.join(get_package_share_directory(
        "map_server"), "rviz", "map_server.rviz")

    return LaunchDescription([

        Node(package="rviz2",
             executable="rviz2",
             name="rviz2",
             output="screen",
             arguments=['-d', rviz_file],
             parameters=[{'use_sim_time': True}],
             emulate_tty=True),

        Node(package="nav2_map_server",
             executable="map_server",
             name="map_server",
             output="screen",
             parameters=[{"use_sim_time": True},
                         {"yaml_filename": map_file}],
             emulate_tty=True),

        Node(package="nav2_lifecycle_manager",
             executable="lifecycle_manager",
             name="lifecycle_manager_mapper",
             output="screen",
             parameters=[{"use_sim_time": True},
                         {"autostart": True},
                         {"node_names": ["map_server"]}],
             emulate_tty=True),

    ])

# End of Code

that’s the terminal o/p:

user:~/nav2_ws$ ros2 launch slam_toolbox map_server_launch.py
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2024-03-14-08-28-57-797451-2_xterm-28268
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [rviz2-1]: process started with pid [28270]
[INFO] [map_server-2]: process started with pid [28272]
[INFO] [lifecycle_manager-3]: process started with pid [28274]
[lifecycle_manager-3] [INFO] [1710404937.993219060] [lifecycle_manager_mapper]: Creating
[lifecycle_manager-3] [INFO] [1710404938.002060723] [lifecycle_manager_mapper]: Creating and initializing lifecycle service clients
[lifecycle_manager-3] [INFO] [1710404938.008421064] [lifecycle_manager_mapper]: Starting managed nodes bringup...
[lifecycle_manager-3] [INFO] [1710404938.008473815] [lifecycle_manager_mapper]: Configuring map_server
[map_server-2] [INFO] [1710404938.027555368] [map_server]:
[map_server-2]  map_server lifecycle node launched.
[map_server-2]  Waiting on external lifecycle transitions to activate
[map_server-2]  See https://design.ros2.org/articles/node_lifecycle.html for more information.
[map_server-2] [INFO] [1710404938.027693577] [map_server]: Creating
[map_server-2] [INFO] [1710404938.027897761] [map_server]: Configuring
[map_server-2] [INFO] [map_io]: Loading yaml file: /home/user/koctasmagaza.yaml
[map_server-2] [DEBUG] [map_io]: resolution: 0.05
[map_server-2] [DEBUG] [map_io]: origin[0]: -62.336
[map_server-2] [DEBUG] [map_io]: origin[1]: -107.616
[map_server-2] [DEBUG] [map_io]: origin[2]: 0
[map_server-2] [DEBUG] [map_io]: free_thresh: 0.196
[map_server-2] [DEBUG] [map_io]: occupied_thresh: 0.65
[map_server-2] [DEBUG] [map_io]: mode: trinary
[map_server-2] [DEBUG] [map_io]: negate: 0
[map_server-2] [INFO] [map_io]: Loading image_file: /home/user/koctasmagaza080324retail.pgm
[rviz2-1] QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-user'
[rviz2-1] [INFO] [1710404938.389072383] [rviz2]: Stereo is NOT SUPPORTED
[rviz2-1] [INFO] [1710404938.389456095] [rviz2]: OpenGl version: 3.1 (GLSL 1.4)
[rviz2-1] [INFO] [1710404938.465945860] [rviz2]: Stereo is NOT SUPPORTED
[map_server-2] [DEBUG] [map_io]: Read map /home/user/koctasmagaza080324retail.pgm: 1508 X 2775 map @ 0.05 m/cell
[lifecycle_manager-3] [INFO] [1710404939.104408638] [lifecycle_manager_mapper]: Activating map_server
[map_server-2] [INFO] [1710404939.104637940] [map_server]: Activating
[lifecycle_manager-3] [INFO] [1710404939.112267752] [lifecycle_manager_mapper]: Managed nodes are active

and RVIZ:

How can I solve this problem? I am working on the adding new gray color to the pgm to create extra category in the map different from unknown, obstacle or free areas, that’s hy I need to visualize that I have been done to the code.
also I wanna note that there is too much gazebo client problems like not responding , crashing, not able to run after a while or like RVIZ visiaulization as a student these are too much time consuming that’s why 8 hours limit is not enough to deal with the issues and observe what I have achive to grasp
the codes, packages etc.

1 Like

Hi @tugbakara ,

Could you please provide more information?
Are you doing a course or working on your own project?
If this is in a course, what is the unit / chapter name?
Are you new to ROS2 and Navigation2 stack?

After going through what you have provided, it seems that you have followed every steps correctly, however, I believe the issue you have is:

  1. Path to map file is wrong.
    [And / Or]
  2. Name of the map file is wrong.
    [And / Or]
  3. The map file name reference in the yaml file is incorrect.

The inference here is that, you have a map file and a yaml file. So if the map is unable to load properly there are only two issues:

  1. The map topic is misconfigured (which I believe is not the reason in your case).
  2. The map file references are incorrect - like map file name, path , map name in yaml file, etc.

From your error output it seems that the node is launching the following map files:

But you have referenced an incorrect file name in your launch file:

Please recheck the file references. That could fix your issue.

Regards,
Girish

It’s pretty intersting because when I run the launch file I am sure that I stop and logout and login the rosject to start from zero or to start clear but I don’t know how the old trials left in the mapserver, I only ran the launch file. Now I am trying to run the launch again now RVIZ cannot be launched, looking RVIZ issue then I’ll come back, thanks for the reply! :slight_smile:
EDIT:
I have run the launch file again the o/p is same but I didn’t run the map_server explicitly, and this is map2.yaml:

image: map2.pgm

mode: trinary

resolution: 0.05

origin: [-7.99, -5.35, 0]

negate: 0

occupied_thresh: 0.65

free_thresh: 0.25

does rosject stuck somewhere in the process of map server couldn’t close itself from the old sessions?
I faced this kinda problem too much in the rosjects.
Also I chaned the map2.yaml to koctasmaa.yaml which has koctasmagaza080324retail.pgm in it, but in RVIZ still issue persists.
Is there any reset button or something of the rosject to get rid of stucked processes?

Hi @tugbakara ,

I think the map2.yaml file expects the full path to the map file.
Try changing the first line in your yaml file:

image: map2.pgm   # <--- replace this line with
image: /full/path/to/map2.pgm   # <--- this line (use correct path)

It could also be that the RViz is starting in parallel with map_server, in a way that the map is advertised before Rviz actually starts (missing by a few microseconds to seconds). Try to launch Rviz first and then launch your map_server launch file (with the Rviz node commented out).
If the map shows up this time, then it is Rviz that is starting after map has been advertised. In this case, you need to add some delay before starting map_server after launching Rviz from launch file.

I am not aware of any reset button, but if you logout from the rosject and login after 15-20 minutes, then the Virtual Machine would have reset itself and you will start again from scratch (with all background processes cleared), your files will be intact.

I hope this helps!

Regards,
Girish

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.