robot_activity

Node lifecycle is coming to ROS 2.0 in form of managed nodes, why not bring it to ROS already?

robot_activity is a ROS package, which implements node lifecycle. The idea is that you don’t have to write a lot of bolier-plate code in C++ when making a new ROS node and you get a lot of features for free!

A minimal example using robot_activity is available in the robot_activity_tutorials package. Check the robot_activity_tutorials_minimal_node.cpp

The main features of the package are:

  1. Controllable node lifecycle - nodes automatically expose ROS services that allow you to pause, stop, restart, reconfigure and terminate a given node
  2. ROS subscribers and services are automatically managed for you during the lifecycle. Services and callbacks will not be called if you request your node to exit RUNNING state. This means that you can now safely reconfigure your nodes without relaunching!
  3. Creation of super-nodes, multiple ROS nodes in a single process (similar to nodelets)
  4. Easy integration with a node supervisor using heartbeat and error messages.

The node lifecycle can be represented as a Finite State Machine (FSM): Example image When you inherit from robot_activity::ManagedRobotActivity, the subscribers and services are managed for you, meaning that they will only be executed in the RUNNING state.

  1. In PAUSED state, they are invoked, but immediately return without executing the actual body of the callback (services return false).
  2. In STOPPED state, all registered subscribers and services are shutdown, so that no IPC or TCP/IP traffic occurs.
  3. When transitioning back to PAUSED state from STOPPED, the subscribers and services are once again advertised for you (with the same arguments), but still not yet fully executed
  4. When transitioning back to RUNNING state from PAUSED, the subscibers and services are now functional. However, all callback invocation that occured out of RUNNING state are lost.

The detailed ROS API documentation, code API as well as message documentation is available at wiki.ros.org/robot_activity. The package is also released so you can install it with:

sudo apt-get install "^ros-${ROS_DISTRO}-robot-activity*"