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

i try to launch this file and i got this error

asked 2022-04-30 18:54:47 -0600

iimata gravatar image

updated 2022-04-30 18:55:08 -0600

Task exception was never retrieved future: <task finished="" name="Task-2" coro="&lt;LaunchService._process_one_event()" done,="" defined="" at="" opt="" ros="" galactic="" lib="" python3.8="" site-packages="" launch="" launch_service.py:226=""> exception=RuntimeError("Included launch description missing required argument 'map' (description: 'Full path to map yaml file to load'), given: []")> Traceback (most recent call last): File "/opt/ros/galactic/lib/python3.8/site-packages/launch/launch_service.py", line 228, in _process_one_event await self.__process_event(next_event) File "/opt/ros/galactic/lib/python3.8/site-packages/launch/launch_service.py", line 248, in __process_event visit_all_entities_and_collect_futures(entity, self.__context)) File "/opt/ros/galactic/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context) File "/opt/ros/galactic/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context) File "/opt/ros/galactic/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures sub_entities = entity.visit(context) File "/opt/ros/galactic/lib/python3.8/site-packages/launch/action.py", line 108, in visit return self.execute(context) File "/opt/ros/galactic/lib/python3.8/site-packages/launch/actions/include_launch_description.py", line 147, in execute raise RuntimeError( RuntimeError: Included launch description missing required argument 'map' (description: 'Full path to map yaml file to load'), given: []


the launch file

import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription from launch.actions import (DeclareLaunchArgument, GroupAction, IncludeLaunchDescription, SetEnvironmentVariable) from launch.conditions import IfCondition from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration, PythonExpression from launch_ros.actions import PushRosNamespace

def generate_launch_description(): # Get the launch directory bringup_dir = get_package_share_directory('sam_bot_description') launch_dir = os.path.join(bringup_dir, 'launch')

# Create the launch configuration variables
namespace = LaunchConfiguration('namespace')
use_namespace = LaunchConfiguration('use_namespace')
slam = LaunchConfiguration('slam')
map_yaml_file = LaunchConfiguration('map')
use_sim_time = LaunchConfiguration('use_sim_time')
params_file = LaunchConfiguration('params_file')
autostart = LaunchConfiguration('autostart')

stdout_linebuf_envvar = SetEnvironmentVariable(
    'RCUTILS_LOGGING_BUFFERED_STREAM', '1')

declare_namespace_cmd = DeclareLaunchArgument(
    'namespace',
    default_value='',
    description='Top-level namespace')

declare_use_namespace_cmd = DeclareLaunchArgument(
    'use_namespace',
    default_value='false',
    description='Whether to apply a namespace to the navigation stack')

declare_slam_cmd = DeclareLaunchArgument(
    'slam',
    default_value='False',
    description='Whether run a SLAM')

declare_map_yaml_cmd = DeclareLaunchArgument(
    'map',
    description='Full path to map yaml file to load')

declare_use_sim_time_cmd = DeclareLaunchArgument(
    'use_sim_time',
    default_value='false',
    description='Use simulation (Gazebo) clock if true')

declare_params_file_cmd = DeclareLaunchArgument(
    'params_file',
    default_value=os.path.join(bringup_dir, 'config', 'nav2_params.yaml'),
    description='Full path to the ROS2 parameters file to use for all launched nodes')

declare_autostart_cmd = DeclareLaunchArgument(
    'autostart', default_value='true',
    description='Automatically startup the nav2 stack')

# Specify the actions
bringup_cmd_group = GroupAction([
    PushRosNamespace(
        condition=IfCondition(use_namespace),
        namespace=namespace),

    IncludeLaunchDescription(
        PythonLaunchDescriptionSource(os.path.join(launch_dir, 'slam_launch.py')),
        condition=IfCondition(slam),
        launch_arguments={'namespace': namespace,
                          'use_sim_time': use_sim_time,
                          'autostart': autostart,
                          'params_file': params_file}.items()),

    IncludeLaunchDescription(
        PythonLaunchDescriptionSource(os.path.join(launch_dir,
                                                   'localization_launch.py')),
        condition=IfCondition(PythonExpression(['not ', slam])),
        launch_arguments={'namespace': namespace,
                          'map': map_yaml_file,
                          'use_sim_time': use_sim_time,
                          'autostart': autostart,
                          'params_file': params_file,
                          'use_lifecycle_mgr': 'false'}.items()),

    IncludeLaunchDescription(
        PythonLaunchDescriptionSource(os.path.join(launch_dir, 'navigation_launch.py')),
        launch_arguments={'namespace': namespace,
                          'use_sim_time': use_sim_time,
                          'autostart': autostart,
                          'params_file': params_file,
                          'use_lifecycle_mgr': 'false',
                          'map_subscribe_transient_local': 'true'}.items()),
])

# Create the launch description and populate
ld = LaunchDescription()

# Set environment variables
ld.add_action(stdout_linebuf_envvar)

# Declare the launch options
ld.add_action(declare_namespace_cmd)
ld.add_action(declare_use_namespace_cmd)
ld.add_action(declare_slam_cmd)
ld.add_action(declare_map_yaml_cmd)
ld.add_action ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-05-02 08:03:18 -0600

WarTurtle gravatar image

You need the full path to your map yaml file such as this:

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

In this case, the map location would be in the package sam_bot_description under the maps folder

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-04-30 18:54:47 -0600

Seen: 698 times

Last updated: May 02 '22