Time synchronization approaches
I have a simple rover using ROS2 Foxy with a lidar running on Raspberry Pi and the rest of the stack running on Ubuntu PC (localization, navigation and odometry).
AMCL is complaining about extrapolation into the future as soon as I turn on the Lidar: https://answers.ros.org/question/3797...
This got me thinking about clock synchronization between nodes on my Ubuntu PC and the Raspberry Pi.
Ubuntu PC is synchronised using ntp
which is the default. Raspberry Pi is synchronized using Chrony which is provided by Balena.io docker environment: https://www.balena.io/docs/reference/...
Should this be enough or can it still cause a discrepancy that might cause TF issues?
How common is it to have more specialized time synchronization and how necessary it is?
Is it ok to synchronize 2 machines by just using ntp, or should one be synchronized by the time from the other?
So far I've seen these approaches:
1. Use ntpd_driver
and publish clock time from one computer and use it to synchronize time on another: https://index.ros.org/r/ntpd_driver/
2. Directly set one computer as ntp
server and use it as a source of truth for another one: http://wiki.ros.org/ROS/NetworkSetup#...
3. Just make sure both computers use ntp
and that's enough
Approach #1 is called a "typical ROS approach" here: https://gitlab.com/autowarefoundation...
How typical is it?
Every tutorial or video I've seen so far doesn't even mention time and clock synchronization so it seems like default approach #3 should work for most of people.
Or approaches #1 and #2 are just omitted because it's understood that you need to synchronize clock of one computer from the clock of another one if you don't want to have timing issues?
Just looking for a general guidance here.
Cheers!
You tagged this
ros2
, so this is somewhat off-topic, but I believe it still works:chrony
is typically used in situations where Wall-clock sync is not as important, but sync between two hosts is. You don't mention it, so I thought I would.If
host1
syncs to some (internet) NTP server, andhost2
syncs tohost1
usingchrony
, in the end the result should be identical, but in case neitherhost1
norhost2
have internet access (or access to anntpd
via some other means),chrony
betweenhost1
andhost2
will at least keeo their clocks synchronised.