Lifecycle Nodes in Python

Hey there!

We develop in Python, and we would like to be able to use the functionality of lifecycle nodes in Python.

Is there an existing ROS2 roadmap for lifecycle nodes in Python, and what are people’s thoughts on the best way to get this working in Python (bindings, etc.)?

At the time of development, rclpy wasn’t in a state which easily allowed us to integrate lifecycle nodes in Python. That’s why we have it only available in C++ as for now.

We anticipated however, that lifecycles are also important to have in Python, so we tried to have as much functionality covered in rcl, so that rclpy really only has to wrap/implement as little as needed.
That is, the state machine with its transitions, as well as a basic communication interface for transition events and services are established within rcl. A high level language really only has to bind callbacks to these services and provide boilerplate to change transitions either via API or service callbacks.

I am not aware of any roadmap specifically designed for Python and Lifecycle nodes, but it shouldn’t be too hard to replicate a lifecycle node. You might want to have a look at what’s implemented in C++, which uses the functionality provided by rcl, to judge how much work it’ll be in Python.

1 Like

I found this repository, but have not been able to test the code yet:

https://github.com/wesleysliao/ros2_lifecycle_py

From a quick look, looks like it was implemented here: Implement managed nodes by ivanpauno · Pull Request #865 · ros2/rclpy · GitHub
I’ve been meaning to try it out.

1 Like

As @tnajjar mentioned on previous comment, Managed Node of rclpy is supported with Rolling and Humble. There is also demo for Managed Node of rclpy, hope this could be helpful.

3 Likes