class LifecycleDriver(ABC):
Known subclasses: ros2.server.drivers.Nav2ManagerDriver, ros2.server.drivers.StandardLifecycleDriver
Constructor: LifecycleDriver(binding, runtime)
One coordinator flavour, commanded and observed. Holds no state machine.
Constructed by the StartupSkill the Binding lands on. A declaration may name a subclass to add a third flavour.
| Method | __init__ |
Resolve every ROS2 type this flavour needs, before anything is subscribed or called. |
| Method | __repr__ |
Return a representation naming the flavour and what it drives. |
| Async Method | appearances |
Yield how many publishers one node's transition_event has, now and on each change. |
| Async Method | apply |
Drive every node toward what one Skill trigger means, and return what went wrong. |
| Async Method | close |
Close every subscription this Driver opened. Idempotent. |
| Async Method | offered |
Ask one node which transitions it will accept right now. |
| Async Method | open |
Subscribe to every node's transition_event. |
| Async Method | read |
Ask one node what state it is in. One call, never a poll. |
| Async Method | send |
Command one transition at the nodes that will accept it, the way this flavour does. |
| Async Method | transitions |
Yield every transition one node announces, until its subscription closes. |
| Class Variable | coordinates |
Whether path names a coordinator other than the node it drives, so that the nodes need to be listed. True for a nav2 manager, false for the standard flavour. |
| Class Variable | flavour |
The name a declaration selects this Driver by, and its key in DRIVERS. |
| Property | binding |
Return the declaration this Driver was built from. |
| Property | paths |
Return the lifecycle nodes this Driver observes, in declaration order. |
| Async Method | _call |
Call one ROS2 service, answering None when the call does not happen. |
| Async Method | _gate |
Ask each node which transitions it offers, keeping silence apart from none. |
| Instance Variable | _binding |
Undocumented |
| Instance Variable | _event |
Undocumented |
| Instance Variable | _get |
Undocumented |
| Instance Variable | _get |
Undocumented |
| Instance Variable | _runtime |
Undocumented |
| Instance Variable | _subscriptions |
Undocumented |
Resolve every ROS2 type this flavour needs, before anything is subscribed or called.
A missing interface package is a declaration error and fatal at init.
| Parameters | |
binding:LifecycleBinding | What to drive. |
runtime:RuntimeInterface | The Machine's Runtime, reached through the Component. |
| Raises | |
MessageTypeError | When an interface package this flavour needs is not installed. |
Yield how many publishers one node's transition_event has, now and on each change.
The current count arrives at once, so a Driver opened against a node that is already there looks immediately.
TRIGGER, ledger: dict[ str, set[ LifecycleNodeTransition]] | None = None) -> tuple[ str, ...]:
¶
Drive every node toward what one Skill trigger means, and return what went wrong.
The trigger's transitions run in order (TRANSITIONS_FOR), each gated per node on
what that node offers at that moment. The gate is read before the first transition and
again between transitions, because deactivating is what makes cleaning up available.
A node that answered and does not offer the transition is skipped without a fault, which makes the handlers idempotent. A node that did not answer is a fault, so that a robot that is off cannot let Start reach Running; it is asked once per trigger.
The ledger records what the Skill performed itself, and halt rolls back those transitions and no others. A node that was already active before Start has an empty ledger and is not touched.
| Parameters | |
trigger:TRIGGER | The Skill trigger to carry out. |
ledger:dict[ | What the Skill performed on each node, by path. Updated in place. None is an empty ledger. |
| Returns | |
tuple[ | One fault per node or coordinator that did not answer or said no. Empty is success, including having had nothing to do. |
Ask one node which transitions it will accept right now.
This is the gate. It is read from the robot, because a stale belief about the state would kill an rclpy node. The name avoids "available", which this project does not use for a state of the robot.
| Returns | |
frozenset[ | The transitions this project can command among those the node offers. The set is empty for a finalized node, and None when nobody answered. The two differ: a node that offers nothing is skipped, a node that is not there is a fault. |
Subscribe to every node's transition_event.
Subscribing is local, so a Component whose robot is off still finishes building. The first question goes out later, when the match events say a node is there.
Ask one node what state it is in. One call, never a poll.
| Returns | |
LifecycleNodeState | None | The state, or None when nobody answered (the node is off). |
LifecycleNodeTransition, paths: tuple[ str, ...]) -> Sequence[ str]:
¶
Command one transition at the nodes that will accept it, the way this flavour does.
Called only for a transition at least one of paths reported as available, so an implementation does not gate again.
| Parameters | |
transition:LifecycleNodeTransition | What to command. |
paths:tuple[ | The nodes that offered it, a non-empty subset of paths. |
| Returns | |
Sequence[ | One human-readable fault per refusal or missing answer; empty on success. Faults are returned so that an operator sees every cause, not the first. |
ros2.server.drivers.Nav2ManagerDriverWhether path names a coordinator other than the node it drives, so that the nodes need to be listed. True for a nav2 manager, false for the standard flavour.
Call one ROS2 service, answering None when the call does not happen.
A node that is off is a runtime condition, not a fault. The commanding path turns the missing answer into a message.
Iterable[ str]) -> tuple[ dict[ str, frozenset[ LifecycleNodeTransition]], list[ str]]:
¶
Ask each node which transitions it offers, keeping silence apart from none.
A node that offered nothing is carried with an empty set. A node that did not answer is a fault and is dropped from the set the following transitions gate on.
| Parameters | |
paths:Iterable[ | The nodes to ask, in the order their faults should be reported in. |
| Returns | |
tuple[ | What each node that answered offers, and one fault per node that did not. |