Ros2_control realtime safety

Thanks for these great insights! I have a question regarding real-time safety of ros2_control (hopefully not off-topic).

ros2_control uses services a lot for controller managing. Thus, is it strictly speaking real-time safe? Thank you for consideration!

Well, the docs explicitly state:

The ros2_control is a framework for (real-time) control of robots using (ROS 2).

And also other sources, such as this Discourse post make similar claims:

Keep in mind that one focus of ros2_control was real-time safe control loops, and they can run without any ROS networking magic

So I assume it should be realtime capable, but I have not investigated that myself.

One of the core capabilities of a real-time framework is to isolate and maintain the guarantees to meet the deadlines while interacting with non-real-time systems. There are many different mechanisms that can be used to communicate into and out of the real-time thread without blocking it, a common one is lock-free buffers. Without being able to interact with the rest of a robotic systems the real-time system would lose a lot of it’s value, such as receiving commands and providing logging and feedback.

1 Like

The ros2_control’s controller_manager launched with the provided ros2_control_node it spawns another thread to execute the read, update and write methods. This thread will be configured with FIFO priority on a real-time enabled system. All the services of the controller_manager are run on a non-RT thread, it shouldn’t affect any real-time performance in general.

What ros2_control ensures is a cleaner interaction between the main RT thread and the non-RT thread(from services and diagnostics etc). For instance, if a new controller is loaded or switched to activate (or) deactivate mode. It makes sure that it is effective from the next control cycle without affecting any realtimeness.

I hope this gives you some clarity

2 Likes

wow, thank you so much @JRTG, @tfoote and @saikishor. This does clarify a lot. I was coming from a standpoint where continuous activation / deactivation of controllers happens, which I am still not 100% convinced is real-time safe. But this might still be a misunderstanding / misuse on my end. I’ll think through it further.