goodrobots / vision_landing

Precision landing using visual targets
GNU General Public License v3.0
202 stars 71 forks source link

Create proper timesync mechanism #35

Closed fnoop closed 6 years ago

fnoop commented 7 years ago

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.

fnoop commented 7 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.

fnoop commented 7 years ago

This references the initial attempt grabbing timestamps from random messages: https://github.com/dronekit/dronekit-python/issues/218

fnoop commented 7 years ago

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.

fnoop commented 7 years ago

Adding TIMESYNC support to ardupilot: https://github.com/ArduPilot/ardupilot/issues/5884 https://github.com/ArduPilot/ardupilot/pull/5888