Just wondering if there is a way to have qGroundcontrol announce flight time whilst flying. I have found this handy on my Taranis but now I am flying with an integrated controller and display… I don’t have that timer announcement and miss it.
I am not totally sure, but as far as I know, there is no such message in MavLink and it seems like every application like MP, QGC taranis etc. have their own timer. i.e when they get a MavLink message like arm or set home or another event that indicates takeoff or something like that, they reset this timer to 0 and than simply present it as flight time. The message you have in the taranis is probably from taranis and not from the FC.
And I truly wonder why there is no such functionality in MavLink?
Just my 2C
He Thanks Gal
I don’t think it’s a mavlink function. I think that qGRoundcontrol should be able to announce the flight time numbers as it already reports them on the screen. So its a known value…not sure about it’s accuracy but the value is know. So the app would just need to announce the value.
I did read late last night that there is a request in to have this feature in QGC but it is not there today.
So here’s hoping to it getting into an update sooner then later.
So it appears there is both a voltage value and a flight time value.
I imagine it might be possible to convert ms to Minutes and send the message to the GCS…no idea how at this point.
voltage( instance ) - Returns the voltage of the selected battery instance.
get_flying_time_ms() - Returns time in milliseconds since the autopilot thinks it started flying, or zero if not currently flying.
Well I am giving it a try
This is what I have so far. lol
function FlightTime() – periodic function that will be called
local Flight_timeMIN = math.tointeger (vehicle:get_flying_time_ms()*0.000016667) – Convert to minutes integer
gcs:send_text(0, Flight_timeMIN & " Minutes") – send the traditional message
You have the bare bones there. The concatenate operator in Lua is .. rather than an ampersand.
I don’t think the math library supports tointeger(). You are probably looking for math.floor()
There’s a TON of info in this live stream that I presented last week.
I haven’t tested this, but it should work:
local RUN_INTERVAL = 30000
local MAV_SEVERITY_WARNING = 4
local ms = vehicle:get_flying_time_ms()
if ms < 1 then return flight_time, RUN_INTERVAL end -- skip if we aren't flying
local mins= math.floor(ms / 60000)
gcs:send_text(MAV_SEVERITY_WARNING, tostring(mins) .. " Minutes")
return flight_time, RUN_INTERVAL
OK … not Ampersand…good to know. https://www.lua.org/manual/5.4/manual.html#pdf-math.tointeger
This is where I got the Integer function. But hey if it’s not needed sweet.
I assume I need to copy this into a file of some sort ending with .Lua.
But what I don’t understand is how does it start or does it start simply because it’s in the Lua Script folder and I have set SCR_ENABLE to 1.