better_launch.elements.lifecycle_manager module

class better_launch.elements.lifecycle_manager.AbstractNode

Bases: object

class better_launch.elements.lifecycle_manager.LifecycleManager(node: AbstractNode)

Bases: object

property current_stage: LifecycleStage

The node’s current (that is, last known) lifecycle stage.

classmethod find_transition_path(start_ros_state: int, goal_ros_state: int) list[int]

Finds a sequence of transitions that will bring a node from an initial lifecycle state (the ROS state, not our LifecycleStage enum) to a target lifecycle state.

This is fairly low level and probably never needed.

Parameters

start_ros_stateint

The initial ROS lifecycle state.

goal_ros_stateint

The final ROS lifecycle state.

Returns

list[int]

A sequence of ROS lifecycle transitions that form a path from the start state to the goal state.

classmethod is_lifecycle(node: AbstractNode, timeout: float = None) bool

Checks whether a node supports lifecycle management.

For a node to support lifecycle management, it must be running, be registered with ROS and offer the ROS lifecycle management services. This method only checks whether one of the key services is present.

If a timeout is specified, the check will be repeated until it succeeds or the specified amount of time has passed. This is to ensure that a freshly started node had enough time to create its topics, especially on slower devices. See AbstractNode.is_lifecycle_node() for additional information.

Parameters

nodeAbstractNode

The node object to check for lifecycle support.

timeoutfloat

How long to wait at most for the lifecycle services to appear. Wait forever if None.

Returns

bool

True if the node supports lifecycle management, False otherwise.

property ros_state: int

The node’s current (that is, last known) ROS lifecycle state ID.

transition(target_stage: LifecycleStage) bool

Transition the managed node into the target lifecycle stage. Does nothing if the node is already in the desired stage.

Note that you don’t have to do step-by-step transitions - simply specify the stage you want the node to end up in and it will go through all the intermediate steps (assuming a path exists).

Parameters

target_stageLifecycleStage

The lifecycle stage you want the node to end up in.

Returns

bool

True if the transition sequence succeeded, False if one of the steps failed.

Raises

ValueError

If no path to the target stage could be found.

class better_launch.elements.lifecycle_manager.LifecycleStage(*values)

Bases: IntEnum

Represents the main stages of nodes that support lifecycle management.

ACTIVE = 2
CONFIGURED = 1
FINALIZED = 3
PRISTINE = 0