[Bug] rviz map not loading Unit 2 ros2 navigation

This is an error report.


Screenshot of the error


Error details

I am trying to get rviz to load the map I saved but it doesn't load the map, it says "No map received". I made sure my launch file has the .yaml file and its publishing but its not loading for some reason.

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', 'turtlebot_area.yaml')

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

        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']}])            
        ])
from setuptools import find_packages, setup
import os
from glob import glob

package_name = 'map_server'

setup(
    name=package_name,
    version='0.0.0',
    packages=find_packages(exclude=['test']),
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
        (os.path.join('share', package_name, 'launch'), glob('launch/*.launch.py')),
        (os.path.join('share', package_name, 'config'), glob('config/*')),
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='user',
    maintainer_email='user@todo.todo',
    description='TODO: Package description',
    license='TODO: License declaration',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
        ],
    },
)

Here is how my files are ordered. user:~/ros2_ws/src/map_server/config$ ls
turtlebot_area.pgm turtlebot_area.yaml

Hi, fellow student here! I had this same issue but found a workaround, so perhaps it’s the same problem you’re facing.

Try updating the Durability Policy to Transient local

Here’s what I think is happening:

  1. When we load the map server, it publishes the map data to the topic
  2. We launch RViz and it subscribes to the /map topic
  3. However, since the map data has already been published nothing comes through and RViz cannot see the map

I believe the default Durability Quality of Service setting of Volatile in RViz is saying “you should only look for new messages”. When we change it to Transient local we’re telling RViz “there may be some old messages persisted, so go and look for those”. When we do that, it can find the map data published in step 1 above.

Here is the Quality of Service ROS documentation: Quality of Service settings — ROS 2 Documentation: Rolling documentation

Perhaps give this change a try and see if that’s your issue?

1 Like

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