ros2 / rclcpp

rclcpp (ROS Client Library for C++)
Apache License 2.0
563 stars 427 forks source link

Lifecycle rewrite for separation of concerns #2212

Open tgroechel opened 1 year ago

tgroechel commented 1 year ago

Feature request

Rewrite rclcpp::lifecycle for clearer separation of concerns (SoC).

Initial PR: https://github.com/ros2/rclcpp/pull/2211

Feature description

I rewrote some of the lifecycle backend code while attempting to create async transitions (https://github.com/ros2/rclcpp/pull/2214). It was suggested it would be best to separate this SoC contribution out into its own issue/PR.

The primary goal was to separate out some of LifecycleNodeInterfaceImpl is responsible for. Currently the LifecycleNodeInterfaceImpl is responsible for:

  1. managing ManagedEntities
  2. managing underlying rcl::state_machine
  3. managing services

I separated these out into files/classes. Proposed architecture: soc_lifecycle

This follows more closely to a model-view-controller design: LifecycleNodeInterfaceImpl: ("controller") owner of:

I also separated out the change_state process into multiple functions to allow for easier splitting when creating async transitions. Additionally, I did some miscellaneous function cleanup and added helper functions for readability.

ros-discourse commented 1 year ago

This issue has been mentioned on ROS Discourse. There might be relevant details there:

https://discourse.ros.org/t/deferrable-canceleable-lifecycle-transitions/32318/1