1
$\begingroup$

To simulate a system, a global timer will be set and all submodules will be synchronized with that timer to work together. such as PID controller, kalman filter, PWM module etc.

How do you sync the timers in ROS?

1) should I make a timer pointer as paramter in PID() and pass the system "ros::Time xxx" to this PID? is this timer "real time" enough for a balance car?
(For the PID controller I can do this because the PID controller and the PWM generater will be in the same node).

2) or receive the msg from nodes and extract the time stamp and use? is the latency can be ignored or how to evaluate the latency?
(The Kanlman filter will be in the sensors node and from the coder view we cannot pass the system timer pointer to the kalman filter such as kalman() )

The PID controller works at around 500Hz and the kalman filter works at lower speed. my PWM is 5KHz.
Thanks a lot!

$\endgroup$

1 Answer 1

2
$\begingroup$

Your question kind of boils down to, what is real time ? In the end real time is what you want/specify for your system to work, whether it be hard real time or soft real time.

In practice ROS is not hard real-time, but is sufficient enough for most robotics applications. It seems to be that you are trying to take into account the latency between your submodules in your system. By experience I would recommend you to first try assuming there are latencies and see how your system works, and if needed investigate the latency issue.

Now for the problem you describe I would rather use the time-stamp in messages because they should give you the date at which they where emitted and compare it with the current machine time (aka the time you get in 1) ). One of the main motivation of defining interfaces between component with timestamps, is to have this simple to way to check if the input that you want to use are fresh (no latency correction needed), less fresh (latency correction to be taken into account) or old (re-design of the architecture).

Now what can impact the delay/latency in the software your describe ? It is the computational power required for your algorithms vs. the computational power at hand to run them. From your post it's hard to see, but a small board like (Pi,beaglebone,...) should be able to handle PID and Kalman filter (for reasonable number of states).

From a robotic perspective, balance boards are inverted pendulum so you try to stabilize an unstable equilibrium and you run your PID at 500Hz, from experience it sounds reasonable. Specifically because running faster and faster will increase your performances but at some point you will realize that the actuators are filtering the inputs so much that running the control faster dosen't bring anything.

$\endgroup$
1
  • $\begingroup$ this is helpful! I will try to use time-stamp in messages firstly. Thanks a lot. $\endgroup$
    – Nick Qian
    Oct 19, 2017 at 10:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.