class documentation

class ROS2PublisherSkill(ROS2ContainerMixin, ParentMixin[BaseMachineryItem], ParameterSetMixin):

Known subclasses: ros2.server.publisher.ROS2ContinuousPublisherSkill, ros2.server.publisher.ROS2FinitePublisherSkill

Constructor: ROS2PublisherSkill(binding, runtime, context, minimum_access_level)

View In Hierarchy

What both publishing Skills share, everything except the tick.

It is not a Skill on its own. The two subclasses below add opensmi's skill logic and differ only in what Running does; the declaration's continuous picks one.

Method __init__ Resolve everything about the declaration that can be wrong, before any node exists.
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 _create_own_parameters Create the Parameters that are not message fields. A finite Skill has 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, *, binding: PublisherBinding, runtime: RuntimeInterface, context: ProjectionContext, minimum_access_level: int = SKILL_ACCESS_LEVEL):

Resolve everything about the declaration that can be wrong, before any node exists.

Parameters
binding:PublisherBindingWhat to build.
runtime:RuntimeInterfaceWhere the message is published (the Machine's, reached through the Component).
context:ProjectionContextThe Projection context this Component renders through, with nothing selected yet.
minimum_access_level:intThe level Start, Halt and Reset need.
Raises
MessageTypeErrorWhen the message type cannot be resolved.
FieldSelectionErrorWhen a selection pattern matches nothing.
NotInvertibleErrorWhen the message type reaches a Projection that cannot run backwards, so no client could ever publish through it.
DeclarationErrorWhen a field of the message would claim the rate Parameter's name on a continuous Skill.
async def build_message(self, values: Mapping[str, object]) -> Message:

Return the message to publish, given what a client wrote into the Parameters.

Override this on a custom implementation class when building needs the instance (another node's value, something injected into the Component). The declaration's message_from is the pure-function form of the same hook, and default_message_from is the default.

An override must work at init, which calls it once with the declaration's defaults. On a continuous Skill the values include the reserved Rate, which is not a message field.

async def close_publisher(self):

Release this Skill's ROS2 publisher. Idempotent.

The declaring Component's shutdown calls it, for a Component torn down while the process goes on serving. Stopping the Runtime closes every publisher too.

async def read_parameters(self) -> Mapping[str, object]:

Return what the ParameterSet holds now, by variable name.

callable_kind: ClassVar[str] =

Undocumented

@property
binding: PublisherBinding =

Return the declaration this Skill was built from.

@property
consecutive_failures: int =

Return how many publishes in a row have failed, as the tolerance counts them.

@property
message_type: type[Message] =

Return the message dataclass this Skill publishes.

@property
publisher: Publisher | None =

Return the ROS2 publisher this Skill owns, or None before init and after shutdown.

It is advertised at init and held, so subscribers discover it while a client is still writing the fields and a one-shot push does not race their discovery.

@property
ros2_qos_provenance: BindingQoS | None =

Return what this Skill's publisher offers and where that came from, or None.

None before _init has advertised. The QoS is declared or defaulted, never discovered, so it cannot change.

async def _create_own_parameters(self):

Create the Parameters that are not message fields. A finite Skill has none.

async def _handle_resetting(self):

Clear the failure count. The ParameterSet stays, so nothing a client wrote is lost.

async def _init(self):

Let opensmi build the Skill, create the ParameterSet variables, and prove them.

The Parameters a client has not written yet hold the plan's initial values, so building a message from them is the message Start would publish now. A value ROS2 would abort the process over is thus a traceback here, not a core dump on a robot. The publisher is advertised last, so a declaration that cannot boot leaves no endpoint on the graph.

Raises
DeclarationErrorWhen the Component cannot raise a BindingEvent.
async def _note_a_failure(self, error: Exception):

Count one failed publish, report it, and halt when the tolerance is spent.

Every failure is reported, tolerated or not: a tolerated one has no other surface, since the Skill stays Running.

Raises
OpenSmiRuntimeErrorWhen this failure is one too many.
async def _publish(self):

Publish one snapshot of the Parameters, and let the continuity decide what a failure is.

Raises
OpenSmiRuntimeErrorWhen the publish failed and the tolerance is spent.
async def _report(self, code: str, *, severity: Severity, text: str):

Fire one BindingEvent about this Binding, and never let the reporting be the fault.

A failure to raise the event is only logged: a stream must not die because the report about a tolerated failure could not be made.

_binding =

Undocumented

_context =

Undocumented

_emit: Callable[..., Awaitable[None]] | None =

Undocumented

_failures: int =

Undocumented

_message_type: type[Message] =

Undocumented

_parameters =

Undocumented

_plan =

Undocumented

_publisher: Publisher | None =

Undocumented

_runtime =

Undocumented