launch.launch_description_sources.python_launch_file_utilities module

Python package utility functions related to loading Python Launch Files.

exception launch.launch_description_sources.python_launch_file_utilities.InvalidPythonLaunchFileError[source]

Bases: Exception

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

launch.launch_description_sources.python_launch_file_utilities.get_launch_description_from_python_launch_file(python_launch_file_path: str | Path) 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.python_launch_file_utilities.load_python_launch_file_as_module(python_launch_file_path: str | Path) ModuleType[source]

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