How do I get System time and GPS time?

I just pulled down the python Mavlink SDK and fired up the telemetry.py example. I added an async function block to get Raw_Gps() data and ran this on a UgCS skyhub. I noticed the data I get for timestamp_us looks like epoch time however it does not map properly to current time. I wonder if this is related to my GPS having a “bad fix” while testing indoors. I also noticed that through Herelink under the MavLink inspector I see a value for System time that is formatted perfectly implying that my flight controller must have a RTC. I want to pull this time with my GPS data in the same way that data is streamed in the telemetry.py example. Is there a way to do this through the SDK? Thanks!

1 Like

Does it work with a proper fix outdoors then?

I will test that today. I guess my main question is that there seems to be at least two different sources for time. One being the GPS which seems to only tell me the microseconds since boot, but might be related to testing indoors. The second source is the flight controller internal clock which appears to be accessible via Mavlink since Herelink shows it in its Mavlink data. I would like to be able to get both sources in case gps is not available momentarily.

Hi… my python async call to raw_gps consistantly returns milliseconds since boot in timestamp_us.

This is the python code I am using:
async for timestamp_us in drone.telemetry.raw_gps():

Is there a way to retrieve GPS UNIX Epoch time using MAVSDK? It would be useful to synchronize actions in my 5 drone fleet.

Thanks!

It seems that https://github.com/mavlink/MAVSDK/pull/798 has added the function here:

https://mavsdk.mavlink.io/main/en/cpp/api_reference/classmavsdk_1_1_telemetry.html#classmavsdk_1_1_telemetry_1ab5ea5f6bb35b5670e34d5697d8c880f4

Which you can use to get the UNIX epoch time at least!

1 Like