rclpy.parameter module
- class rclpy.parameter.Parameter(name, type_=None, value=None)
Bases:
object
- class Type(value)
Bases:
Enum
An enumeration.
- check(parameter_value)
- classmethod from_parameter_value(parameter_value)
Get a Parameter.Type from a given variable.
- Returns:
A Parameter.Type corresponding to the instance type of the given value.
- Raises:
TypeError if the conversion to a type was not possible.
- classmethod from_parameter_msg(param_msg)
- get_parameter_value()
- property name
- to_parameter_msg()
- property type_
- property value
- rclpy.parameter.get_parameter_value(string_value: str) rcl_interfaces.msg.ParameterValue
Guess the desired type of the parameter based on the string value.
- Parameters:
string_value – The string value to be converted to a ParameterValue.
- Returns:
The ParameterValue.
- rclpy.parameter.parameter_dict_from_yaml_file(parameter_file: str, use_wildcard: bool = False, target_nodes: List[str] | None = None, namespace: str = '') Dict[str, rcl_interfaces.msg.Parameter]
Build a dict of parameters from a YAML file.
Will load all parameters if
target_nodes
is None or empty.- Raises:
RuntimeError – if a target node is not in the file
RuntimeError – if the is not a valid ROS parameter file
- Parameters:
parameter_file – Path to the YAML file to load parameters from.
use_wildcard – Use wildcard matching for the target nodes.
target_nodes – List of nodes in the YAML file to load parameters from.
namespace – Namespace to prepend to all parameters.
- Returns:
A dict of Parameter messages keyed by the parameter names
- rclpy.parameter.parameter_value_to_python(parameter_value: rcl_interfaces.msg.ParameterValue)
Get the value for the Python builtin type from a rcl_interfaces/msg/ParameterValue object.
Returns the value member of the message based on the
type
member. ReturnsNone
if the parameter is “NOT_SET”.- Parameters:
parameter_value – The message to get the value from.
- Raises:
RuntimeError – if the member
type
has an unexpected value.