altos: Add 100ms constants for baro Kalman filter
authorKeith Packard <keithp@keithp.com>
Fri, 28 Apr 2017 06:59:27 +0000 (23:59 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 28 Apr 2017 06:59:27 +0000 (23:59 -0700)
MicroPeak v2 uses this rate.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_microkalman.c
src/util/make-kalman

index ff543cc43ec8916c0c5475f5246fd43cbb5054d5..3cfb87ccbfa3bf8b7b8169387858cf2286bb49db 100644 (file)
 
 #include <ao_kalman.h>
 
 
 #include <ao_kalman.h>
 
+#ifndef AO_MK_STEP_96MS
+#define AO_MK_STEP_96MS        1
+
+#endif
+
+#if AO_MK_STEP_100MS
+#define AO_MK_TIME_STEP        0.1
+
+#define AO_K0_10       AO_MK2_BARO_K0_10
+#define AO_K1_10       AO_MK2_BARO_K1_10
+#define AO_K2_10       AO_MK2_BARO_K2_10
+#endif
+
+#if AO_MK_STEP_96MS
+#define AO_MK_TIME_STEP        0.096
+
+#define AO_K0_10       AO_MK_BARO_K0_10
+#define AO_K1_10       AO_MK_BARO_K1_10
+#define AO_K2_10       AO_MK_BARO_K2_10
+#endif
+
 /* Basic time step (96ms) */
 /* Basic time step (96ms) */
-#define AO_MK_STEP     to_fix_v(0.096)
+#define AO_MK_STEP     to_fix_v(AO_MK_TIME_STEP)
+
 /* step ** 2 / 2 */
 /* step ** 2 / 2 */
-#define AO_MK_STEP_2_2 to_fix_v(0.004608)
+#define AO_MK_STEP_2_2 to_fix_v(AO_MK_TIME_STEP * AO_MK_TIME_STEP / 2.0)
 
 uint32_t       ao_k_pa;                /* 24.8 fixed point */
 int32_t                ao_k_pa_speed;          /* 16.16 fixed point */
 
 uint32_t       ao_k_pa;                /* 24.8 fixed point */
 int32_t                ao_k_pa_speed;          /* 16.16 fixed point */
@@ -66,9 +88,9 @@ ao_microkalman_correct(void)
 
        e = pa - from_fix8(ao_k_pa);
 
 
        e = pa - from_fix8(ao_k_pa);
 
-       ao_k_pa       += fix16_to_fix8((int32_t) e * AO_MK_BARO_K0_10);
-       ao_k_pa_speed += (int32_t) e * AO_MK_BARO_K1_10;
-       ao_k_pa_accel += (int32_t) e * AO_MK_BARO_K2_10;
+       ao_k_pa       += fix16_to_fix8((int32_t) e * AO_K0_10);
+       ao_k_pa_speed += (int32_t) e * AO_K1_10;
+       ao_k_pa_accel += (int32_t) e * AO_K2_10;
        ao_pa = from_fix8(ao_k_pa);
        ao_pa_speed = from_fix(ao_k_pa_speed);
        ao_pa_accel = from_fix(ao_k_pa_accel);
        ao_pa = from_fix8(ao_k_pa);
        ao_pa_speed = from_fix(ao_k_pa_speed);
        ao_pa_accel = from_fix(ao_k_pa_accel);
index 580a45158a4285c4fdf28a8d33ce659de8a01222..c630e9cbb049626f3d0a3767b969d704641ae243 100644 (file)
@@ -40,4 +40,5 @@ nickle kalman.5c -p AO_BARO -c baro -t 0.01 $SIGMA_BARO
 nickle kalman.5c -p AO_BARO -c baro -t 0.1 $SIGMA_BARO
 nickle kalman.5c -p AO_BARO -c baro -t 1 $SIGMA_BARO
 
 nickle kalman.5c -p AO_BARO -c baro -t 0.1 $SIGMA_BARO
 nickle kalman.5c -p AO_BARO -c baro -t 1 $SIGMA_BARO
 
-nickle kalman_micro.5c -p AO_MK_BARO -c baro -t 0.096 $SIGMA_MICRO
\ No newline at end of file
+nickle kalman_micro.5c -p AO_MK_BARO -c baro -t 0.096 $SIGMA_MICRO
+nickle kalman_micro.5c -p AO_MK2_BARO -c baro -t 0.1 $SIGMA_MICRO