Closed fnoop closed 6 years ago
Note mavros already contains a good mechanism for synching the OBC RTC to the FC, so add an option to turn on/off this timesync mechanism.
This references the initial attempt grabbing timestamps from random messages: https://github.com/dronekit/dronekit-python/issues/218
A much better method would be simply to take the time from SYSTEM_TIME instead of grabbing from random messages (duh). But this still suffers from latency on the link. TIMESYNC send/receive is needed to calculate the latency on the link and synchronise the timestamps. It looks like TIMESYNC isn't supported by ardupilot.
Adding TIMESYNC support to ardupilot: https://github.com/ArduPilot/ardupilot/issues/5884 https://github.com/ArduPilot/ardupilot/pull/5888
Currently there is an attempt to sync timestamps between FC and OBC extracting timestamps from mavlink messages and adding microseconds from local clock tick. This suffers from out of order mavlink message processing and doesn't take into account transmission latency.
Instead, use the mavlink timesync messaging, establish the roundtrip latency/offset, and use that as the basis for adding the local ticker. Call regularly to counteract drift.