Accurately timestamped GPS data on MavLink

Hi all,

I am having some issues achieving accurately timestamped GPS positions.

I have a drone connected to an offboard computer, which retrieves the GPS positions through MavLink and saves them to a file, which then is used in post-processing to match the drone position to some other data based on timestamp.

So far I have tried just timestamping the data when it arrives (which of course is not amazingly accurate), or using the supplied timestamp. Unfortunately, that timestamp is always in “time since boot”, not actual UNIX time. I have tried using both the TIME_SYNC and SYSTEM_TIME to correct for the offset.

In any case, the timestamps seem to be imprecise, and I need to apply offsets of up to around 100ms.

From docs and the Ardupilot source code it looks like the RAW_GPS data should actually use a UNIX timestamp once the time data from GPS is valid, but this never happens. I only get the time since boot timestamp.

The RTC_TYPES is set to sync to GPS.

I am using a F9P GPS, and tried with it sending data either as UBX or NMEA (making sure to enable TIMEGPS and RMC messages, respectively).

I also tried requesting GLOBAL_POSITION_INT_COV, which should include a UNIX timestamp, but that one doesn´t seem to be supported by Ardupilot.

To verify I have tried comparing the recorded data to post-processed PPK positions, based on the same RTK base station and GPS receiver in the drone, and I am getting the same time offsets.

Any advice? Especially on why the GPS_RAW message never supplies the UNIX timestamp, only time since boot?

Thanks!

Take a look at Fixed GPS timestamping and EKF time horizon issues by tridge · Pull Request #5060 · ArduPilot/ardupilot · GitHub