Skip to content

ROS2 Concepts

Vivek edited this page Sep 11, 2022 · 4 revisions

Summary of some important concepts in ROS2:

1. Lifecycle nodes:

  • Lifecycle nodes are managed nodes state machines. It has primary and transition states.
  • Task is performed in primary states (steady states).
  • Transition states (intermediate states) indicate if the transition between two states is successful.
  • In a service client lifecycle, an external user can control the lifecycle of the nodes
  • Application - For some devices which take a long booting time such as laser or camera, we can perform activities in their configuring state.
  • currently, subscriber is not provided by the Lifecycle class.
* Reference - [https://github.com/ros2/demos/blob/foxy/lifecycle/README.rst](https://github.com/ros2/demos/blob/foxy/lifecycle/README.rst)

2. Composition

  • In ROS2, the recommended way of coding is using something akin to a nodelet, called a Component. These components are built into a shared library, and are then loaded by a container process at runtime. One main advantage of composition is that the deployment of the components will be a run-time decision and will give the operator more freedom in choosing between running the different nodes/components in different processes for debugging and fault isolation, and running in the same process for reduced overhead and efficient intraprocess communication.

  • In this package, we follow this recommendation and have defined the multimodal object recognition node as well as the data collector node as components and calling it via the executor defined in the corresponding launch files.

  • Reference - https://docs.ros.org/en/foxy/Concepts/About-Composition.html#writing-a-component

3. Quality of service:

  • Quality of Service (QoS) policies handles communication between the nodes.
  • If not defined, system default parameters will be chosen for the QoS profile.
  • Reliability, Lifespan, and Liveliness are some of the important QoS policies.
  • When compared to ROS1, ROS1 only sends "reliable" data. There is no option for "best-effort" reliability.
  • For critical applications, it is important to receive image data as soon as it is captured (Reliability - 'Best Effort'). Losing 5-6 frames doesn't matter for subscribers in this case. While some subscribers need reliable data.
  • We can configure QoS profiles for both publishers and subscribers. But we have to take care of compatibility constraints if we assign different profiles to them.
  • Reference - https://docs.ros.org/en/foxy/Concepts/About-Quality-of-Service-Settings.html

4. Message filters

  • Message filters have a policy defined for each filter. These filters take messages as input and depending upon this policy, they may or may not output the message at a later point in time.
  • Example - time synchronizer takes messages from multiple sources and outputs if all the received messages have the same timestamp. With C++ we can synchronize up to 9 channels.
  • Each filter has different input and output types. So, not all filters are inter-connectable.
  • Reference - https://github.com/ros2/message_filters/blob/master/include/message_filters/time_synchronizer.h
Clone this wiki locally