module documentation

The parameter facet: a ROS2 node's parameters, read one at a time and written non-atomically.

A ROS2 parameter is a named, typed configuration value on a ROS2 node, read and written over the node's parameter services and observable on /parameter_events. Three behaviours of the library (verified on Jazzy) shape this module:

  • A read takes one name. get_parameters and describe_parameters answer with an empty list and no error when any one name is undeclared, so a batched read would blank every value on one typo.
  • A write is never atomic. set_parameters reports per parameter, while the atomic variant discards the whole batch when one name is undeclared. The atomic call is not wrapped.
  • One subscription to /parameter_events serves all watches and demultiplexes by node. It is open only while a watch exists. The topic also fires for changes a node makes to itself, and these are passed on.

ParameterType has the nine declarable members of rcl_interfaces/msg/ParameterType. A value crossing this module is a ParameterValue: one of those types and a plain Python value. The facet reads and writes through callables the Runtime supplies, so nothing here imports rclpy.

Class ParameterDescription What a ROS2 node says about one of its parameters, beyond the value it holds.
Class ParameterFacet The ROS2 parameters of every node on one Machine's graph.
Class ParameterRange The range a ROS2 node declares for one numeric parameter, inclusive at both ends.
Class ParameterReading What one look at one ROS2 parameter found: not present, present without a value, or a value.
Class ParameterType The declarable members of rcl_interfaces/msg/ParameterType.
Class ParameterUpdate What one /parameter_events message says about one node.
Class ParameterValue One ROS2 parameter value, as the declaration typed it.
Class ParameterWatch One consumer's view of one ROS2 node's parameter changes, and its lifetime.
Class SetOutcome What a ROS2 node answered about one parameter of a write.
Function absolute Return a ROS2 node path with the leading / that /parameter_events uses.
Function describe_request Return the DescribeParameters request asking about exactly one name.
Function description_of Return what a DescribeParameters response says about the one name it was asked for.
Function get_request Return the GetParameters request for exactly one name.
Function list_request Return the ListParameters request for every name (no prefixes, depth zero is DEPTH_RECURSIVE).
Function names_of Return the parameter names a ListParameters response carries, in the node's own order.
Function outcomes_of Return what a SetParameters response says, per parameter, paired back with its name.
Function reading_of Return what a GetParameters response says about the one name it was asked for.
Function set_request Return the SetParameters request writing a batch, in the order it was given.
Function update_of Return one /parameter_events message as an update.
Constant CALL_TIMEOUT Seconds to wait for the answer once a parameter request has gone.
Constant DESCRIBE_PARAMETERS_TYPE The service type behind <node>/describe_parameters, asked one name at a time.
Constant EVENT_DEPTH How many parameter events one subscription and one watch buffer.
Constant GET_PARAMETERS_TYPE The service type behind <node>/get_parameters.
Constant LIST_PARAMETERS_TYPE The service type behind <node>/list_parameters, which answers what a node declares.
Constant PARAMETER_EVENT_TYPE The type carried on PARAMETER_EVENTS_TOPIC.
Constant PARAMETER_EVENTS_TOPIC The one topic every ROS2 node announces its parameter changes on.
Constant SERVER_TIMEOUT Seconds a parameter call waits for the node's service to appear.
Constant SET_PARAMETERS_TYPE The service type behind <node>/set_parameters, which reports per parameter.
Type Alias DescribeFunction How the facet describes: the node path and one name.
Type Alias EventFunction How the facet follows /parameter_events: one generator, closed with the last watch.
Type Alias ListFunction How the facet lists: the node path, and every parameter name that node declares.
Type Alias ReadFunction How the facet reads one parameter: the node path and one name.
Type Alias WriteFunction How the facet writes: the node path and a batch, answered per parameter.
Function _built Build one message dataclass from its field names (they are only known at run time).
Function _field Return one field of a message dataclass by name (its fields are not statically known).
Function _range_of Return the one range a ParameterDescriptor declares, or None.
Function _raw_value Return one typed value as the rcl_interfaces/msg/ParameterValue that carries it.
Function _value_of Return one rcl_interfaces/msg/ParameterValue as a typed value, or None when unset.
Constant _BY_CODE Undocumented
Constant _CODES The constants of rcl_interfaces/msg/ParameterType, written out so member order cannot renumber them.
Constant _EMPTY_VALUE Every field of rcl_interfaces/msg/ParameterValue at its zero.
Constant _FIELD_TYPES What each declarable parameter type is, in the package's field-type model.
Constant _LOGGER Undocumented
def absolute(node: str) -> str:

Return a ROS2 node path with the leading / that /parameter_events uses.

A path without the slash would match no event.

def describe_request(request_type: type[Message], name: str) -> Message:

Return the DescribeParameters request asking about exactly one name.

def description_of(name: str, response: Message) -> ParameterDescription:

Return what a DescribeParameters response says about the one name it was asked for.

An empty list means the node has no such parameter, as for a read.

def get_request(request_type: type[Message], name: str) -> Message:

Return the GetParameters request for exactly one name.

def list_request(request_type: type[Message]) -> Message:

Return the ListParameters request for every name (no prefixes, depth zero is DEPTH_RECURSIVE).

def names_of(response: Message) -> tuple[str, ...]:

Return the parameter names a ListParameters response carries, in the node's own order.

def outcomes_of(names: Iterable[str], response: Message) -> Mapping[str, SetOutcome]:

Return what a SetParameters response says, per parameter, paired back with its name.

Names missing from a short answer are marked unsuccessful and unanswered, with no reason text, because SetOutcome.reason must only ever hold the node's own words.

def reading_of(name: str, response: Message) -> ParameterReading:

Return what a GetParameters response says about the one name it was asked for.

An empty list means the node has no such parameter (and arrives without an error).

def set_request(request_type: type[Message], values: Mapping[str, ParameterValue]) -> Message:

Return the SetParameters request writing a batch, in the order it was given.

The order matters: results come back positionally and outcomes_of pairs them by it.

def update_of(message: Message) -> ParameterUpdate:

Return one /parameter_events message as an update.

New and changed parameters, then deleted ones as readings that are not present.

CALL_TIMEOUT: float =

Seconds to wait for the answer once a parameter request has gone.

Value
30.0
DESCRIBE_PARAMETERS_TYPE: str =

The service type behind <node>/describe_parameters, asked one name at a time.

Value
'rcl_interfaces/srv/DescribeParameters'
EVENT_DEPTH: int =

How many parameter events one subscription and one watch buffer.

Deeper than a Monitoring Binding's because the buffer is shared by every node on the graph, and a dropped event leaves a UA Parameter holding a value the node no longer has.

Value
100
GET_PARAMETERS_TYPE: str =

The service type behind <node>/get_parameters.

Value
'rcl_interfaces/srv/GetParameters'
LIST_PARAMETERS_TYPE: str =

The service type behind <node>/list_parameters, which answers what a node declares.

Value
'rcl_interfaces/srv/ListParameters'
PARAMETER_EVENT_TYPE: str =

The type carried on PARAMETER_EVENTS_TOPIC.

Value
'rcl_interfaces/msg/ParameterEvent'
PARAMETER_EVENTS_TOPIC: str =

The one topic every ROS2 node announces its parameter changes on.

Value
'/parameter_events'
SERVER_TIMEOUT: float =

Seconds a parameter call waits for the node's service to appear.

ROS2 supplies no deadline: a parameter-service call to a node that is not running produces no error and no result.

Value
10.0
SET_PARAMETERS_TYPE: str =

The service type behind <node>/set_parameters, which reports per parameter.

Value
'rcl_interfaces/srv/SetParameters'
DescribeFunction: TypeAlias =

How the facet describes: the node path and one name.

Value
Callable[[str, str], Awaitable[ParameterDescription]]
EventFunction: TypeAlias =

How the facet follows /parameter_events: one generator, closed with the last watch.

Value
Callable[[], AsyncGenerator[ParameterUpdate, None]]
ListFunction: TypeAlias =

How the facet lists: the node path, and every parameter name that node declares.

Value
Callable[[str], Awaitable[tuple[str, ...]]]
ReadFunction: TypeAlias =

How the facet reads one parameter: the node path and one name.

Value
Callable[[str, str], Awaitable[ParameterReading]]
WriteFunction: TypeAlias =

How the facet writes: the node path and a batch, answered per parameter.

Value
Callable[[str, Mapping[str, ParameterValue]],
         Awaitable[Mapping[str, SetOutcome]]]
def _built(message_type: type[Message], **fields: object) -> Message:

Build one message dataclass from its field names (they are only known at run time).

def _field(message: Message, name: str) -> Any:

Return one field of a message dataclass by name (its fields are not statically known).

def _range_of(descriptor: Message) -> ParameterRange | None:

Return the one range a ParameterDescriptor declares, or None.

At most one of the two range fields is filled, with at most one element.

def _raw_value(value_type: type[Message], value: ParameterValue) -> Message:

Return one typed value as the rcl_interfaces/msg/ParameterValue that carries it.

def _value_of(raw: Message) -> ParameterValue | None:

Return one rcl_interfaces/msg/ParameterValue as a typed value, or None when unset.

A code with no member here also gives None, so a wrong value is never shown.

_BY_CODE: Mapping[int, ParameterType] =

Undocumented

Value
{code: each for each, code in _CODES.items()}
_CODES: Mapping[ParameterType, int] =

The constants of rcl_interfaces/msg/ParameterType, written out so member order cannot renumber them.

Value
{ParameterType.BOOL: 1,
 ParameterType.INTEGER: 2,
 ParameterType.DOUBLE: 3,
 ParameterType.STRING: 4,
 ParameterType.BYTE_ARRAY: 5,
 ParameterType.BOOL_ARRAY: 6,
 ParameterType.INTEGER_ARRAY: 7,
...
_EMPTY_VALUE: Mapping[str, object] =

Every field of rcl_interfaces/msg/ParameterValue at its zero.

Message dataclasses have no defaults, so a value is built with all ten fields and the relevant one overwritten. A field added upstream raises a missing-argument TypeError here.

Value
{'type': 0,
 'bool_value': False,
 'integer_value': 0,
 'double_value': 0.0,
 'string_value': '',
 'byte_array_value': b'',
 'bool_array_value': (),
...
_FIELD_TYPES: Mapping[ParameterType, FieldType] =

What each declarable parameter type is, in the package's field-type model.

Value
{ParameterType.BOOL: PrimitiveType(name='bool'),
 ParameterType.INTEGER: PrimitiveType(name='int64'),
 ParameterType.DOUBLE: PrimitiveType(name='float64'),
 ParameterType.STRING: StringType(),
 ParameterType.BYTE_ARRAY: SequenceType(element=PrimitiveType(name='uint8')),
 ParameterType.BOOL_ARRAY: SequenceType(element=PrimitiveType(name='bool')),
 ParameterType.INTEGER_ARRAY: SequenceType(element=PrimitiveType(name='int64')),
...
_LOGGER =

Undocumented

Value
structlog.get_logger('opensmi.ros2.runtime.parameters')