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
This commit is contained in:
Oleg Kalachev 2023-12-19 04:46:59 +03:00
parent 415f0e9ad5
commit 57e83040b8

View File

@ -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));