class ROS2ContinuousPublisherSkill(ROS2PublisherSkill, ContinuousSkillLogicMixin, BaseSkill):
Constructor: ROS2ContinuousPublisherSkill(**kwargs)
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 |
Create the rate Parameter, and check a declared stale_after. |
| Async Method | _handle |
Publish the declared halt message once, when a stream that ran comes to an end. |
| Async Method | _handle |
Publish the current snapshot on every tick, until something ends the stream. |
| Async Method | _locking |
Return the NodeId of the Lock's LockingUser variable, looked up once. |
| Async Method | _newest |
Return when any Parameter was last written (its ServerTimestamp), or None. |
| Async Method | _on |
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 |
Halt the stream when no Parameter has been written for stale_after seconds. |
| Async Method | _require |
Halt the stream when the Lock it was started under has ended. |
| Method | _require |
Refuse a declared stale_after on a server that does not stamp the writes it takes. |
| Async Method | _tied |
Tie the stream to whoever holds the Machine's Lock now, for as long as the block runs. |
| Async Method | _until |
Wait one period, and halt on the way if the Lock ends or the setpoint goes stale. |
| Instance Variable | _fresh |
Undocumented |
| Instance Variable | _halt |
Undocumented |
| Instance Variable | _holder |
Undocumented |
| Instance Variable | _lock |
Undocumented |
| Instance Variable | _locking |
Undocumented |
| Instance Variable | _rate |
Undocumented |
| Instance Variable | _streaming |
Undocumented |
Inherited from ROS2PublisherSkill:
| Async Method | build |
Return the message to publish, given what a client wrote into the Parameters. |
| Async Method | close |
Release this Skill's ROS2 publisher. Idempotent. |
| Async Method | read |
Return what the ParameterSet holds now, by variable name. |
| Class Variable | callable |
Undocumented |
| Property | binding |
Return the declaration this Skill was built from. |
| Property | consecutive |
Return how many publishes in a row have failed, as the tolerance counts them. |
| Property | message |
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 |
Return what this Skill's publisher offers and where that came from, or None. |
| Async Method | _handle |
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 |
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 |
Undocumented |
| Instance Variable | _parameters |
Undocumented |
| Instance Variable | _plan |
Undocumented |
| Instance Variable | _publisher |
Undocumented |
| Instance Variable | _runtime |
Undocumented |
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.
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.
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.
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.
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 | |
OpenSmiRuntimeError | When the Parameter holds a rate outside its published bounds. |
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 | |
float | The seconds left before the setpoint goes stale, infinite without stale_after. |
| Raises | |
OpenSmiRuntimeError | When the setpoint is stale. |
Halt the stream when the Lock it was started under has ended.
| Raises | |
OpenSmiRuntimeError | When the Lock was released, broken, expired or lost with its session. |
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 | |
DeclarationError | When the server does not record write times. |
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.