projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altosuilib: New line styles and colors for graphs. Selectable line width
[fw/altos]
/
src
/
kernel
/
ao_kalman.c
diff --git
a/src/kernel/ao_kalman.c
b/src/kernel/ao_kalman.c
index d401a3c8ff5bd04a88c7dea0216d53abcd145589..ac41085df8166db526d26c0d5a95f5f750360056 100644
(file)
--- a/
src/kernel/ao_kalman.c
+++ b/
src/kernel/ao_kalman.c
@@
-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;
__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;
__pdata ao_v_t ao_error_h_sq_avg;
+#endif
#if HAS_ACCEL
__pdata ao_v_t ao_error_a;
#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)
{
static void
ao_kalman_err_height(void)
{
+#if !HAS_ACCEL
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,15
+95,12
@@
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 !HAS_ACCEL
e = ao_error_h;
if (e < 0)
e = -e;
if (e > 127)
e = 127;
e = ao_error_h;
if (e < 0)
e = -e;
if (e > 127)
e = 127;
-#if HAS_ACCEL
- ao_error_h_sq_avg -= ao_error_h_sq_avg >> 2;
- ao_error_h_sq_avg += (e * e) >> 2;
-#else
ao_error_h_sq_avg -= ao_error_h_sq_avg >> 4;
ao_error_h_sq_avg += (e * e) >> 4;
#endif
ao_error_h_sq_avg -= ao_error_h_sq_avg >> 4;
ao_error_h_sq_avg += (e * e) >> 4;
#endif
@@
-108,13
+109,13
@@
ao_kalman_err_height(void)
return;
height_distrust = ao_sample_alt - AO_MAX_BARO_HEIGHT;
#if HAS_ACCEL
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) {