Current Flight Time

Is there a mavlink message that has the current flight time? Or what time the vehicle last took off so flight time could be calculated? I know these can be displayed in mission planner, but I’m using a c++ interface to drive the autopilot. I’m assuming mission planner just watches for the change to in-flight and then calculates flight based on that (since it only resets of you disconnect/reconnect mission planner)

Thanks

1 Like

Interesting read…may help you.MAVLINK_FOR_DUMMIESPart1_v.1.1.pdf (290.5 KB)

I didn’t see anything in there about flight time. I can send and receive mavlink messages no problem, upload missions, download missions, set params, etc.

Doesn’t look like MAVLINK supports that. I am not up to speed on MAVLINK yet.

Found this article about flight time. Looks like its an internal parameters.

https://ardupilot.org/copter/docs/common-flight-time-recorder.html

Maybe via some script it can be sent via Mavlink. Not sure.

I don’t think MAVLINK provide such data https://mavlink.io/en/messages/common.html

I don’t see any parameters. Not sure if you can read this parameter value STAT_FLTTIME remotely via Mavlink while in flight. That might be the only solution.

So how does MP and QGC do that? I don’t think they use internal timer, so maybe there is a way. Just need to find the answer.

Was also wondering about this the other day so I quickly took a glance at the code.

There seems to be a section which is updated every second and if the autpilot is armed AND the throttle is above 12% OR the ground speed is above 3m/s a variable (“timeInAir”) keeping the time (in seconds) is increased.
There is also a second variable which is increased, “timeSinceArmInAir” which is set to 0 as long as the autopilot is not armed.
Here is a screenshot of that snippet that gets updated every second:
image

1 Like

So it seems like MP actually keeps its own timer.
Nice finding and I was wrong (not the first time)
Gal