Hi,
I common problem I run into are latencies induced by chains of timers, spanning over multiple nodes.
Example :
State Estimator
- Has a timer computing the current state of the robot (Pose / Velocity etc) every 10 ms. Publishes state data.
Trajectory Follower
- Has a timer computing the joint cmd every 10 ms. Works on state data, publishes joint cmd.
Joint Driver
- Has a timer every 10ms, that writes the last received joint cmd to the hardware.
In this example, we can have a latency up to 30 ms, just by bad timing of the timers. E.g. if every timer runs at the exactly same time, each timer would work on 10 ms old data from the previous timer in the chain.
To make matters worse, the latency will vary on every startup.
I thought about this a while and found a few possible solution so far
- Use something like ros2_control and run as much as possible in sequence / remove as much timers as possible, run things callback based.
- Increase the frequency of the timers.
- Sync the timers.
Does anyone know of a further option ?
Option 1 and 2 are not practicable in my special use case. Therefore I am looking into option 3. Until now my best idea was, to measure the worst case runtime of the timers, and extend the rcl timer api to be able to set the āstart timeā of a timer. Note, timers always trigger on āstart timeā + X * period.
E.g.
State estimator needs up to 4 ms to compute the state, and msg pub / rec takes around 400 us.
Trajectory Follower takes around 2 ms + plus 400 us pub/rec.
This would result in a start timer config of
- State estimator 0
- Trajectory Follower 5ms
- Joint driver 8ms
I would love to know your thoughts about this, and if I am missing something obvious, that would break the timer sync ideaā¦