Skip to main content

LifecycleTransition

Enum LifecycleTransition 

Source
#[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

Source

pub const ALL: [Self; 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.

Source

pub fn from_shorthand(state: LifecycleState, name: &str) -> Option<Self>

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.

Source

pub const fn from_u8(value: u8) -> Option<Self>

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).

Source

pub const fn source_state(&self) -> LifecycleState

Get the source state required for this transition.

Source

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.

Source

pub fn label(&self) -> &'static str

The lifecycle_msgs/msg/Transition.label for this transition.

Source

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

Source§

fn clone(&self) -> LifecycleTransition

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LifecycleTransition

Source§

impl Debug for LifecycleTransition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for LifecycleTransition

Source§

impl Hash for LifecycleTransition

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for LifecycleTransition

Source§

fn eq(&self, other: &LifecycleTransition) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LifecycleTransition

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.