projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Remove 8051 address space specifiers
[fw/altos]
/
src
/
kernel
/
ao_kalman.c
diff --git
a/src/kernel/ao_kalman.c
b/src/kernel/ao_kalman.c
index 87f1bf66f6147e372edad8a94513802aa11c1774..4f4ffe8f1b6a813b532cd4fe751ed6d684f34b6b 100644
(file)
--- a/
src/kernel/ao_kalman.c
+++ b/
src/kernel/ao_kalman.c
@@
-24,9
+24,9
@@
#include "ao_sample.h"
#include "ao_kalman.h"
#include "ao_sample.h"
#include "ao_kalman.h"
-static
__pdata
ao_k_t ao_k_height;
-static
__pdata
ao_k_t ao_k_speed;
-static
__pdata
ao_k_t ao_k_accel;
+static ao_k_t ao_k_height;
+static ao_k_t ao_k_speed;
+static ao_k_t ao_k_accel;
#define AO_K_STEP_100 to_fix_v(0.01)
#define AO_K_STEP_2_2_100 to_fix_v(0.00005)
#define AO_K_STEP_100 to_fix_v(0.01)
#define AO_K_STEP_2_2_100 to_fix_v(0.00005)
@@
-37,18
+37,24
@@
static __pdata ao_k_t ao_k_accel;
#define AO_K_STEP_1 to_fix_v(1)
#define AO_K_STEP_2_2_1 to_fix_v(0.5)
#define AO_K_STEP_1 to_fix_v(1)
#define AO_K_STEP_2_2_1 to_fix_v(0.5)
-
__pdata
ao_v_t ao_height;
-
__pdata
ao_v_t ao_speed;
-
__pdata
ao_v_t ao_accel;
-
__xdata
ao_v_t ao_max_height;
-static
__pdata
ao_k_t ao_avg_height_scaled;
-
__xdata
ao_v_t ao_avg_height;
+ao_v_t ao_height;
+ao_v_t ao_speed;
+ao_v_t ao_accel;
+ao_v_t ao_max_height;
+static ao_k_t ao_avg_height_scaled;
+ao_v_t ao_avg_height;
-__pdata ao_v_t ao_error_h;
-__pdata ao_v_t ao_error_h_sq_avg;
+ao_v_t ao_error_h;
+#if !HAS_ACCEL || AO_FLIGHT_TEST
+#define AO_ERROR_H_SQ_AVG 1
+#endif
+
+#if AO_ERROR_H_SQ_AVG
+ao_v_t ao_error_h_sq_avg;
+#endif
#if HAS_ACCEL
#if HAS_ACCEL
-
__pdata
ao_v_t ao_error_a;
+ao_v_t ao_error_a;
#endif
static void
#endif
static void
@@
-83,7
+89,9
@@
ao_kalman_predict(void)
static void
ao_kalman_err_height(void)
{
static void
ao_kalman_err_height(void)
{
+#if AO_ERROR_H_SQ_AVG
ao_v_t e;
ao_v_t e;
+#endif
ao_v_t height_distrust;
#if HAS_ACCEL
ao_v_t speed_distrust;
ao_v_t height_distrust;
#if HAS_ACCEL
ao_v_t speed_distrust;
@@
-91,6
+99,7
@@
ao_kalman_err_height(void)
ao_error_h = ao_sample_height - (ao_v_t) (ao_k_height >> 16);
ao_error_h = ao_sample_height - (ao_v_t) (ao_k_height >> 16);
+#if AO_ERROR_H_SQ_AVG
e = ao_error_h;
if (e < 0)
e = -e;
e = ao_error_h;
if (e < 0)
e = -e;
@@
-98,18
+107,19
@@
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;
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;
height_distrust = ao_sample_alt - AO_MAX_BARO_HEIGHT;
#if HAS_ACCEL
if (ao_flight_state >= ao_flight_drogue)
return;
height_distrust = ao_sample_alt - AO_MAX_BARO_HEIGHT;
#if HAS_ACCEL
- /* speed is stored * 16, but we need to ramp between 2
00
and 328, so
+ /* speed is stored * 16, but we need to ramp between 2
48
and 328, so
* we want to multiply by 2. The result is a shift by 3.
*/
speed_distrust = (ao_speed - AO_MS_TO_SPEED(AO_MAX_BARO_SPEED)) >> (4 - 1);
* we want to multiply by 2. The result is a shift by 3.
*/
speed_distrust = (ao_speed - AO_MS_TO_SPEED(AO_MAX_BARO_SPEED)) >> (4 - 1);
- if (speed_distrust
<= 0
)
- speed_distrust =
0
;
-
else
if (speed_distrust > height_distrust)
+ if (speed_distrust
> AO_MAX_SPEED_DISTRUST
)
+ speed_distrust =
AO_MAX_SPEED_DISTRUST
;
+ if (speed_distrust > height_distrust)
height_distrust = speed_distrust;
#endif
if (height_distrust > 0) {
height_distrust = speed_distrust;
#endif
if (height_distrust > 0) {