launch.launch_description_sources package

Submodules

Module contents

Package for launch_description_sources.

class launch.launch_description_sources.AnyLaunchDescriptionSource[source]

Bases: LaunchDescriptionSource

Encapsulation of a launch file, which can be loaded during launch.

This launch description source will attempt to load a launch file based on its extension first, then it will try to load the file as a python launch file, and then as a declarative (markup based) launch file. It is recommended to use specific LaunchDescriptionSource subclasses when possible.

__init__(launch_file_path: str | Substitution | Iterable[str | Substitution]) None[source]

Create an AnyLaunchDescriptionSource.

If a relative path is passed, it will be relative to the current working directory wherever the launch file was run from.

Parameters:

launch_file_path – the path to the launch file. It can be made up of Substitution instances which are expanded when get_launch_description() is called.

class launch.launch_description_sources.FrontendLaunchDescriptionSource[source]

Bases: LaunchDescriptionSource

Encapsulation of a declarative (markup based) launch file.

It can be loaded during launch using an IncludeLaunchDescription action.

__init__(launch_file_path: str | ~launch.substitution.Substitution | ~typing.Iterable[str | ~launch.substitution.Substitution], *, method: str = 'interpreted frontend launch file', parser: ~typing.Type[~launch.frontend.parser.Parser] = <class 'launch.frontend.parser.Parser'>) None[source]

Create a FrontendLaunchDescriptionSource.

The given file path should be to a launch frontend style file (like xml or yaml). If a relative path is passed, it will be relative to the current working directory wherever the launch file was run from.

Parameters:
  • launch_file_path – the path to the launch file. It can be made up of Substitution instances which are expanded when get_launch_description() is called.

  • parser – an specific parser implementation

exception launch.launch_description_sources.InvalidFrontendLaunchFileError[source]

Bases: InvalidLaunchFileError

Exception raised when the given frontend launch file is not valid.

exception launch.launch_description_sources.InvalidLaunchFileError[source]

Bases: Exception

Exception raised when the given launch file is not valid.

__init__(extension='', *, likely_errors=None)[source]

Create an InvalidLaunchFileError.

exception launch.launch_description_sources.InvalidPythonLaunchFileError[source]

Bases: Exception

Exception raised when the given Python launch file is not valid.

class launch.launch_description_sources.PythonLaunchDescriptionSource[source]

Bases: LaunchDescriptionSource

Encapsulation of a Python launch file, which can be loaded during launch.

__init__(launch_file_path: str | Substitution | Iterable[str | Substitution]) None[source]

Create a PythonLaunchDescriptionSource.

The given file path should be to a .launch.py style file. The path should probably be absolute, since the current working directory will be wherever the launch file was run from, which might change depending on the situation. The path can be made up of Substitution instances which are expanded when get_launch_description() is called.

See also get_launch_description_from_python_launch_file().

Parameters:

launch_file_path – the path to the launch file

launch.launch_description_sources.get_launch_description_from_any_launch_file(launch_file_path: str, *, parser: ~typing.Type[~launch.frontend.parser.Parser] = <class 'launch.frontend.parser.Parser'>) LaunchDescription[source]

Load a given launch file (by path), and return the launch description from it.

Raises:
launch.launch_description_sources.get_launch_description_from_frontend_launch_file(frontend_launch_file_path: str, *, parser: ~typing.Type[~launch.frontend.parser.Parser] = <class 'launch.frontend.parser.Parser'>) LaunchDescription[source]

Load a LaunchDescription from a declarative (markup based) launch file.

launch.launch_description_sources.get_launch_description_from_python_launch_file(python_launch_file_path: str) LaunchDescription[source]

Load a given Python launch file (by path), and return the launch description from it.

Python launch files are expected to have a .py extension and must provide a function within the module called generate_launch_description(). This function is called after loading the module to get the single launch.LaunchDescription class from it. The signature of the function should be as follows:

def generate_launch_description() -> launch.LaunchDescription:
    ...

The Python launch file, as much as possible, should avoid side-effects. Keep in mind that the reason it is being loaded may be just to introspect the launch description and not necessarily to execute the launch itself.

launch.launch_description_sources.load_python_launch_file_as_module(python_launch_file_path: str) module[source]

Load a given Python launch file (by path) as a Python module.