"No map received" ROS 2 Navigation (Galactic)

Hello

I’m currently trying to complete the ROS 2 Navigation (Galactic) course. However, on part 3 “How to localize the robot in the environment” I run into an error when using acml. The error I receive is that “Frame [map] does not exist” when I open Rviz2. I tried debugging for a long time, until I ended up copying the solution code for the exercises, but I still get the same error. My launch file, config files and setup file is identical to the solutions, and the amcl packages builds and runs with expected output:

user:~/ros2_ws$ colcon build --packages-select localization_serverStarting >>> localization_server
Finished <<< localization_server [2.14s]Summary: 1 package finished [2.50s]

user:~/ros2_ws$ source ~/ros2_ws/install/setup.bash

user:~/ros2_ws$ ros2 launch localization_server localization.launch.py

[INFO] [launch]: All log files can be found below /home/user/.ros/log/2023-10-14
-12-58-31-648849-3_xterm-2846
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [map_server-1]: process started with pid [2848]
[INFO] [amcl-2]: process started with pid [2850]
[INFO] [lifecycle_manager-3]: process started with pid [2852]
[lifecycle_manager-3] [INFO] [1697288312.264099797] [lifecycle_manager_localization]: Creating
[lifecycle_manager-3] [INFO] [1697288312.272206926] [lifecycle_manager_localization]: Creating and initializing lifecycle service clients
[lifecycle_manager-3] [INFO] [1697288312.279015844] [lifecycle_manager_localization]: Starting managed nodes bringup...
[lifecycle_manager-3] [INFO] [1697288312.279625725] [lifecycle_manager_localization]: Configuring map_server
[amcl-2] [INFO] [1697288312.286019997] [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] [1697288312.286166428] [amcl]: Creating
[map_server-1] [INFO] [1697288312.437992960] [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] [1697288312.438141299] [map_server]: Creating
[map_server-1] [INFO] [1697288312.451080866] [map_server]: Configuring
[map_server-1] [INFO] [map_io]: Loading yaml file: /home/user/ros2_ws/install/map_server/share/map_server/config/turtlebot_area.yaml
[map_server-1] [DEBUG] [map_io]: resolution: 0.05
[map_server-1] [DEBUG] [map_io]: origin[0]: -4.31
[map_server-1] [DEBUG] [map_io]: origin[1]: -5.33
[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/user/ros2_ws/install/map_server/share/map_server/config/turtlebot_area.pgm
[map_server-1] [DEBUG] [map_io]: Read map /home/user/ros2_ws/install/map_server/share/map_server/config/turtlebot_area.pgm: 232 X 218 map @ 0.05 m/cell
[lifecycle_manager-3] [INFO] [1697288312.516344792] [lifecycle_manager_localization]: Configuring amcl
[amcl-2] [INFO] [1697288312.516687330] [amcl]: Configuring
[amcl-2] [INFO] [1697288312.516796026] [amcl]: initTransforms
[amcl-2] [INFO] [1697288312.528289610] [amcl]: initPubSub
[amcl-2] [INFO] [1697288312.531923916] [amcl]: Subscribed to map topic.
[lifecycle_manager-3] [INFO] [1697288312.534485837] [lifecycle_manager_localization]: Activating map_server
[map_server-1] [INFO] [1697288312.534736499] [map_server]: Activating
[map_server-1] [INFO] [1697288312.534963188] [map_server]: Creating bond (map_server) to lifecycle manager.
[amcl-2] [INFO] [1697288312.535673053] [amcl]: Received a 232 X 218 map @ 0.050m/pix
[lifecycle_manager-3] [INFO] [1697288312.638709625] [lifecycle_manager_localization]: Server map_server connected with bond.
[lifecycle_manager-3] [INFO] [1697288312.638785905] [lifecycle_manager_localization]: Activating amcl
[amcl-2] [INFO] [1697288312.638997754] [amcl]: Activating
[amcl-2] [INFO] [1697288312.639051963] [amcl]: Creating bond (amcl) to lifecycle manager.
[amcl-2] [INFO] [1697288312.665716697] [amcl]: createLaserObject
[lifecycle_manager-3] [INFO] [1697288312.741945513] [lifecycle_manager_localization]: Server amcl connected with bond.
[lifecycle_manager-3] [INFO] [1697288312.742020307] [lifecycle_manager_localization]: Managed nodes are active
[lifecycle_manager-3] [INFO] [1697288312.742050165] [lifecycle_manager_localization]: Creating bond timer...
[amcl-2] [WARN] [1697288314.472852263] [amcl]: AMCL cannot publish a pose or update the transform. Please set the initial pose...

I also check the topics, and I can see that the map topic exists, but when I echo it, nothing is published to it. I find it weird that the output from amcl package is saying that it receives the map I made in part 2 of this tutorial.

I also checked the tf tree:

digraph G {
"odom" -> "base_footprint"[label=" Broadcaster: default_authority\nAverage rate: 29.61\nBuffer length: 5.032\nMost recent transform: 1481.414\nOldest transform: 1476.382\n"];
"base_footprint" -> "base_link"[label=" Broadcaster: default_authority\nAverage rate: 10000.0\nBuffer length: 0.0\nMost recent transform: 0.0\nOldest transform: 0.0\n"];
"base_link" -> "caster_back_link"[label=" Broadcaster: default_authority\nAverage rate: 10000.0\nBuffer length: 0.0\nMost recent transform: 0.0\nOldest transform: 0.0\n"];
"base_link" -> "imu_link"[label=" Broadcaster: default_authority\nAverage rate: 10000.0\nBuffer length: 0.0\nMost recent transform: 0.0\nOldest transform: 0.0\n"];
"base_link" -> "base_scan"[label=" Broadcaster: default_authority\nAverage rate: 10000.0\nBuffer length: 0.0\nMost recent transform: 0.0\nOldest transform: 0.0\n"];
"base_link" -> "wheel_left_link"[label=" Broadcaster: default_authority\nAverage rate: 19.608\nBuffer length: 4.998\nMost recent transform: 1481.414\nOldest transform: 1476.416\n"];
"base_link" -> "wheel_right_link"[label=" Broadcaster: default_authority\nAverage rate: 19.608\nBuffer length: 4.998\nMost recent transform: 1481.414\nOldest transform: 1476.416\n"];
edge [style=invis];
 subgraph cluster_legend { style=bold; color=black; label ="view_frames Result";
"Recorded at time: 1697288688.9173172"[ shape=plaintext ] ;
}->"odom";
}

This is what my rviz2 looks like:

Is anyone able to help me? Would appreciate any help because I need the amcl to work in the next tutorials as well:)

I post my files here:

localization.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():
    
    nav2_yaml = os.path.join(get_package_share_directory('localization_server'), 'config', 'amcl_config.yaml')
    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_amcl',
            executable='amcl',
            name='amcl',
            output='screen',
            parameters=[nav2_yaml]
        ),

        Node(
            package='nav2_lifecycle_manager',
            executable='lifecycle_manager',
            name='lifecycle_manager_localization',
            output='screen',
            parameters=[{'use_sim_time': True},
                        {'autostart': True},
                        {'node_names': ['map_server', 'amcl']}]
        )
    ])

setup.py

from setuptools import setup
import os
from glob import glob

package_name = 'localization_server'

setup(
    name=package_name,
    version='0.0.0',
    packages=[package_name],
    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': [
        ],
    },
)

acml_config.yaml

amcl:
  ros__parameters:
    use_sim_time: True
    alpha1: 0.2
    alpha2: 0.2
    alpha3: 0.2
    alpha4: 0.2
    alpha5: 0.2
    base_frame_id: "base_footprint"
    beam_skip_distance: 0.5
    beam_skip_error_threshold: 0.9
    beam_skip_threshold: 0.3
    do_beamskip: false
    global_frame_id: "map"
    lambda_short: 0.1
    laser_likelihood_max_dist: 2.0
    laser_max_range: 100.0
    laser_min_range: -1.0
    laser_model_type: "likelihood_field"
    max_beams: 60
    max_particles: 8000
    min_particles: 200
    odom_frame_id: "odom"
    pf_err: 0.05
    pf_z: 0.99
    recovery_alpha_fast: 0.0
    recovery_alpha_slow: 0.0
    resample_interval: 1
    robot_model_type: "differential"
    save_pose_rate: 0.5
    sigma_hit: 0.2
    tf_broadcast: true
    transform_tolerance: 1.0
    update_min_a: 0.2
    update_min_d: 0.25
    z_hit: 0.5
    z_max: 0.05
    z_rand: 0.5
    z_short: 0.05

Hello @stinky ,

Are you setting the initial pose in RViz? Without setting the initial pose, the map frame will remain disconnected from the robot.

Hi @stinky ,

Welcome to this Community!

You cannot echo the topic to see if anything is published to it, especially if it was a one-time publisher, you will not receive any data.
The best option is to see if any publisher is attached to the topic by doing
ros2 topic info /map -v.

Anyways, coming to your problem of map not being received, follow the steps exactly in order.

  1. Start Simulation in a terminal.
  2. Start the ROS bridge in a terminal (if required).
  3. Start RViz now.
  4. Now start the launch file containing map_server.
  5. Start the launch file with amcl [if you have combined amcl with map_server make sure map_server is launched before amcl]
  6. Now check Rviz for the map.

The trick here is to start Rviz first, before starting map_server in ROS2.

Try this out and let us know if you got it working!

Regards,
Girish

1 Like

Yes, and when I do I get the following warning in the terminal where I launched amcl

[amcl-2] [INFO] [1697637550.070547977] [amcl]: initialPoseReceived
[amcl-2] [WARN] [1697637550.070744520] [amcl]: Failed to transform initial pose in time (Lookup would require extrapolation into the future.  Requested time 1697637550.070336 but the latest data is at time 270.504000, when looking up transform from frame [odom] to frame [base_footprint])

And in the terminal running RViz2

Warning: Invalid frame ID "map" passed to canTransform argument target_frame - frame does not exist
         at line 156 in /tmp/binarydeb/ros-galactic-tf2-0.17.2/src/buffer_core.cpp

This is how my RViz looks like

Hello @stinky ,

I just tested your setup, and it’s working OK. You have to update a couple of QoS settings in your RViz2, though. Here are the steps I followed:

  1. Launch localization system
  2. Launch RViz2 and load the localization config file
  3. Set the Durability Policy of the map to Transient Local in order to visualize the map:
  4. With the map, set the initial pose of the robot. After you set the initial pose, you should be able to visualize everything correctly:
  5. In order to properly visualize the laser in RViz2, you have to change the Reliability to Best Effort:
    Captura de Pantalla 2023-10-19 a las 10.20.06

I verified the TF tree and amcl is correctly publishing the map->odom TF:

Best,

Thank. This seem to solve the issue!

Thanks for the help. The solution provided by albertoezquerro solved the issue.

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