#[repr(u8)]pub enum LifecycleTransition {
Configure = 1,
Cleanup = 2,
Activate = 3,
Deactivate = 4,
ShutdownUnconfigured = 5,
ShutdownInactive = 6,
ShutdownActive = 7,
ErrorRecovery = 60,
}Expand description
Lifecycle transition (REP-2002)
Each transition has a specific source state. Shutdown has three variants because it can originate from Unconfigured, Inactive, or Active.
§The discriminants ARE lifecycle_msgs/msg/Transition (issue 1099)
These numbers are not ours to choose. They cross the C ABI as
NROS_LIFECYCLE_TRANSITION_*, they are what
nros::LifecycleNode::trigger_transition(uint8_t) accepts, and they are
what a ChangeState request carries on the wire — so a caller reaching any
one of those surfaces with a literal must get the transition ROS 2 would
give them.
They did not, until issue 1099: Activate/Deactivate/Cleanup were
2/3/4 where upstream is 3/4/2, so a ported
trigger_transition(2) on an Inactive node ACTIVATED it and returned OK
where ROS 2 cleans it up. Four of eight ids disagreed, and only the wire
path translated — the C and C++ paths passed the raw byte through.
The one id with no upstream counterpart is Self::ErrorRecovery: upstream
8 is TRANSITION_DESTROY, which we do not implement (nothing is
deallocated in a fixed arena), and upstream models error recovery as the
IMPLICIT TRANSITION_ON_ERROR_SUCCESS = 60. So ErrorRecovery is 60 —
the id transition_wire() in nros-node already put on the wire for it —
and 8 is now rejected rather than silently meaning error recovery.
Do not renumber these. nros_c::lifecycle re-asserts every one against its
NROS_LIFECYCLE_TRANSITION_* literal (issue 0792), and nros-node’s
transition_wire / from_msg_transition_id are now identity functions that
a test pins.
Variants§
Configure = 1
Unconfigured -> (configuring) -> Inactive
(lifecycle_msgs TRANSITION_CONFIGURE)
Cleanup = 2
Inactive -> (cleaning up) -> Unconfigured
(lifecycle_msgs TRANSITION_CLEANUP)
Activate = 3
Inactive -> (activating) -> Active
(lifecycle_msgs TRANSITION_ACTIVATE)
Deactivate = 4
Active -> (deactivating) -> Inactive
(lifecycle_msgs TRANSITION_DEACTIVATE)
ShutdownUnconfigured = 5
Unconfigured -> (shutting down) -> Finalized
(lifecycle_msgs TRANSITION_UNCONFIGURED_SHUTDOWN)
ShutdownInactive = 6
Inactive -> (shutting down) -> Finalized
(lifecycle_msgs TRANSITION_INACTIVE_SHUTDOWN)
ShutdownActive = 7
Active -> (shutting down) -> Finalized
(lifecycle_msgs TRANSITION_ACTIVE_SHUTDOWN)
ErrorRecovery = 60
ErrorProcessing -> (error recovery) -> Unconfigured
(lifecycle_msgs TRANSITION_ON_ERROR_SUCCESS; see the type doc for
why this is 60 and not 8 — 8 is upstream’s TRANSITION_DESTROY.)
Implementations§
Source§impl LifecycleTransition
impl LifecycleTransition
Sourcepub const ALL: [LifecycleTransition; 8]
pub const ALL: [LifecycleTransition; 8]
Every transition in the REP-2002 graph, in lifecycle_msgs id order.
phase-417 W4.f. The three shutdown variants are listed separately
because their source_state differs, which is
also rclcpp’s graph shape. nros_node::lifecycle_services served this
table over ~/get_transition_graph while holding it privately, so a
node’s own code could not read its transition table in ANY of our three
languages; this is the one table all of them now read.
Sourcepub fn from_shorthand(
state: LifecycleState,
name: &str,
) -> Option<LifecycleTransition>
pub fn from_shorthand( state: LifecycleState, name: &str, ) -> Option<LifecycleTransition>
Resolve a shorthand transition name from the current state.
“shutdown” maps to the correct variant based on the current state.
Returns None if the shorthand is not valid from the given state.
Sourcepub const fn from_u8(value: u8) -> Option<LifecycleTransition>
pub const fn from_u8(value: u8) -> Option<LifecycleTransition>
Try to convert from a lifecycle_msgs/msg/Transition id.
0 (TRANSITION_CREATE) and 8 (TRANSITION_DESTROY) are upstream
ids we deliberately do not implement — construction and deallocation are
not transitions in a fixed arena — so both are None rather than
aliases for something else (issue 1099).
Sourcepub const fn source_state(&self) -> LifecycleState
pub const fn source_state(&self) -> LifecycleState
Get the source state required for this transition.
Sourcepub const fn label_cstr(&self) -> &'static CStr
pub const fn label_cstr(&self) -> &'static CStr
The lifecycle_msgs/msg/Transition.label for this transition,
NUL-terminated. See LifecycleState::label_cstr for why the C
spelling is the source.
The three shutdown variants share the label "shutdown" — that is
upstream’s wire spelling, and from_shorthand is what resolves it back
against the current state.
Sourcepub fn label(&self) -> &'static str
pub fn label(&self) -> &'static str
The lifecycle_msgs/msg/Transition.label for this transition.
Sourcepub const fn goal_state(&self) -> LifecycleState
pub const fn goal_state(&self) -> LifecycleState
The state this transition ADVERTISES as its destination — rclcpp’s
Transition::goal_state().
It is the state a SUCCEEDING callback reaches, which is what the
transition graph advertises. A failing callback routes to
ErrorProcessing or rolls back at runtime; that is
apply_transition’s business and orthogonal to the advertised graph.
Trait Implementations§
Source§impl Clone for LifecycleTransition
impl Clone for LifecycleTransition
Source§fn clone(&self) -> LifecycleTransition
fn clone(&self) -> LifecycleTransition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more