class documentation

class ROS2ContinuousPublisherSkill(ROS2PublisherSkill, ContinuousSkillLogicMixin, BaseSkill):

Constructor: ROS2ContinuousPublisherSkill(**kwargs)

View In Hierarchy

The stream: one publish per tick of the rate Parameter, until Halt or nobody is in charge.

opensmi has no periodic hook on a running Skill, so this one owns a wait loop that the halting transition cancels. Two things end it besides Halt and a failed publish: the Lock it was started under ends (LOCK_ENDED), and a declared stale_after passes without a write to any Parameter (SETPOINT_STALE). Both are checked before every publish, and the wait between ticks wakes for either, so a halt does not wait for the next tick. A stream whose Binding declares a halt_message publishes it once as it ends, whatever ended it; without one it just stops. The robot's own command timeout stays what brings it to rest.

Method __init__ Build the Skill, and start out with nothing known about the client's writing.
Async Method _create_own_parameters Create the rate Parameter, and check a declared stale_after.
Async Method _handle_halting Publish the declared halt message once, when a stream that ran comes to an end.
Async Method _handle_running Publish the current snapshot on every tick, until something ends the stream.
Async Method _locking_user Return the NodeId of the Lock's LockingUser variable, looked up once.
Async Method _newest_write Return when any Parameter was last written (its ServerTimestamp), or None.
Async Method _on_lock_written Note that the Lock ended when its holder is no longer the one the stream started under.
Async Method _period Return how long until the next tick, read off the rate Parameter on every one.
Async Method _require_a_fresh_setpoint Halt the stream when no Parameter has been written for stale_after seconds.
Async Method _require_the_lock_holds Halt the stream when the Lock it was started under has ended.
Method _require_write_times_are_recorded Refuse a declared stale_after on a server that does not stamp the writes it takes.
Async Method _tied_to_the_lock Tie the stream to whoever holds the Machine's Lock now, for as long as the block runs.
Async Method _until_the_next_tick Wait one period, and halt on the way if the Lock ends or the setpoint goes stale.
Instance Variable _fresh_since Undocumented
Instance Variable _halt_message Undocumented
Instance Variable _holder Undocumented
Instance Variable _lock_ended Undocumented
Instance Variable _locking_user_node Undocumented
Instance Variable _rate Undocumented
Instance Variable _streaming Undocumented

Inherited from ROS2PublisherSkill:

Async Method build_message Return the message to publish, given what a client wrote into the Parameters.
Async Method close_publisher Release this Skill's ROS2 publisher. Idempotent.
Async Method read_parameters Return what the ParameterSet holds now, by variable name.
Class Variable callable_kind Undocumented
Property binding Return the declaration this Skill was built from.
Property consecutive_failures Return how many publishes in a row have failed, as the tolerance counts them.
Property message_type Return the message dataclass this Skill publishes.
Property publisher Return the ROS2 publisher this Skill owns, or None before init and after shutdown.
Property ros2_qos_provenance Return what this Skill's publisher offers and where that came from, or None.
Async Method _handle_resetting Clear the failure count. The ParameterSet stays, so nothing a client wrote is lost.
Async Method _init Let opensmi build the Skill, create the ParameterSet variables, and prove them.
Async Method _note_a_failure Count one failed publish, report it, and halt when the tolerance is spent.
Async Method _publish Publish one snapshot of the Parameters, and let the continuity decide what a failure is.
Async Method _report Fire one BindingEvent about this Binding, and never let the reporting be the fault.
Instance Variable _binding Undocumented
Instance Variable _context Undocumented
Instance Variable _emit Undocumented
Instance Variable _failures Undocumented
Instance Variable _message_type Undocumented
Instance Variable _parameters Undocumented
Instance Variable _plan Undocumented
Instance Variable _publisher Undocumented
Instance Variable _runtime Undocumented
def __init__(self, **kwargs: Any):

Build the Skill, and start out with nothing known about the client's writing.

async def _create_own_parameters(self):

Create the rate Parameter, and check a declared stale_after.

The rate is bounded by an EURange, which opensmi's write path enforces, so a client cannot write a period of zero.

async def _handle_halting(self):

Publish the declared halt message once, when a stream that ran comes to an end.

opensmi halts through here whatever ended the stream: Halt, the end of the Lock, a stale setpoint or a spent tolerance. The rate loop has been cancelled or has raised by now, so the halt message is the last one. A halt message that cannot be published is reported and does not hold the halt up.

async def _handle_running(self):

Publish the current snapshot on every tick, until something ends the stream.

Publishes first and waits afterwards, so Start sends at once; Start also counts as a fresh setpoint. This never returns; every exit raises.

async def _locking_user(self) -> ua.NodeId:

Return the NodeId of the Lock's LockingUser variable, looked up once.

async def _newest_write(self) -> datetime | None:

Return when any Parameter was last written (its ServerTimestamp), or None.

async def _on_lock_written(self, *_change: object):

Note that the Lock ended when its holder is no longer the one the stream started under.

It runs inside the Lock's own update, so it only sets a flag; the running loop halts.

async def _period(self) -> float:

Return how long until the next tick, read off the rate Parameter on every one.

Reading it per tick makes a rate change effective on the next tick. The range check is not a second enforcement of the EURange: it only refuses to divide by a number no client write could have produced, such as one written by a consumer's own code.

Raises
OpenSmiRuntimeErrorWhen the Parameter holds a rate outside its published bounds.
async def _require_a_fresh_setpoint(self) -> float:

Halt the stream when no Parameter has been written for stale_after seconds.

Without this, a stream whose client died keeps republishing the last values (on /cmd_vel, a robot driving on a command nobody sends) for as long as the client's session and Lock outlive it. It compares when each Parameter was last written, not what it holds: a client steering straight ahead writes the same numbers every time. Every Parameter counts, rate included. The write times are wall-clock ServerTimestamp values, so a clock stepped forward can halt a stream early, which is the safe side.

Returns
floatThe seconds left before the setpoint goes stale, infinite without stale_after.
Raises
OpenSmiRuntimeErrorWhen the setpoint is stale.
async def _require_the_lock_holds(self):

Halt the stream when the Lock it was started under has ended.

Raises
OpenSmiRuntimeErrorWhen the Lock was released, broken, expired or lost with its session.
def _require_write_times_are_recorded(self):

Refuse a declared stale_after on a server that does not stamp the writes it takes.

The check reads asyncua's ServerTimestamp, which an application may turn off. Without it every stream would halt after stale_after while its client writes.

Raises
DeclarationErrorWhen the server does not record write times.
@contextlib.asynccontextmanager
async def _tied_to_the_lock(self) -> AsyncIterator[None]:

Tie the stream to whoever holds the Machine's Lock now, for as long as the block runs.

A client needs the Lock to call Start, so its holder is the one in charge of the stream. A Skill started through the server's own interface while nobody holds the Lock is tied to nothing, since there is no Lock to end.

opensmi signals no change of the Lock, but every change (ExitLock, BreakLock, the inactivity timeout, a closed session) writes the Lock's LockingUser variable, so the stream watches that write in asyncua's address space, as a subscription does.

async def _until_the_next_tick(self, period: float):

Wait one period, and halt on the way if the Lock ends or the setpoint goes stale.

Raises
OpenSmiRuntimeErrorWhen either happens before the period is over.
_fresh_since =

Undocumented

_halt_message =

Undocumented

_holder: UserAuthorization | None =

Undocumented

_lock_ended =

Undocumented

_locking_user_node: ua.NodeId | None =

Undocumented

_rate: UaVariable[float] | None =

Undocumented

_streaming: bool =

Undocumented