ROS2 Lifecycle Nodes

Implements ROS2 managed lifecycle nodes with state transitions in Python and C++.

Updated Aug 16, 2026
One-click install
npx skills add https://github.com/three1324/yeonjinautomotive --skill ros2-lifecycle-nodes-three1324
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ROS2 Lifecycle Nodes
Source: https://github.com/three1324/yeonjinautomotive/tree/main/.claude/skills/ros2_lifecycle
Command: npx skills add https://github.com/three1324/yeonjinautomotive --skill ros2-lifecycle-nodes-three1324

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Managing node startup, shutdown, and resource allocation in ROS2 systems is error-prone when nodes initialize hardware or connections at unpredictable times. This Skill provides templates and patterns for ROS2 Managed (Lifecycle) Nodes so resources are allocated and released through controlled state transitions. ## Core Features & Use Cases - Lifecycle State Machine Reference: Covers the full state diagram (UNCONFIGURED, INACTIVE, ACTIVE) and the transitions between them (configure, activate, deactivate, cleanup, shutdown). - C++ Managed Node Template: Provides a rclcpp_lifecycle::LifecycleNode subclass overriding on_configure, on_activate, on_deactivate, on_cleanup, and on_shutdown with lifecycle publishers. - Lifecycle Client: Shows how to control another node's state remotely using lifecycle_msgs ChangeState and GetState services. - Use Case: When building a robot sensor driver that must open a serial port only after configuration and start publishing only after activation, use this Skill to structure the node so launch files can orchestrate its state automatically. ## Quick Start Ask the AI to generate a ROS2 lifecycle node in C++ that allocates its publisher in on_configure and only publishes while in the ACTIVE state.

Frequently Asked Questions about ROS2 Lifecycle Nodes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a ROS2 lifecycle node in C++?

Inherit from rclcpp_lifecycle::LifecycleNode and override the transition callbacks on_configure, on_activate, on_deactivate, on_cleanup, and on_shutdown. Create publishers in on_configure and call on_activate on the lifecycle publisher before publishing data.

What is the difference between a ROS2 node and a lifecycle node?

A standard rclcpp node starts running immediately, while a lifecycle node moves through managed states: UNCONFIGURED, INACTIVE, and ACTIVE. External tools or launch files trigger transitions, giving deterministic control over resource allocation and when publishing begins.

How do I change the state of a lifecycle node from another node?

Create a client for the target node's /change_state service using lifecycle_msgs::srv::ChangeState, then send a request with the desired transition id such as configure or activate. You can query the current state with the GetState service.

When should resources be allocated in a lifecycle node?

Allocate resources like memory, connections, and publishers in on_configure, and release them in on_cleanup. Only publish data or run main logic in the ACTIVE state, and use on_error to handle failures during transitions.

Can lifecycle nodes be managed from ROS2 launch files?

Yes, launch files can include LifecycleNode entries that automatically trigger configure and activate transitions at startup. This removes the need for manual service calls to bring nodes into the ACTIVE state.