launch.actions.include_launch_description module

Module for the IncludeLaunchDescription action.

class launch.actions.include_launch_description.IncludeLaunchDescription[source]

Bases: Action

Action 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.DeclareLaunchArgument action.

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.SetLaunchConfiguration action. 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’s other_launch.py and 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 let and arg for launch arguments, they are both converted into SetLaunchConfiguration actions (let). The same launch argument should not be defined using both let and arg.

__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.

get_sub_entities()[source]

Get subentities.

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.

classmethod parse(entity: Entity, parser: Parser)[source]

Return IncludeLaunchDescription action and kwargs for constructing it.