launch_ros.utilities.normalize_parameters module

Module with utility for normalizing parameters to a node.

launch_ros.utilities.normalize_parameters.normalize_parameter_dict(parameters: 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]], *, _prefix: Sequence[launch.substitution.Substitution] | None = None) 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]

Normalize types used to store parameters in a dictionary.

The parameters are passed as a dictionary that specifies parameter rules. Keys of the dictionary can be strings, a Substitution, or an iterable of Substitution. A normalized key will be a tuple of substitutions. Values in the dictionary can be strings, integers, floats, substitutions, lists of the previous types, or another dictionary with the same properties.

Normalized values that were lists will have all subvalues converted to the same type. If all subvalues are int or float, then the normalized subvalues will all be float. If the subvalues otherwise do not all have the same type, then the normalized subvalues will be lists of Substitution that will result in a list of strings.

Values that are a list of strings will become a list of strings when normalized and evaluated. Values that are a list which has at least one Substitution and all other elements are either strings or a list of substitutions will become a single list of substitutions that will evaluate to a single string. To make a list of strings from substitutions, each item in the list must be a list or tuple.

Normalized values that contained nested dictionaries will be collapsed into a single layer with parameter names concatenated with the parameter namespace separator “.”.

Parameters:
  • parameters – Parameters to be normalized

  • _prefix – internal parameter used for flatening recursive dictionaries

Returns:

Normalized parameters

launch_ros.utilities.normalize_parameters.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 using normalize_parameter_dict().