@lbegani real-time is a larger topic and as Jackie in above article points includes memory management (no allocations on the runtime), device IO (e.g. no logging to disk) and synchronization (thread priorities, no indefinitely blocking calls, …).
In addition you also need to have an RTOS that supports deterministic scheduling (e.g. QNX) and a real-time DDS implementation (currently only Connext Micro DDS is so and for that we do not have an rmw_* layer yet).
For below assume that I only talk about C++ code, so no python, java and friends.
Said that following has been done to make ROS 2 real-time so far:
- all rmw_* implementations have static type support (https://github.com/ros2/rmw_fastrtps/pull/203, https://github.com/ros2/rmw_fastrtps/pull/218)
- all data structures in rcutils, rmw, and rcl take in allocators (https://github.com/ros2/rcutils/pull/102, https://github.com/ros2/rcl/pull/261, https://github.com/ros2/rmw_fastrtps/pull/208/files)
@wjwwood you’d have more to add here …, right?
What would still need to happen:
- rclcpp needs to be memory audited, e.g. if there are usages of STL containers, we need to use memory allocators for them (e.g. https://github.com/foonathan/memory)
- allocators need to be passed correctly between rmw, rcl and rclcpp layers
- threads need to have controllable stack sizes and priorities
static exceptions need to be used
- logging to memory needs to be implemented (as oppose to the file)
https://en.wikipedia.org/wiki/Run-time_type_information needs to be looked at. This is probably not real-time safe
- waitset concept needs to be implemented in addition to callbacks (see https://github.com/ros2/rclcpp/issues/572)
Finally developers should also use managed nodes to be able to differentiate between memory pre-allocation and memory re-use on the runtime. Developers should also use an RTOS and a static DDS implementation.
I am probably still missing out on lots of other things but this is from the top of my head and as you see still quite some work to get there.