Time synchronization between multiple sensors on multiple Raspberry Pi's
I have ROS kinetic running on two Raspberry Pi's (RPi's). Each RPi has is connected to a set of sensors. The RPi's are not connected with each other as they will be out in the field, but will be connected at least once via WLAN to a master computer to start (and eventually stop) the recording (rosbridge service to start/stop a rosbag file). Once data is collected, I would like to combine and analyze the data from both RPi's and therefore synchronize the data over time.
How can I ensure that they both record at the same clock time? I can add a real-time clock (RTC) to each of them and synchronize each RTC with the internet time once before the recording. But is that precise? I have seen in other threads here that chrony is recommended, which I have no experience with, yet. Another idea could be to record GPS reference time on both RPi's and synchronize the data to that one, but it would be recorded at low frequency (about 10 Hz) and I am not sure either how precise it could be.
Ideally, I would like to have a time sync error below say 1 ms.
Do you have any spontaneous suggestions how to go after it? I hope I provided enough details.
Asked by Test01 on 2019-11-01 04:59:38 UTC
Answers
PTP
Its an industry standard and works well for what you want. Look up specific instructions for your platform, that's not really ROS related so I don't want to get into any super deep discussion on it in this forum.
Asked by stevemacenski on 2019-11-02 20:07:41 UTC
Comments
@steveMacenski: would this need the two PIs to be networked? The OP seems to indicate that this is not the case, or at least not always.
Asked by gvdhoorn on 2019-11-04 03:25:52 UTC
To have something like the metric they're looking for, something like Chrony / PTP would be required, otherwise the clock drift over time would exceed 1 ms. Even NTP would not likely bound it below 1 ms over extended durations.
Asked by stevemacenski on 2019-11-04 03:32:25 UTC
I know, but I just wanted to draw attention to this fact for the benefit of the OP.
It's not entirely clear OP is aware of the intricacies of networked clock synchronisation, so making this requirement (ie: permanent network connection) explicit was something I felt could be important.
Asked by gvdhoorn on 2019-11-04 03:47:26 UTC
If you like to have an sync of 1ms the pi it the wrong system. Because then you neet a real time system.
It is not possible to sync those with # 1ms precision with an hard wire. Because you OS make different stuff in the background. The io has also delays.
You are not Abe to readout the sensors with this precise on one PI
Asked by duck-development on 2019-11-04 13:47:42 UTC
Comments
That is inaccurate. You can easily achieve 1ms on an RPi with a wired connection.
Asked by stevemacenski on 2019-11-06 08:42:13 UTC
If you could generate signal witch 1ms accuracy who need a real time system? Because ethercat is working with this frequency, and this the only couse you use an iec system.
Asked by duck-development on 2019-11-06 09:34:10 UTC
1ms is not real-time, 1ms is 1ms. They're asking about a real-time clock, not a real-time system. 1ms is just their example specification they want to bound their error at.
Asked by stevemacenski on 2019-11-06 09:56:17 UTC
Comments