ROS2 nav2 map_server - Problems loading map with nav2_map_server [closed]

asked 2022-03-28 07:35:46 -0500

lcfs gravatar image

I am using ROS-Foxy with ubuntu 20.04 LTS. I was uses to ROS1, so I am new in the ROS2 world and I am working in the transition of my software for ROS2. Map_server is a simple, yet important package for me. So I got surprised with it's complexity to work in ROS2.

I followed the instructions in the documentation, so:

1- Created the "map_server_params.yaml" (I found out later that indentation is crucial in this file)

# map_server_params.yaml
        yaml_filename: "map.yaml"

2- the map.yaml is just like in ROS1 version:

image: map.pgm
resolution: 0.050000
origin: [-1.000000, -17.000000, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196

3 - run the node:

$ ros2 run nav2_map_server map_server _params:=map_server_params.yaml

4- As a result, the the map is not published:

[INFO] [1648467290.572912903] [map_server]: 
    map_server lifecycle node launched. 
    Waiting on external lifecycle transitions to activate
    See for more information.
[INFO] [1648467290.572984105] [map_server]: Creating

5 - I managed to find that it is necessary to activate the "lifecycle" , which is not indicated in the original documentation! I

$ ros2 run nav2_util lifecycle_bringup map_server

6 - However, it is not working either:

$ ros2 run nav2_map_server map_server _params:=map_server_params.yaml
[INFO] [1648467520.824391783] [map_server]: 
    map_server lifecycle node launched. 
    Waiting on external lifecycle transitions to activate
    See for more information.
[INFO] [1648467520.824462825] [map_server]: Creating
[INFO] [1648467538.673566146] [map_server]: Configuring
[ERROR] [1648467538.673770244] []: Caught exception in callback for transition 10
[ERROR] [1648467538.673809412] []: Original error: yaml_filename
[WARN] [1648467538.673851628] []: Error occurred while doing error handling.
[FATAL] [1648467538.673883971] [map_server]: Lifecycle node map_server does not have error state implemented
[WARN] [1648467538.674845275] [rcl_lifecycle]: No transition matching 3 found for current state unconfigured
[ERROR] [1648467538.674900522] []: Unable to start transition 3 from current state unconfigured: Transition is not registered., at /tmp/binarydeb/ros-foxy-rcl-lifecycle-1.1.13/src/rcl_lifecycle.c:350

7- I decided to create a launch file (which actually worked, partially solving the problem)

import os
import yaml
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import ExecuteProcess
from launch.substitutions import LaunchConfiguration
import launch_ros.actions

def generate_launch_description():

    ld = LaunchDescription()

    # Map server
    map_server_config_path = os.path.join(
    map_server_cmd = Node(


    return ld

8 - I had to add the data folder to cmake in order to use the launch File (I am mentioning this in case someone else gets stuck too)


9 - After compiling, I managed to publish a map, yet I still need to run it with two commands:

$ ros2 launch agrob_path

$ ros2 run nav2_util lifecycle_bringup map_server

10 - This works, but I wanted to publish a map with one simple command, or at least with one file! So, I tried to add the lifecycle_bringup to the map launch ... (more)

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by jarvisschultz
close date 2022-03-28 16:14:11.203659


jarvisschultz gravatar image jarvisschultz  ( 2022-03-28 16:14:21 -0500 )edit