ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

timeout error while saving map

asked 2021-06-03 23:58:01 -0500

Youssef_Lah gravatar image

Hi,

Environment: ROS2 Foxy / ubuntu

I am trying to save a map, but I receive a timeout error, I tried using SLAM and then cartographer but i always got the error. I tried also to increase the param save_map_timeout but without success, I think the problem comes from the map_saver but i don't know how to solve it, here is the error:

[INFO] [1622781078.674465384] [map_saver]: 
    map_saver lifecycle node launched. 
    Waiting on external lifecycle transitions to activate
    See https://design.ros2.org/articles/node_lifecycle.html for more information.
[INFO] [1622781078.674613664] [map_saver]: Creating
[INFO] [1622781078.675119277] [map_saver]: Saving map from 'map' topic to '/home/youssef/map.png' file
[WARN] [1622781078.675153653] [map_saver]: Free threshold unspecified. Setting it to default value: 0.250000
[WARN] [1622781078.675175138] [map_saver]: Occupied threshold unspecified. Setting it to default value: 0.650000
[ERROR] [1622781080.678197391] [map_saver]: Failed to save the map: timeout
[INFO] [1622781080.678245818] [map_saver]: Destroying

Any help please, i am tired searching and tuning params. Thanks in advance.

edit retag flag offensive close merge delete

Comments

Similar problem was reported a year ago but the problem still appear https://github.com/ros-planning/navig...

Youssef_Lah gravatar image Youssef_Lah  ( 2021-06-04 00:00:29 -0500 )edit

Update: I've configured the ros-testing repo for Galactic, it's working well, no errors, seems like it's a bug that was patched for galactic but not for foxy

Youssef_Lah gravatar image Youssef_Lah  ( 2021-06-04 15:06:09 -0500 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2021-06-14 14:13:24 -0500

updated 2021-06-17 05:25:52 -0500

  • The nav2_map_saver CLI for sure doesn't work, as it doesn't have the capability of setting a custom timeout.

    $ ros2 run nav2_map_server map_saver_cli -h
    
    Usage:
    map_saver_cli [arguments] [--ros-args ROS remapping args]
    
    Arguments:
      -h/--help
      -t <map_topic>
      -f <mapname>
      --occ <threshold_occupied>
      --free <threshold_free>
      --fmt <image_format>
      --mode trinary(default)/scale/raw
    
    NOTE: --ros-args should be passed at the end of command line
    
  • So we create a custom launch file with a parametric YAML file that will help us to setup our timeout argument.

     The Launch File: - let's say map_saver.launch.py

#!/usr/bin/env python3
import os
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from ament_index_python.packages import get_package_share_directory
from launch_ros.actions import Node

def generate_launch_description():

    # .................. Configurable Arguments .....................

    use_sim_time = True
    map_saver_params_file = 'map_saver_params.yaml'
    # ...............................................................


    pkg_dir = get_package_share_directory('your_ROS2_pkg')
    map_save_config = os.path.join(pkg_dir, 'path_to_your_config_file', map_saver_params_file)


    return LaunchDescription([

        DeclareLaunchArgument("use_sim_time", default_value=str(use_sim_time), description="Use simulation/Gazebo clock"),
        DeclareLaunchArgument("map_saver_params_file", default_value=map_save_config, description="Map Saver Configuration File"),

        Node(
            package='nav2_map_server',
            executable='map_saver_server',
            output='screen',
            emulate_tty=True,  
            parameters=[LaunchConfiguration('map_saver_params_file')]                  
        ),

        Node(
            package='nav2_lifecycle_manager',
            executable='lifecycle_manager',
            name='lifecycle_manager',
            output='screen',
            emulate_tty=True,  
            parameters=[
                {'use_sim_time': LaunchConfiguration('use_sim_time')},
                {'autostart': True},
                {'node_names': ['map_saver']}]
        )

    ])


     The Configuration FIle - map_saver_params.yaml

map_saver:
  ros__parameters:
    use_sim_time: True
    save_map_timeout: 5000 # The glorious timeout parameter
    free_thresh_default: 0.25
    occupied_thresh_default: 0.65


* Execute the launch file once you're done mapping the environment.

* Finally, on a separate terminal, call the service to generate your map:

    $ ros2 service call /map_saver/save_map nav2_msgs/srv/SaveMap "{map_topic: map, map_url: my_map, image_format: pgm, map_mode: trinary, free_thresh: 0.25, occupied_thresh: 0.65}"


References


Note: Please let me know if this solution doesn't work out for you. If in case it does, feel free to upvote my answer.

edit flag offensive delete link more
3

answered 2021-12-05 04:27:08 -0500

KVS Mohan Vamsi gravatar image

ros2 run nav2_map_server map_saver_cli -f my_map --ros-args -p save_map_timeout:=10000

This command is what worked for me. using ros2 foxy and unity.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-06-03 23:58:01 -0500

Seen: 2,319 times

Last updated: Jun 17 '21