class documentation

class ROS2LifecycleStartupSkill(MonitoringMixin, ROS2StartupSkill):

Constructor: ROS2LifecycleStartupSkill(bindings, runtime, **kwargs)

View In Hierarchy

One Component's lifecycle declarations, as the StartupSkill they all land on.

The declaring Component constructs it. A Component may name a subclass through startup_skill_type. It extends opensmi.ros2.server.required.ROS2StartupSkill with the managed nodes, so a Component with both required and lifecycle Bindings waits for the required ones first and then activates its nodes (see _start_the_ros2_side).

Method __init__ Build a Driver per declaration, before any node exists.
Async Method close_drivers Stop following and release every subscription. Idempotent.
Async Method close_startup Release the gate this Skill inherits, and then its own subscriptions. Idempotent.
Property bindings Return the declarations this Skill was built from, in declaration order.
Property drivers Return one Driver per declaration, in the same order.
Property node_presence Return a copy of whether each declared node is on the graph, by node path.
Property observed Return a copy of what each node last said about itself, as the Skill state it means.
Property terminal Return the node paths currently latched Terminal, in sorted order.
Async Method _command Ask every Driver to drive its nodes toward what one trigger means, and collect faults.
Async Method _condition_reset_allowed Refuse Reset while any node behind this Skill is Terminal.
Async Method _create_state_variables Give every declared node one Monitoring variable holding its lifecycle state.
Async Method _drive Command one trigger at every node, and halt this Skill if anything refused.
Method _fire Fire one trigger from a task of its own, never from the task that decided to.
Async Method _follow_appearances Ask a node what state it is in each time it appears, and only then.
Async Method _follow_transitions Record every transition one node announces, reading the pair and never the field.
Async Method _handle_halting Take back what this Skill brought up, and let opensmi halt what it halts.
Async Method _handle_resetting Configure every node.
Async Method _init Build the Skill, give every node a state variable, and start following.
Async Method _latch_terminal Latch or lift one node's Terminal condition, firing the event exactly on the latch.
Async Method _note Record one thing a node said about itself, and ask for the Skill to be settled.
Async Method _read_back Ask every node where it ended up, rather than assuming the command took it there.
Async Method _report Fire one BindingEvent about one node, and never let the reporting be the fault.
Method _require_every_node_active Refuse to reach Running unless every node actually reached active.
Async Method _settle Fire at most one trigger toward the aggregate, and say whether the Skill could act.
Async Method _settling Move the Skill toward what its nodes say, whenever something new has been recorded.
Method _spawn Run one following coroutine as a task this Skill owns and cancels.
Method _start_following Start one task per node per signal (transitions and appearances), plus the settling one.
Async Method _start_the_ros2_side Activate every node, and check they all got there.
Async Method _trigger_once Offer one trigger to the state machine, tolerating a state it is not valid from.
Method _weakest Return the Binding and node path that dragged the aggregate down to target.
Async Method _write_state Publish one node's lifecycle state as the label ROS2 spells it, with Good status.
Instance Variable _announced Undocumented
Instance Variable _bindings Undocumented
Instance Variable _commanding Undocumented
Instance Variable _drivers Undocumented
Instance Variable _emit Undocumented
Instance Variable _fired Undocumented
Instance Variable _firing Undocumented
Instance Variable _observed Undocumented
Instance Variable _owner Undocumented
Instance Variable _pending Undocumented
Instance Variable _performed Undocumented
Instance Variable _present Undocumented
Instance Variable _tasks Undocumented
Instance Variable _terminal Undocumented
Instance Variable _variables Undocumented
def __init__(self, *, bindings: Sequence[LifecycleBinding], runtime: RuntimeInterface, **kwargs: Any):

Build a Driver per declaration, before any node exists.

Parameters
bindings:Sequence[LifecycleBinding]Every lifecycle declaration on the Component. They share this one Skill, and their nodes aggregate lowest-wins.
runtime:RuntimeInterfaceThe Machine's Runtime, reached through the Component.
**kwargs:AnyWhat ~opensmi.ros2.server.required.ROS2StartupSkill takes.
Raises
DeclarationErrorWhen two declarations follow the same ROS2 node.
MessageTypeErrorWhen an interface package a declared flavour needs is missing.
async def close_drivers(self):

Stop following and release every subscription. Idempotent.

async def close_startup(self):

Release the gate this Skill inherits, and then its own subscriptions. Idempotent.

@property
bindings: tuple[LifecycleBinding, ...] =

Return the declarations this Skill was built from, in declaration order.

@property
drivers: tuple[LifecycleDriver, ...] =

Return one Driver per declaration, in the same order.

@property
node_presence: dict[str, bool] =

Return a copy of whether each declared node is on the graph, by node path.

A vanished node keeps its last state, because absence is not a lifecycle state. Presence comes from the node's transition_event subscription and answers a required lifecycle Binding (opensmi.ros2.server.required.satisfaction_of).

@property
observed: dict[str, SkillState] =

Return a copy of what each node last said about itself, as the Skill state it means.

@property
terminal: tuple[str, ...] =

Return the node paths currently latched Terminal, in sorted order.

While this is non-empty, Reset is refused.

async def _command(self, trigger: TRIGGER) -> tuple[str, ...]:

Ask every Driver to drive its nodes toward what one trigger means, and collect faults.

Idempotent, since each Driver gates every transition on what its nodes report as available.

async def _condition_reset_allowed(self, _user: UserAuthorization) -> bool:

Refuse Reset while any node behind this Skill is Terminal.

Commanding a transition at a finalized node returns success=False on a C++ node and kills the process on an rclpy one.

Raises
UaStatusCodeErrorBadInvalidState. It is raised because a bare False would reach try_trigger as an unexplained Good.
async def _create_state_variables(self):

Give every declared node one Monitoring variable holding its lifecycle state.

Created at init from the declaration alone, so they are readable against a robot that is off. They hold UNKNOWN_STATE until the node speaks, then the ROS2 label.

Raises
DuplicateVariableNameErrorWhen two declarations claim one state variable, which is the same Binding name and node path. This differs from two declarations following one node (see _require_one_owner_per_node).
async def _drive(self, trigger: TRIGGER):

Command one trigger at every node, and halt this Skill if anything refused.

Raises
OpenSmiRuntimeErrorWhen a node or a manager refused or did not answer.
def _fire(self, trigger: TRIGGER):

Fire one trigger from a task of its own, never from the task that decided to.

AsyncMachine cancels the tasks processing a transition when a new one begins and swallows the CancelledError, so a long-lived task awaiting a trigger would silently stop following.

async def _follow_appearances(self, driver: LifecycleDriver, path: str):

Ask a node what state it is in each time it appears, and only then.

A server starting against an already finalized node gets no transition event, and without this it would offer a Reset that cannot work. The node's transition_event publisher is still matched, so it can be seen.

async def _follow_transitions(self, driver: LifecycleDriver, path: str):

Record every transition one node announces, reading the pair and never the field.

async def _handle_halting(self):

Take back what this Skill brought up, and let opensmi halt what it halts.

Only transitions the Skill performed itself are rolled back, so a node that was already active when the Skill started is not touched. Never shutdown, since finalized is terminal and the Skill could not be reset. opensmi's own halting runs whatever the robot did, and the faults are raised afterwards.

async def _handle_resetting(self):

Configure every node.

async def _init(self):

Build the Skill, give every node a state variable, and start following.

Nothing is asked of the robot here, so a Component whose robot is off still builds. The first question goes out when a transition_event subscription gets a publisher.

Raises
DeclarationErrorWhen the Component cannot raise a BindingEvent.
async def _latch_terminal(self, path: str, state: LifecycleNodeState | int):

Latch or lift one node's Terminal condition, firing the event exactly on the latch.

Only observing another primary state on that path lifts it. The node vanishing does not, since the last thing known is still finalized.

async def _note(self, path: str, state: LifecycleNodeState | int, means: SkillState | None, *, routed: bool = False):

Record one thing a node said about itself, and ask for the Skill to be settled.

Transition states are not news: the Skill has its own intermediate states for them.

Parameters
path:strUndocumented
state:LifecycleNodeState | intUndocumented
means:SkillState | NoneUndocumented
routed:boolWhether this came from a transition_event and so carries the state pair. A routed observation outranks the routeless read-back of _read_back.
async def _read_back(self):

Ask every node where it ended up, rather than assuming the command took it there.

A node announces the transitions we caused too, and a Skill that ignored its own commands would read its successful Reset as a robot that never moved. The read has no route, so it gives a rank but not which state at that rank. A node that announced a transition inside this window is skipped: its event carries a route, and overwriting it would turn somebody else's failed activation (Halted) into a routeless inactive (Ready).

async def _report(self, binding: str, path: str, code: str, text: str, severity: Severity = Severity.ERROR):

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

A failure to raise the event is only logged.

def _require_every_node_active(self):

Refuse to reach Running unless every node actually reached active.

The Driver's gate is quiet: a node that offers no activate is skipped. That is right for halt but not for start, where a node left unconfigured would let Start succeed while the Skill claims a robot it does not have. The read-back is checked, not the command.

Raises
OpenSmiRuntimeErrorWhen any node reports anything other than active.
async def _settle(self) -> bool:

Fire at most one trigger toward the aggregate, and say whether the Skill could act.

Returns
boolFalse when the Skill is not resting and the observation has to be re-offered; True when it acted, or when there was nothing for it to do.
async def _settling(self):

Move the Skill toward what its nodes say, whenever something new has been recorded.

An observation the Skill cannot take yet (mid-transition, or a handler is commanding) is held and re-offered every SETTLE_INTERVAL.

def _spawn(self, work: Any, label: str):

Run one following coroutine as a task this Skill owns and cancels.

These tasks stay out of opensmi's own task bookkeeping, which is cancelled when the Skill halts, because a Skill that stopped watching on halt could never see its nodes come back.

def _start_following(self):

Start one task per node per signal (transitions and appearances), plus the settling one.

An appearance is the subscription's own DDS match event, which is the "one state query on first discovery".

async def _start_the_ros2_side(self):

Activate every node, and check they all got there.

This is the lifecycle half of Starting, run after the required Bindings were waited for. A required lifecycle Binding is thus waited for before its nodes are commanded: a node that is not on the graph does not answer, and that is a fault rather than a wait. Nodes of other required Bindings have their publishers by now, because a managed node creates them on configure, which Reset has already done.

async def _trigger_once(self, trigger: TRIGGER):

Offer one trigger to the state machine, tolerating a state it is not valid from.

try_trigger answers with a status code instead of raising, so a transition arriving mid-handler is harmless.

def _weakest(self, target: SkillState) -> tuple[LifecycleBinding, str]:

Return the Binding and node path that dragged the aggregate down to target.

The first in declaration order wins a tie.

async def _write_state(self, path: str, state: LifecycleNodeState | int):

Publish one node's lifecycle state as the label ROS2 spells it, with Good status.

_announced: set[str] =

Undocumented

_bindings =

Undocumented

_commanding =

Undocumented

_drivers =

Undocumented

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

Undocumented

_fired =

Undocumented

_firing: TRIGGER | None =

Undocumented

_observed: dict[str, SkillState] =

Undocumented

_owner =

Undocumented

_pending =

Undocumented

_performed: dict[str, set[LifecycleNodeTransition]] =

Undocumented

_present: dict[str, bool] =

Undocumented

_tasks: list[asyncio.Task[None]] =

Undocumented

_terminal: dict[str, str] =

Undocumented

_variables: dict[str, Node] =

Undocumented