synchros2.launch.values module

Provides a helper class for accessing the values of launch arguments from a LaunchConfiguration

Copyright (c) 2024 Robotics and AI Institute LLC dba RAI Institute. All rights reserved.

class synchros2.launch.values.LaunchConfigurationValues[source]

Bases: object

Helper class for accessing the values of launch arguments from a LaunchConfiguration.

This helper serves the following purposes:
  1. Avoid spending a line of code on each of a potentially large number of values retrieved from the launch config

  2. Enable easily accessing the values of boolean arguments as actual bool types when needed, while still normally treating them as str the way downstream launch operations usually expect.

Example

>>> def launch_setup(context: LaunchContext):
...     launch_elements = []
...     vals = LaunchConfigurationValues(context)
...     vals["robot_name"]  # str
...     vals.bool("use_afterburner")  # bool
...     # The "condition" kwarg expects a launch operation on a string-type boolean, not an actual bool
...     launch_elements.append(
...         Node(
...             # ...
...             # Argument is in ["true", "false"], not [True, False]
...             condition=IfCondition(vals["use_afterburner"]),
...         ),
...     )
...     if vals.bool("use_afterburner"):  # Access value as one of [True, False]
...         # Add an additional launch element
...     # ...
__init__(context: launch.LaunchContext)[source]

Initialize a LaunchConfigurationValues helper for a given launch context

Parameters:

context – The LaunchContext being used in the launch_setup function where this helper class is needed.

bool(launch_arg_name: str) bool[source]

Retrieve the boolean value of the specified launch argument.

This method should fail if the argument’s string value is not one of the expected options for a boolean.