From 72e93a9c36f83ba39ce4f524017a266accf87765 Mon Sep 17 00:00:00 2001 From: Maximilian Laiacker Date: Wed, 11 Sep 2019 11:24:57 +0200 Subject: [PATCH] fixed total flight time counting bug After landing it can happen that a second take off is detected and then the _takeoff_time is rest, resulting in a wrong total flight time counter. With this fix the flight time is reliably counted from the first take off until the vehicle is disarmed. Normally the vehicle will not spend much time armed after landing, if it does the flight time will be off but this is the same as before this fix. This fix was tested in several flight experiments. --- src/modules/land_detector/LandDetector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/land_detector/LandDetector.cpp b/src/modules/land_detector/LandDetector.cpp index e597eac039..9a031aa576 100644 --- a/src/modules/land_detector/LandDetector.cpp +++ b/src/modules/land_detector/LandDetector.cpp @@ -104,7 +104,7 @@ void LandDetector::Run() (_land_detected.in_ground_effect != in_ground_effect) || (fabsf(_land_detected.alt_max - alt_max) > FLT_EPSILON)) { - if (!landDetected && _land_detected.landed) { + if (!landDetected && _land_detected.landed && _takeoff_time == 0) { /* only set take off time once, until disarming */ // We did take off _takeoff_time = now; }