Rosanswers logo

I have a hardware controller node which controls three motors using SOEM with Ethercat. I use a ROS timer in this node with 500 Hz control frequency. However, I find out that the timer is not accurate at all; sometimes there is a 100ms delay and cause the Ethercat to send 'stop-working' commands to motors. So I plan to use a RT_PREEMPT patch to the current Linux kernel to solve the 'jitter' problem. However, I want to solve this problem with least effort possible. So what is the possible shortcut? And are there any problems if I only use the RT_PREEMPT patch without using ros_control or orocos framework as many people are actually using them?

Another problem is how to choose a suitable realtime priority for my hardware controller node?

Originally posted by Winston on ROS Answers with karma: 180 on 2017-05-11

Post score: 1


1 Answer 1


Rosanswers logo

I would suggest the following approach:

1) Setup RT_Preempt

You will need an RTOS anyway, I think RT_Preempt fits your demands.


2) Setup your Controller as RT-application



3) Allow RT priorities from Userspace


4) Find a suitable RT priority

When your controller does not require the entire CPU, this is not a problem. Just pick one (e.g. 80). This should work.

If this is not enough I would recommend trying ros_control.

Originally posted by Jan Carstensen with karma: 66 on 2017-05-12

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by Winston on 2017-05-17:
Does ros_control provide realt-time capability already?

Comment by Jan Carstensen on 2017-05-18:
ros_control on its own cannot provide real-time capabilities. It can, however, offer real-time safe functions. In any case, a real-time operating system (e.g. RT Preempt) is required.

Comment by Winston on 2017-05-18:
What do you mean by real-time safe functions? If I use ros_control, do I still needs to do 1) to 4) steps as you posted as the answer?

Comment by Jan Carstensen on 2017-05-18:
Your controller node will need to communicate with other ROS-nodes, this communication is not real-time safe. ros_control offers functions that separate this into a second thread.

You will either need 1-4 or only 1 and use orocos (e.g. https://github.com/skohlbr/rtt_ros_control_example).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.