ros2 / launch

Tools for launching multiple processes and for writing tests involving multiple processes.
Apache License 2.0
125 stars 139 forks source link

Bug when setting launch arguments of included descriptions #749

Open jdlangs opened 9 months ago

jdlangs commented 9 months ago

Bug report

Required Info:

Steps to reproduce issue

Build this package and run ros2 launch launch_args_ex top.launch.py bottom1:=true bottom2:=true

top.launch.py

import os
from ament_index_python import get_package_share_directory
import launch
from launch.actions import IncludeLaunchDescription

def generate_launch_description():
    return launch.LaunchDescription([
        IncludeLaunchDescription(
            os.path.join(
                get_package_share_directory('launch_args_ex'),
                'launch',
                'bottom.launch.py',
            ),
        ),
    ])

bottom.launch.py

import launch
from launch.actions import DeclareLaunchArgument

def generate_launch_description():
    return launch.LaunchDescription([
        DeclareLaunchArgument("bottom1", description="Inner argument 1"),
        DeclareLaunchArgument("bottom2", description="Inner argument 2"),
    ])

Expected behavior

The bottom1 and bottom2 arguments receive values passed from the command-line.

Actual behavior

❯ ros2 launch launch_args_ex top.launch.py bottom1:=true bottom2:=true                                                                                                                     
[INFO] [launch]: All log files can be found below ...
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): Included launch description missing required argument 'bottom1' (description: 'Inner argument 1'), given: []

What's weird is if you don't set one of the args, it now sees that the other one was given:

❯ ros2 launch launch_args_ex top.launch.py bottom2:=true                                                                                                                                                           ─╯
[INFO] [launch]: All log files can be found below ...
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): Included launch description missing required argument 'bottom1' (description: 'Inner argument 1'), given: [bottom2]

Here's a full debug output as well:

❯ ros2 launch launch_args_ex top.launch.py bottom1:=true bottom2:=true -d                                                                                                                                          ─╯
[DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.IncludeLaunchDescription'
[INFO] [launch]: All log files can be found below ...
[INFO] [launch]: Default logging verbosity is set to DEBUG
[DEBUG] [launch]: processing event: '<launch.events.include_launch_description.IncludeLaunchDescription object at 0x7fe55b1ae700>'
[DEBUG] [launch]: processing event: '<launch.events.include_launch_description.IncludeLaunchDescription object at 0x7fe55b1ae700>' ✓ '<launch.event_handlers.on_include_launch_description.OnIncludeLaunchDescription object at 0x7fe55b183f10>'
[DEBUG] [launch]: An exception was raised in an async action/event
[DEBUG] [launch]: Traceback (most recent call last):
  File "/home/josh/ros2_dev/install/launch/lib/python3.8/site-packages/launch/launch_service.py", line 337, in run_async
    raise completed_tasks_exceptions[0]
  File "/home/josh/ros2_dev/install/launch/lib/python3.8/site-packages/launch/launch_service.py", line 230, in _process_one_event
    await self.__process_event(next_event)
  File "/home/josh/ros2_dev/install/launch/lib/python3.8/site-packages/launch/launch_service.py", line 250, in __process_event
    visit_all_entities_and_collect_futures(entity, self.__context))
  File "/home/josh/ros2_dev/install/launch/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 "/home/josh/ros2_dev/install/launch/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 "/home/josh/ros2_dev/install/launch/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)
  [Previous line repeated 1 more time]
  File "/home/josh/ros2_dev/install/launch/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 "/home/josh/ros2_dev/install/launch/lib/python3.8/site-packages/launch/action.py", line 109, in visit
    return self.execute(context)
  File "/home/josh/ros2_dev/install/launch/lib/python3.8/site-packages/launch/actions/include_launch_description.py", line 173, in execute
    raise RuntimeError(
RuntimeError: Included launch description missing required argument 'bottom1' (description: 'Inner argument 1'), given: []

[ERROR] [launch]: Caught exception in launch (see debug for traceback): Included launch description missing required argument 'bottom1' (description: 'Inner argument 1'), given: []
[DEBUG] [launch.launch_context]: emitting event: 'launch.events.Shutdown'
[DEBUG] [launch]: processing event: '<launch.events.shutdown.Shutdown object at 0x7fe55b183df0>'
[DEBUG] [launch]: processing event: '<launch.events.shutdown.Shutdown object at 0x7fe55b183df0>' ✓ '<launch.event_handlers.on_shutdown.OnShutdown object at 0x7fe55b183430>'
sloretz commented 9 months ago

@methylDragon Would you be willing to look into the behavior and figure out where the bug is? 🧇

It seems like passing launch_arguments to IncludeLaunchDescription in top.launch.py might be part of the solution, but if I understand correctly that wouldn't explain why setting bottom2 only seems to have been recognized by bottom.launch.py.