altos: Don't compute filtered average of height error when HAS_ACCEL
authorKeith Packard <keithp@keithp.com>
Mon, 28 Aug 2017 07:15:43 +0000 (00:15 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 28 Aug 2017 07:22:43 +0000 (00:22 -0700)
We only use this for baro-only devices to avoid firing drogue charges
at mach transitions; we trust the combination of accel+baro to do the
right thing when available.

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

index 82315c485de086b7f3b0cb64a462a878ac620119..ac41085df8166db526d26c0d5a95f5f750360056 100644 (file)
@@ -45,7 +45,9 @@ static __pdata ao_k_t         ao_avg_height_scaled;
 __xdata ao_v_t                 ao_avg_height;
 
 __pdata ao_v_t                 ao_error_h;
+#if !HAS_ACCEL
 __pdata ao_v_t                 ao_error_h_sq_avg;
+#endif
 
 #if HAS_ACCEL
 __pdata ao_v_t                 ao_error_a;
@@ -83,7 +85,9 @@ ao_kalman_predict(void)
 static void
 ao_kalman_err_height(void)
 {
+#if !HAS_ACCEL
        ao_v_t  e;
+#endif
        ao_v_t height_distrust;
 #if HAS_ACCEL
        ao_v_t  speed_distrust;
@@ -91,6 +95,7 @@ ao_kalman_err_height(void)
 
        ao_error_h = ao_sample_height - (ao_v_t) (ao_k_height >> 16);
 
+#if !HAS_ACCEL
        e = ao_error_h;
        if (e < 0)
                e = -e;
@@ -98,6 +103,7 @@ ao_kalman_err_height(void)
                e = 127;
        ao_error_h_sq_avg -= ao_error_h_sq_avg >> 4;
        ao_error_h_sq_avg += (e * e) >> 4;
+#endif
 
        if (ao_flight_state >= ao_flight_drogue)
                return;
index f89d6a4ced254e0c7723eb002503987590b73d3d..fbef031d46129ab1039b186b7a3885144969e10d 100644 (file)
@@ -180,7 +180,9 @@ extern __xdata ao_v_t                       ao_max_height;  /* max of ao_height */
 extern __xdata ao_v_t                  ao_avg_height;  /* running average of height */
 
 extern __pdata ao_v_t                  ao_error_h;
+#if !HAS_ACCEL
 extern __pdata ao_v_t                  ao_error_h_sq_avg;
+#endif
 
 #if HAS_ACCEL
 extern __pdata ao_v_t                  ao_error_a;