Category Archives: Nav2

Nav2 Localisation not Loading a Default Map

Hi everyone,

I finally have my diffdrive robot navigating with waypoints using Nav2 and this great tutorial. However, while trying to use a saved map for localization I ran into the following error:

ros2 launch my_bot localization_launch.py use_sim_time:=false
....
ocalization]: Configuring map_server
[map_server-1] [INFO] [1673064055.126698671] [map_server]: Configuring
[map_server-1] [ERROR] [map_io]: Failed processing YAML file /home/chris/Desktop/dev_ws/install/my_bot/share/my_bot/maps/chris_room_07012023/chris_room_save.yaml at position (-1:-1) for reason: bad file
[map_server-1] [ERROR] [1673064055.126801797] []: Caught exception in callback for transition 10
[map_server-1] [ERROR] [1673064055.126805589] []: Original error: Failed to load map yaml file: /home/chris/Desktop/dev_ws/install/my_bot/share/my_bot/maps/chris_room_07012023/chris_room_save.yaml
[map_server-1] [WARN] [1673064055.126811964] []: Error occurred while doing error handling.
[map_server-1] [FATAL] [1673064055.126815339] [map_server]: Lifecycle node map_server does not have error state implemented
[map_server-1] [INFO] [map_io]: Loading yaml file: /home/chris/Desktop/dev_ws/install/my_bot/share/my_bot/maps/chris_room_07012023/chris_room_save.yaml
[lifecycle_manager-3] [ERROR] [1673064055.127951438] [lifecycle_manager_localization]: Failed to change state for node: map_server
[lifecycle_manager-3] [ERROR] [1673064055.128136607] [lifecycle_manager_localization]: Failed to bring up all requested nodes. Aborting bringup.
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)

I had the following entry in my launch file:

        DeclareLaunchArgument(
            'map',
            default_value=os.path.join(bringup_dir, 'maps', 'chris_room_07012023/chris_room_save.yaml'),
            description='Full path to map yaml file to load'),

My map was also in the correct folder and valid output from the slam_toolbox plugin in rviz2. I had also run `colcon build –symlink-install`.

Initially I thought that I’d used the wrong settings in rviz but eventually I realised that the file was missing from the install directory. Despite running colcon build it was not building my new map files.

Luckily, this ended up being a fairly easy fix. I’d simply missed adding the directory to CMakeLists.txt.

# Add maps to the end of the DIRECTORY line.
install(
  DIRECTORY config description launch worlds maps
  DESTINATION share/${PROJECT_NAME}
)

After updating CMakeLists.txt and re-running colcon build --symlink-install I was finally able to start localization with a default map.