ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You can use the GroupAction
action. From its docstring:
Action that yields other actions, optionally scoping launch configurations.
This action is used to nest other actions without including a separate launch description, while also optionally having a condition (like all other actions), scoping launch configurations, and/or declaring launch configurations for just the group and its yielded actions.
You can wrap the inclusion of ext in a group action to achieve the scoping you want:
GroupAction([
IncludeLaunchDescription(
PythonLaunchDescriptionSource([ThisLaunchFileDir(),'/ext_launch.py']),
launch_arguments={
'arg1': 'External_Arg_Mod'
}.items()
)
]),
With that, running ros2 launch launch_test base_launch.py
gives:
[INFO] [launch.user]: Internal Arg (before): Internal_Arg
[INFO] [launch.user]: External Arg: External_Arg_Mod
[INFO] [launch.user]: Internal Arg (after): Internal_Arg
Internally the scoping works by using the PushLaunchConfigurations
and PopLaunchConfigurations
actions:
if self.__scoped:
self.__actions_to_return = [
PushLaunchConfigurations(),
*self.__actions_to_return,
PopLaunchConfigurations()
]
So you may also be able to surround the include with those in your own launch file if you feel that using GroupAction
around a single action is less nice.