You're reading the documentation for a development version. For the latest released version, please have a look at Kilted.
Managing node lifecycles - example
Managed lifecycles for nodes allow greater control over the state of the ROS system. This example uses a simple talker/listener pair of managed nodes to show how a managed lifecycle can be implemented and used. You can use the example to understand and experiment with managing nodes in this way.
Area: ROS-framework | Content-type: example | Experience: expert
Summary
ROS 2 introduces the concept of managed nodes, also called lifecycle nodes. These nodes can be used to ensure that resources are correctly initialised, activated, deactivated, and cleaned up as the node moves between lifecycle states. A common use case is nodes that control hardware, where devices such as cameras, lidars, motor drivers, and other sensors and actuators must be started, configured, and shut down in a controlled order.
Using lifecycle nodes helps ensure hardware is only initialised when it is ready, and is safely released during shutdown or error recovery. The following packages enable you to implement these managed nodes: rclcpp_lifecycle (implementation library) and lifecycle_msgs (interface definitions).
Prerequisites
See the installation instructions for details on installing ROS 2.
Example
Access the example
Information on how to run the example is here: lifecycle_demo_launch.py
Commentary
For more information about how to run it and what’s happening, see: lifecycle README