launch_ros.utilities package
Submodules
- launch_ros.utilities.evaluate_parameters module
- launch_ros.utilities.lifecycle_event_manager module
- launch_ros.utilities.namespace_utils module
- launch_ros.utilities.normalize_parameters module
- launch_ros.utilities.normalize_remap_rule module
- launch_ros.utilities.plugin_support module
- launch_ros.utilities.to_parameters_list module
- launch_ros.utilities.track_node_names module
Module contents
Module for descriptions of launchable entities.
Descriptions are not executable and are immutable so they can be reused by launch entities.
- class launch_ros.utilities.LifecycleEventManager(lifecycle_node)
Bases:
object
- property node_name
- setup_lifecycle_manager(context: launch.LaunchContext) None
- launch_ros.utilities.add_node_name(context: launch.launch_context.LaunchContext, node_name: str) None
Add a node name to the context, indicating an occurrence of the node name.
- Parameters:
context – the context that keeps track of the node names
node_name – the node name to keep track
- launch_ros.utilities.evaluate_parameters(context: launch.launch_context.LaunchContext, parameters: Sequence[ParameterFile | Dict[Sequence[launch.substitution.Substitution], Sequence[launch.substitution.Substitution] | Sequence[Sequence[launch.substitution.Substitution]] | str | int | float | bool | Sequence[str] | Sequence[int] | Sequence[float] | Sequence[bool] | bytes | ParameterValue] | Parameter]) Sequence[Path | Parameter | Dict[str, str | int | float | bool | Sequence[str] | Sequence[int] | Sequence[float] | Sequence[bool] | bytes]]
Evaluate substitutions to produce paths and name/value pairs.
The parameters must have been normalized with normalize_parameters() prior to calling this. Substitutions for parameter values in dictionaries will be evaluated according to yaml rules. If you want the substitution to stay a string, the output of the substition must have quotes.
- Parameters:
parameters – normalized parameters
- Returns:
values after evaluating lists of substitutions
- launch_ros.utilities.get_node_name_count(context: launch.launch_context.LaunchContext, node_name: str) int
Get the number of times the node name has occurred, according to the context.
- Parameters:
context – the context that keeps track of the node names
node_name – the node name to keep track
- Returns:
number of times the node name has occurred
- launch_ros.utilities.is_namespace_absolute(ns: str) bool
Return True if ns is absolute.
- launch_ros.utilities.is_root_namespace(ns: str) bool
Return True if ns is ‘/’.
- launch_ros.utilities.make_namespace_absolute(ns: OptionalText) OptionalText
Make a relative namespace absolute.
- launch_ros.utilities.normalize_parameters(parameters: Sequence[launch.some_substitutions_type.SomeSubstitutionsType | Path | ParameterFile | Parameter | Mapping[Sequence[launch.substitution.Substitution | str], ParameterValue | launch.some_substitutions_type.SomeSubstitutionsType | Sequence[launch.some_substitutions_type.SomeSubstitutionsType] | str | int | float | bool | Sequence[str] | Sequence[int] | Sequence[float] | Sequence[bool] | bytes | Mapping[Sequence[launch.substitution.Substitution | str], Any]]]) Sequence[ParameterFile | Dict[Sequence[launch.substitution.Substitution], Sequence[launch.substitution.Substitution] | Sequence[Sequence[launch.substitution.Substitution]] | str | int | float | bool | Sequence[str] | Sequence[int] | Sequence[float] | Sequence[bool] | bytes | ParameterValue] | Parameter]
Normalize the types used to store parameters to substitution types.
The passed parameters must be an iterable where each element is a path to a yaml file or a dict. The normalized parameters will have all paths converted to a list of
Substitution
, and dictionaries normalized usingnormalize_parameter_dict()
.
- launch_ros.utilities.normalize_remap_rule(remap_rule: Tuple[launch.some_substitutions_type.SomeSubstitutionsType, launch.some_substitutions_type.SomeSubstitutionsType]) Tuple[Tuple[launch.substitution.Substitution, ...], Tuple[launch.substitution.Substitution, ...]]
Normalize a remap rule to a specific type.
- launch_ros.utilities.normalize_remap_rules(remap_rules: Iterable[Tuple[launch.some_substitutions_type.SomeSubstitutionsType, launch.some_substitutions_type.SomeSubstitutionsType]]) Iterable[Tuple[Tuple[launch.substitution.Substitution, ...], Tuple[launch.substitution.Substitution, ...]]]
Normalize multiple remap rules.
- launch_ros.utilities.prefix_namespace(base_ns: str | None, ns: str | None) str | None
Return ns prefixed with base_ns if ns is relative, return ns if not.
- Parameters:
base_ns – Prefix to be added to ns.
ns – Namespace to be prefixed.
- Returns:
None if both base_ns and ns are None, or base_ns if ns is None, or ns if base_ns is None, or ns if ns is absolute, or ns prefixed with base_ns. In all cases, trailing / are stripped from the result.
## Examples:
```python3 combined_ns = prefix_namespace(‘my_ns’, ‘original_ns’) assert combined_ns == ‘my_ns/original_ns’
combined_ns = prefix_namespace(‘/my_ns’, ‘original_ns’) assert combined_ns == ‘/my_ns/original_ns’
combined_ns = prefix_namespace(‘my_ns’, ‘/original_ns’) assert combined_ns == ‘/original_ns’
combined_ns = prefix_namespace(None, ‘original_ns’) assert combined_ns == ‘original_ns’
combined_ns = prefix_namespace(‘my_ns’, None) assert combined_ns == ‘my_ns’ ```
- launch_ros.utilities.to_parameters_list(context: launch.launch_context.LaunchContext, node_name: str, namespace: str, evaluated_parameters: Sequence[Path | Parameter | Dict[str, str | int | float | bool | Sequence[str] | Sequence[int] | Sequence[float] | Sequence[bool] | bytes]]) List[rclpy.parameter.Parameter]
Transform evaluated parameters into a list of rclpy.parameter.Parameter objects.
- Parameters:
context – to carry out substitutions during normalization of parameter files. See normalize_parameters() documentation for further reference.
node_name – node name
namespace – node namespace
parameters – parameters as either paths to parameter files or name/value pairs. See evaluate_parameters() documentation for further reference.
- Returns:
a list of parameters