altos: use raw height while waiting for landing
authorKeith Packard <keithp@keithp.com>
Sun, 14 Aug 2011 06:58:03 +0000 (23:58 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 14 Aug 2011 06:58:03 +0000 (23:58 -0700)
This avoids any noise introduced by the kalman filter, making landing
detection much more reliable. This patch also changes the interval to
10s so that the height bounds can be increased to 4m.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao_flight.c
src/ao_kalman.c

index af3d6bfa36c2292ecc07e366a6edb7574e4a8df3..85c1825bddfebf68c06f2d2b055c511eddae4164 100644 (file)
@@ -54,7 +54,7 @@ __pdata uint8_t                       ao_flight_force_idle;
 /* Landing is detected by getting constant readings from both pressure and accelerometer
  * for a fairly long time (AO_INTERVAL_TICKS)
  */
 /* Landing is detected by getting constant readings from both pressure and accelerometer
  * for a fairly long time (AO_INTERVAL_TICKS)
  */
-#define AO_INTERVAL_TICKS      AO_SEC_TO_TICKS(5)
+#define AO_INTERVAL_TICKS      AO_SEC_TO_TICKS(10)
 
 #define abs(a) ((a) < 0 ? -(a) : (a))
 
 
 #define abs(a) ((a) < 0 ? -(a) : (a))
 
@@ -286,7 +286,7 @@ ao_flight(void)
                                ao_interval_max_height = ao_avg_height;
 
                        if ((int16_t) (ao_sample_tick - ao_interval_end) >= 0) {
                                ao_interval_max_height = ao_avg_height;
 
                        if ((int16_t) (ao_sample_tick - ao_interval_end) >= 0) {
-                               if (ao_interval_max_height - ao_interval_min_height <= AO_M_TO_HEIGHT(2))
+                               if (ao_interval_max_height - ao_interval_min_height <= AO_M_TO_HEIGHT(4))
                                {
                                        ao_flight_state = ao_flight_landed;
 
                                {
                                        ao_flight_state = ao_flight_landed;
 
index 203d727a07f4d837551539b74e9feb7a89e32f47..ee01949e5e54a416bc9737e56bb20a03261f8bc1 100644 (file)
@@ -277,7 +277,7 @@ ao_kalman(void)
        ao_accel = from_fix(ao_k_accel);
        if (ao_height > ao_max_height)
                ao_max_height = ao_height;
        ao_accel = from_fix(ao_k_accel);
        if (ao_height > ao_max_height)
                ao_max_height = ao_height;
-       ao_avg_height_scaled = ao_avg_height_scaled - ao_avg_height + ao_height;
+       ao_avg_height_scaled = ao_avg_height_scaled - ao_avg_height + ao_sample_height;
 #ifdef AO_FLIGHT_TEST
        if (ao_sample_tick - ao_sample_prev_tick > 50)
                ao_avg_height = (ao_avg_height_scaled + 1) >> 1;
 #ifdef AO_FLIGHT_TEST
        if (ao_sample_tick - ao_sample_prev_tick > 50)
                ao_avg_height = (ao_avg_height_scaled + 1) >> 1;