[Bug] Unit 2 Map Server Example cannot load RVIZ

This is an error report.


Screenshot of the error


Error details

Hello,

I hope everyone is live and well. I am trying this example on the Nav2 Course and I ran into this issue on the loading of the map server. In the first webshell it state it ran all of the server correctly from my understanding but the issue is that the rviz2 application does not open as expected with the projected map from the previous example.

I will provide the files used for this example, the setup.py, and the screenshot of my current file directory. I am not sure if I missed a certain step in the process of developing my solution to the example. Thank you all for your support and assistance I appreciate it! Have a great weekend.

nav2_map_server.launch.py:

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']}])            
    ])

setup.py:
import os
from glob import glob
from setuptools import find_packages, setup

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’: [
],
},
)

package.xml:

<?xml version="1.0"?> <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> map_server 0.0.0 TODO: Package description user TODO: License declaration

rclpy

<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

ament_python

Hi @Agarcia5612 ,

Your launch file and your setup.py files are correct. From the images you have shared, the launch file is working and the two nodes - map server and lifecycle - are also started successfully.

Your issue is that RViz2 is not showing up. For this you need to:

  1. Launch RViz2 in a separate terminal
    [OR]
  2. Add RViz2 launch node in your launch file.

But not do both of them. I recommend that you to do the second option, adding Rviz launch node into your map_server launch file.

To launch rviz in a separate terminal:

  1. rviz2 - this will launch only a new instance of rviz2 gui without any display elements added.
  2. rviz2 -d /path/to/<config_file>.rviz - this will launch a pre-configured rviz2 gui.

If you start an empty Rviz2 GUI, you WILL NOT see the robot and the map directly.
You need to set Fixed Frame to map and add RobotModel display elements. Refer to the course instructions on how to add them.

This should fix your problem.

Regards,
Girish

Hi @girishkumar.kannan

I was able to execute the rviz2 launch node added to my launch file well and loaded the rviz2 correctly.


Current State:


I have a quick question. I am having now issues loading my yaml map file into the rviz2 window. I am curious if the yaml map file has an incomplete map of the environment or if the simulated environment will prevent it from loading into the user interface with the map server.

I am unable to load it since the message on the map tab states that no map was received. I am wondering how I can fix that error. I redid the map with a full detail image of the environment and that did not fix the issue.

Thank you again for your quick responses. I really appreciate it.

Best,
Agarcia

Hi @Agarcia5612 ,

Please DO NOT post images / screenshots of codes.
Please post markdown formatted code-blocks with syntax highlights.
Refer here: Fenced Code Blocks and Syntax Highlighting

Why do you have nav2_lifecycle_manager with nav2 stack nodes inside a map_server launch file?
Your nav2_map_server.launch.py file has only two nodes - rviz2 and map_server. Why do you have a lifecycle_manager node with amcl, controller_server, planner_server, recoveries_server and bt_navigator?

The following should be the contents of your map_server launch file. [This is also the correct way to post a code formatted as Markdown Code Block with Syntax Highlighting]:

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")
    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

Once RViz2 launches, you need to set your map topic QoS Durability Policy to Transient Local.

Your map file is loaded into RViz2 as an image file. So, even if your map is incomplete, the map can be loaded in RViz2. The simulated environment does not prevent it from being loaded into the RViz2 GUI (unless you also have the mapping node running, which would give a map topic clash).

If the map is not loading correctly then you have only 2 issues:

  1. Wrong path for the map file referenced in the launch file of the map_server node.
    [AND / OR]
  2. Wrong QoS setting in RViz2 for the Map Display Element.

This should fix your issue.

Regards,
Girish

Thank you so much this actually helped! The launch file you sent was able to compile the file and do the execution. I also updated with the correct QoS setting and that loaded the map!

I also added lifecycle manager node since I could not get the map sever launch to work I wanted to continue with the other example in that Unit2 course on how to activate all the ros2 services within that lifecycle_manager node.

Thank you again!

Hi @Agarcia5612 ,

Glad to know that your issue is fixed!

Regards,
Girish

Hi @girishkumar.kannan,

I ran the code again but I still run into the issue that the map does not want to load again.

This was now in Unit3 but wanted to test code from Unit2 to debug but now it back tracked to have this error and double checked the conditions of quality you wanted me to check the laser scan is still in volatile and the map topic is set to transient local and saved as such.

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')
    rviz_file = os.path.join(get_package_share_directory('map_server'), 'config','mapper_rviz_config2.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),
      
        ])


mapper_rviz_config file

Panels:

  • Class: rviz_common/Displays
    Help Height: 78
    Name: Displays
    Property Tree Widget:
    Expanded:
    - /Global Options1
    - /Status1
    - /Map1
    - /Map1/Update Topic1
    - /LaserScan1
    - /LaserScan1/Topic1
    Splitter Ratio: 0.5
    Tree Height: 548
  • Class: rviz_common/Selection
    Name: Selection
  • Class: rviz_common/Tool Properties
    Expanded:
    • /2D Goal Pose1
    • /Publish Point1
      Name: Tool Properties
      Splitter Ratio: 0.5886790156364441
  • Class: rviz_common/Views
    Expanded:
    • /Current View1
      Name: Views
      Splitter Ratio: 0.5
  • Class: rviz_common/Time
    Experimental: false
    Name: Time
    SyncMode: 0
    SyncSource: LaserScan
    Visualization Manager:
    Class: “”
    Displays:
    • Alpha: 0.5
      Cell Size: 1
      Class: rviz_default_plugins/Grid
      Color: 160; 160; 164
      Enabled: true
      Line Style:
      Line Width: 0.029999999329447746
      Value: Lines
      Name: Grid
      Normal Cell Count: 0
      Offset:
      X: 0
      Y: 0
      Z: 0
      Plane: XY
      Plane Cell Count: 10
      Reference Frame:
      Value: true
    • Alpha: 0.699999988079071
      Class: rviz_default_plugins/Map
      Color Scheme: map
      Draw Behind: false
      Enabled: true
      Name: Map
      Topic:
      Depth: 5
      Durability Policy: Transient Local
      Filter size: 10
      History Policy: Keep Last
      Reliability Policy: Best Effort
      Value: /map
      Update Topic:
      Depth: 5
      Durability Policy: Transient Local
      History Policy: Keep Last
      Reliability Policy: Best Effort
      Value: /map_updates
      Use Timestamp: false
      Value: true
    • Alpha: 1
      Autocompute Intensity Bounds: true
      Autocompute Value Bounds:
      Max Value: 10
      Min Value: -10
      Value: true
      Axis: Z
      Channel Name: intensity
      Class: rviz_default_plugins/LaserScan
      Color: 255; 255; 255
      Color Transformer: Intensity
      Decay Time: 0
      Enabled: true
      Invert Rainbow: false
      Max Color: 255; 255; 255
      Max Intensity: 0
      Min Color: 0; 0; 0
      Min Intensity: 0
      Name: LaserScan
      Position Transformer: XYZ
      Selectable: true
      Size (Pixels): 3
      Size (m): 0.05000000074505806
      Style: Flat Squares
      Topic:
      Depth: 5
      Durability Policy: Volatile
      Filter size: 10
      History Policy: Keep Last
      Reliability Policy: Best Effort
      Value: /scan
      Use Fixed Frame: true
      Use rainbow: true
      Value: true
      Enabled: true
      Global Options:
      Background Color: 48; 48; 48
      Fixed Frame: map
      Frame Rate: 30
      Name: root
      Tools:
    • Class: rviz_default_plugins/Interact
      Hide Inactive Objects: true
    • Class: rviz_default_plugins/MoveCamera
    • Class: rviz_default_plugins/Select
    • Class: rviz_default_plugins/FocusCamera
    • Class: rviz_default_plugins/Measure
      Line color: 128; 128; 0
    • Class: rviz_default_plugins/SetInitialPose
      Covariance x: 0.25
      Covariance y: 0.25
      Covariance yaw: 0.06853891909122467
      Topic:
      Depth: 5
      Durability Policy: Volatile
      History Policy: Keep Last
      Reliability Policy: Reliable
      Value: /initialpose
    • Class: rviz_default_plugins/SetGoal
      Topic:
      Depth: 5
      Durability Policy: Volatile
      History Policy: Keep Last
      Reliability Policy: Reliable
      Value: /goal_pose
    • Class: rviz_default_plugins/PublishPoint
      Single click: true
      Topic:
      Depth: 5
      Durability Policy: Volatile
      History Policy: Keep Last
      Reliability Policy: Reliable
      Value: /clicked_point
      Transformation:
      Current:
      Class: rviz_default_plugins/TF
      Value: true
      Views:
      Current:
      Class: rviz_default_plugins/Orbit
      Distance: 10
      Enable Stereo Rendering:
      Stereo Eye Separation: 0.05999999865889549
      Stereo Focal Distance: 1
      Swap Stereo Eyes: false
      Value: false
      Focal Point:
      X: 0
      Y: 0
      Z: 0
      Focal Shape Fixed Size: true
      Focal Shape Size: 0.05000000074505806
      Invert Z Axis: false
      Name: Current View
      Near Clip Distance: 0.009999999776482582
      Pitch: 0.785398006439209
      Target Frame:
      Value: Orbit (rviz)
      Yaw: 0.785398006439209
      Saved: ~
      Window Geometry:
      Displays:
      collapsed: false
      Height: 846
      Hide Left Dock: false
      Hide Right Dock: false
      QMainWindow State: 000000ff00000000fd000000040000000000000156000002affc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005d00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003e000002af000000cb00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002affc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003e000002af000000a500fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b00000003efc0100000002fb0000000800540069006d00650100000000000004b00000027900fffffffb0000000800540069006d006501000000000000045000000000000000000000023f000002af00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
      Selection:
      collapsed: false
      Time:
      collapsed: false
      Tool Properties:
      collapsed: false
      Views:
      collapsed: false
      Width: 1200
      X: 60
      Y: 60

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