ROS 2 Realtime Support Package

We have been working on adding real-time functionality to rcl and rclcpp since 2022.
In response to this proposal, we have created a new package that provides real-time functionality without changing the existing packages.

esol-community/ros2_realtime_support

Background

The previous discussion is as follows: ROS lacks a unified mechanism to formally support real-time functionality, and we have tried to achieve this by adding functionality to rcl and rclcpp.

On the other hand, it has been pointed out in past PTCs that it makes it difficult to check at release time and to support the OS.
Since CallbackIsolatedExecutor was announced around the same time, we have also changed our policy to provide functionality in separate packages.

Update REP-2017 prototype and executor using OS native threads - ROS/ROS General - Open Robotics Discourse

How to use

For now, we provide rclcpp-friendly classes. There are four things to do:

  1. Add package description to CMakeLists.txt and package.xml
  2. Add a configuration file in YAML format
  3. Change the main routine in the source file
    • Change rclcpp::init, rclcpp::shutdown to the rclcpp_realtime namespace
    • Change executors to be able to apply thread attributes provided by rclcpp_realtime

This allows thread attribute settings to be applied to executors by specifying an environment variable or a configuration file with --ros-args.
See the README below for details.

ros2_realtime_support/examples_rclcpp_realtime/README.md at rolling · esol-community/ros2_realtime_support

Discussion & Future Work

Despite the name, real-time support, not much has been done.
The thread attributes can be managed through the extended rcl interfaces; APIs for thread operations, abstracted by these attributes, are provided, and executors that use the attributes have been added.

In the future, we will change the mutexes and condition variables used in rclcpp_realtime on an RTOS to call OS-native APIs.
Another challenge is to make intra-process communication real-time, so we can guarantee real-time performance in robot systems that run on a single PC.

4 Likes