launch.actions.include_launch_description module
Module for the IncludeLaunchDescription action.
- class launch.actions.include_launch_description.IncludeLaunchDescription[source]
Bases:
ActionAction that includes a launch description source and yields its entities when visited.
It is possible to pass arguments to the launch description, which it declared with the
launch.actions.DeclareLaunchArgumentaction.If any given arguments do not match the name of any declared launch arguments, then they will still be set as Launch Configurations using the
launch.actions.SetLaunchConfigurationaction. This is done because it’s not always possible to detect all instances of the declare launch argument class in the given launch description.On the other side, an error will sometimes be raised if the given launch description declares a launch argument and its value is not provided to this action. It will only produce this error, however, if the declared launch argument is unconditional (sometimes the action that declares the launch argument will only be visited in certain circumstances) and if it does not have a default value on which to fall back.
Conditionally included launch arguments that do not have a default value will eventually raise an error if this best effort argument checking is unable to see an unsatisfied argument ahead of time.
For example, to include
my_pkg’sother_launch.pyand set launch arguments for it:def generate_launch_description(): return ([ SetLaunchConfiguration('arg1', 'value1'), IncludeLaunchDescription( AnyLaunchDescriptionSource([ PathJoinSubstitution([ FindPackageShare('my_pkg'), 'launch', 'other_launch.py', ]), ]), launch_arguments={ 'other_arg1': LaunchConfiguration('arg1'), 'other_arg2': 'value2', }.items(), ), ])
<launch> <let name="arg1" value="value1" /> <include file="$(find-pkg-share my_pkg)/launch/other_launch.py"> <let name="other_arg1" value="$(var arg1)" /> <let name="other_arg2" value="value2" /> </include> </launch>
launch: - let: name: 'arg1' value: 'value1' - include: file: '$(find-pkg-share my_pkg)/launch/other_launch.py' let: - name: 'other_arg1' value: '$(var arg1)' - name: 'other_arg2' value: 'value2'
Note
While frontends currently support both
letandargfor launch arguments, they are both converted intoSetLaunchConfigurationactions (let). The same launch argument should not be defined using bothletandarg.- __init__(launch_description_source: LaunchDescriptionSource | str | Path | Substitution | Iterable[str | Path | Substitution], *, launch_arguments: Iterable[Tuple[str | Path | Substitution | Iterable[str | Path | Substitution], str | Path | Substitution | Iterable[str | Path | Substitution]]] | None = None, **kwargs) None[source]
Create an IncludeLaunchDescription action.
- execute(context: LaunchContext) List[LaunchDescriptionEntity][source]
Execute the action.
- property launch_arguments: Sequence[Tuple[str | Path | Substitution | Iterable[str | Path | Substitution], str | Path | Substitution | Iterable[str | Path | Substitution]]]
Getter for self.__launch_arguments.
- property launch_description_source: LaunchDescriptionSource
Getter for self.__launch_description_source.