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.
How to use
For now, we provide rclcpp-friendly classes. There are four things to do:
- Add package description to CMakeLists.txt and package.xml
- Add a configuration file in YAML format
- Change the
mainroutine in the source file- Change
rclcpp::init,rclcpp::shutdownto therclcpp_realtimenamespace - Change executors to be able to apply thread attributes provided by
rclcpp_realtime
- Change
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.
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.