Skip to content

Lifecycle helper interface proposal #654

Open
@mjeronimo

Description

@mjeronimo

Feature request

Feature description

LifecycleNodes (and Nodes) sometimes have helper classes that aren't themselves nodes, but that use the parent node handle to create publishers, subscribers, services, and so on. When walking a LifecycleNode through its various states, these helper classes should be walked along through the states as well. For example,

CallbackReturn
Parent::on_activate(const rclcpp_lifecycle::State & state)
{
  // Parent does its own activation

  // Delegates the on_activate message to is contained classes
  // Helpers could throw an exception upon failure
  helper1__->on_activate(state);
  helper2__->on_activate(state);

  return nav2_lifecycle::CallbackReturn::SUCCESS;
}

One could use the LifecycleNode interface (https://github.com/ros2/rclcpp/blob/master/rclcpp_lifecycle/include/rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp) for the helper classes but it seems to me that the on_error and on_shutdown callbacks are appropriate for nodes but not the helper classes; a helper class doesn't really "shut down" and the parent would be the one to recover, if possible, from an error state. So, using the LifecycleNodeInterface for this purpose wouldn't be very elegant - the helper classes would have to override these methods, but would likely not provide any useful implementation

Instead, I propose a LifecycleHelperInterface that has a subset of the methods from LifecycleNodeInterface: on_configure, on_activate, on_deactivate, and on_cleanup. Helper classes would implement these methods, allowing them to be used by a LifecycleNode and track with the state changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions