From 57e83040b8670b2861ebc51a2f9d2cd8e5c10a34 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Tue, 19 Dec 2023 04:46:59 +0300 Subject: [PATCH] Apply accelerometer in estimation only when we're landed and stable Accelerometer gives only motors specific force in flight, which makes it useless to determine the current vertial --- flix/estimate.ino | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/flix/estimate.ino b/flix/estimate.ino index b8445a7..6302e9f 100644 --- a/flix/estimate.ino +++ b/flix/estimate.ino @@ -29,10 +29,9 @@ void applyAcc() { // test should we apply accelerometer gravity correction float accNorm = acc.norm(); - if (accNorm < ACC_MIN * ONE_G || accNorm > ACC_MAX * ONE_G) { - // use accelerometer only when we're not accelerating - return; - } + bool landed = !motorsActive() && abs(accNorm - ONE_G) < ONE_G * 0.1f; + + if (!landed) return; // calculate accelerometer correction Vector up = attitude.rotate(Vector(0, 0, -1));