Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

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

Oleg Kalachev57e83040b867
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));