0
$\begingroup$

Rosanswers logo

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.


Originally posted by Youssef_Lah on ROS Answers with karma: 195 on 2021-06-03

Post score: 1


Original comments

Comment by Youssef_Lah on 2021-06-04:
Similar problem was reported a year ago but the problem still appear https://github.com/ros-planning/navigation2/issues/1864

Comment by Youssef_Lah on 2021-06-04:
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

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

  • 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.*

Originally posted by LSD with karma: 98 on 2021-06-14

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by KVS Mohan Vamsi with karma: 31 on 2021-12-05

This answer was NOT ACCEPTED on the original site

Post score: 3

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.