module documentation

A published topic is a Skill: a client writes the fields, then starts the publishing.

The message fields are the Skill's Parameters, writable in any state, and nothing goes out while they are written. Start reads them, builds the message and publishes it: the first tick of a stream on a continuous Skill, the only publish on a finite one. Halt closes a stream. Reset clears the failure count and leaves the Parameters alone. There is no Suspend (opensmi keeps running the handler through SUSPENDING, so a paused stream would go on publishing) and no Monitoring sibling: the echo of a topic we publish is our own message, so a readback would only confirm the last value published. A consumer who wants to see the topic declares a MonitoringBinding on it. There is no FinalResultData either (it is optional in the SkillSet model), since a publish has no result.

The trigger is the tick alone: there is no debounce, coalescing or dirty tracking. A finite push has one publish, so any failure halts. A stream absorbs tolerated_failures consecutive ones, and every failure fires a BindingEvent whether it was absorbed or not.

opensmi leaves a continuous Skill in Running when its handler returns, so the rate loop never returns: every exit raises an OpenSmiRuntimeError, which halts the Skill and reaches the Component's Notification with its code. A stream exits when its tolerance for failed publishes is spent, when the Lock it was started under ends (LOCK_ENDED), and when a declared stale_after passes without a write (SETPOINT_STALE), each with a BindingEvent of the same code. Halt cancels the handler instead.

Access is a Skill's like any other: Start, Halt and Reset need the Skill level (skill_access_level) and the Machine's Lock, and Start also needs a completed startup. The ParameterSet is built in opensmi.ros2.server.containers; the header stamp and the send-time value guard are in opensmi.ros2.runtime.publisher.

Class ROS2ContinuousPublisherSkill The stream: one publish per tick of the rate Parameter, until Halt or nobody is in charge.
Class ROS2FinitePublisherSkill The one-shot push: publish once on Start, then reach Completed.
Class ROS2PublisherSkill What both publishing Skills share, everything except the tick.
Function binding_event_emitter Return the BindingEvent emitter of the machinery item that declared a Binding.
Function default_message_from Build the message to publish out of what a client wrote into a Skill's Parameters.
Function halt_message_from Build the message a stream publishes once when it ends, or None when none is declared.
Constant LOCK_ENDED The BindingEvent Code and ErrorCode of a stream halted because the Lock it was started under ended: released, broken, expired, or lost with the holder's session.
Constant MAXIMUM_RATE The fastest publish rate, in hertz: the 1 ms period is the floor asyncio.sleep can keep.
Constant MESSAGE_UNBUILDABLE The ErrorCode of a tick whose Parameters could not be built into a message.
Constant MINIMUM_RATE The slowest publish rate a declaration or a client may set, in hertz (one tick every 16 minutes).
Constant PUBLISH_FAILED The BindingEvent Code of every failed publish, and the ErrorCode of the error that halts the Skill once its tolerance is spent. A TF Binding's failed broadcast reports under it too.
Constant PUBLISH_FAULTS The faults that mean this tick did not reach the topic: the middleware refused the message, or the guard refused a field value. Any other Runtime error (a released publisher, a stopped Runtime) cannot be mended by another tick and is not tolerated.
Constant RATE_PARAMETER The browse name of the one Parameter of a continuous publishing Skill that is not a message field.
Constant SETPOINT_STALE The BindingEvent Code and ErrorCode of a stream halted because no client wrote any of its Parameters within the Binding's stale_after.
Exception _HaltMessageRefusedError A halt message table that does not fit its message type, with the field path at fault.
Function _element_value Return one scalar or one element of a list, a nested element built from its own default.
Function _field_value Return what one field of a halt message holds, given what the table says for it.
Function _overlaid Return a message with the fields a table names set to its values, the rest left as they are.
Function _require_the_rate_name_is_free Refuse a continuous declaration whose message already claims the rate Parameter's name.
Constant _FLOATING Undocumented
def binding_event_emitter(machinery_item: object, message: str) -> Callable[..., Awaitable[None]]:

Return the BindingEvent emitter of the machinery item that declared a Binding.

Resolved at init so that a missing reporting surface is not first noticed by a report going nowhere. A Binding is only built by a Component that mixes ours in, so this is unreachable through the declarative API.

Parameters
machinery_item:objectUndocumented
message:strThe error text for a machinery item that cannot raise one.
Returns
Callable[..., Awaitable[None]]Undocumented
Raises
DeclarationErrorWhen the machinery item has no BindingEvent emitter.
def default_message_from(message_type: type[Message], values: Mapping[str, object], context: ProjectionContext) -> Message:

Build the message to publish out of what a client wrote into a Skill's Parameters.

This runs the Projection of the message type backwards, as an action's goal and a service's request do. It is a pure function (no server, no rclpy, no event loop). Values the message has no field for, such as the reserved rate, are ignored.

Raises
NotInvertibleErrorWhen a field of the message has no value, because the selection removed it or no Parameter carries it. A default is never invented.
def halt_message_from(binding: PublisherBinding, message_type: type[Message], runtime: RuntimeInterface) -> Message | None:

Build the message a stream publishes once when it ends, or None when none is declared.

It starts from the message as the type's generated class constructs it, so a field the table does not name keeps that class's default, and sets the named fields. A number goes into a floating-point field as a float, so z = -1 in a file is -1.0. The result passes the same send-time guard as every message the Skill publishes, so a value the field cannot hold fails here, at init, and not on the robot.

Raises
DeclarationErrorWhen the table names a field the message type does not have, gives a table where a value belongs or the reverse, or holds a value its field cannot carry.
LOCK_ENDED: str =

The BindingEvent Code and ErrorCode of a stream halted because the Lock it was started under ended: released, broken, expired, or lost with the holder's session.

Value
'LOCK_ENDED'
MAXIMUM_RATE: float =

The fastest publish rate, in hertz: the 1 ms period is the floor asyncio.sleep can keep.

Value
1000.0
MESSAGE_UNBUILDABLE: str =

The ErrorCode of a tick whose Parameters could not be built into a message.

It halts the Skill and nothing is published; the error message names the field and the reason.

Value
'MessageUnbuildable'
MINIMUM_RATE: float =

The slowest publish rate a declaration or a client may set, in hertz (one tick every 16 minutes).

The bound is published as an EURange on the Parameter, so a write of zero is refused before a period is divided by it.

Value
0.001
PUBLISH_FAILED: str =

The BindingEvent Code of every failed publish, and the ErrorCode of the error that halts the Skill once its tolerance is spent. A TF Binding's failed broadcast reports under it too.

Value
'PUBLISH_FAILED'
PUBLISH_FAULTS =

The faults that mean this tick did not reach the topic: the middleware refused the message, or the guard refused a field value. Any other Runtime error (a released publisher, a stopped Runtime) cannot be mended by another tick and is not tolerated.

Value
(PublishFailedError, FieldValueError)
RATE_PARAMETER: str =

The browse name of the one Parameter of a continuous publishing Skill that is not a message field.

It is reserved: a message with a field that converts to it (rate) is refused at init. Its DisplayName is rate.

Value
'Rate'
SETPOINT_STALE: str =

The BindingEvent Code and ErrorCode of a stream halted because no client wrote any of its Parameters within the Binding's stale_after.

Value
'SETPOINT_STALE'
def _element_value(element: ElementType, nested: type[Message] | None, value: object, runtime: RuntimeInterface, path: str) -> object:

Return one scalar or one element of a list, a nested element built from its own default.

def _field_value(field_type: FieldType, nested: type[Message] | None, current: object, value: object, runtime: RuntimeInterface, path: str) -> object:

Return what one field of a halt message holds, given what the table says for it.

def _overlaid(default: Message, table: Mapping[str, object], runtime: RuntimeInterface, where: str) -> Message:

Return a message with the fields a table names set to its values, the rest left as they are.

def _require_the_rate_name_is_free(plan: tuple[PlanEntry, ...], message_type: type[Message], binding: PublisherBinding):

Refuse a continuous declaration whose message already claims the rate Parameter's name.

Checked against the plan, not the message's fields, because a curated Projection chooses its own names and those are what collide. A finite Skill has no rate node, so it is not checked.

Raises
DeclarationErrorWhen the plan has a top-level entry called rate.
_FLOATING =

Undocumented

Value
frozenset(set(['float32', 'float64']))