summaryrefslogtreecommitdiff
path: root/src/ao_flight.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-08-01 22:33:38 -0700
committerKeith Packard <keithp@keithp.com>2011-08-02 00:30:08 -0700
commite19a117b99e8374ca0e8e35948e23bc672ad1a32 (patch)
treec079f4bf51fbca4ff00dd5232698cd6ecd247436 /src/ao_flight.c
parent146a0ab223e8d9b376125d1e59f597f6d7851a9b (diff)
altos: Average height values for landing detection
Instead of using the direct output of the kalman filter and hoping that is quiet enough to detect landing, filter that with a long exponential decay filter and then check to make sure that doesn't change more than 2m in 5 seconds as a trigger for landing detection. Tested with existing telemetrum flight logs and it correctly detects landing in all cases. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/ao_flight.c')
-rw-r--r--src/ao_flight.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/ao_flight.c b/src/ao_flight.c
index f1b60d69..a8760ff0 100644
--- a/src/ao_flight.c
+++ b/src/ao_flight.c
@@ -43,7 +43,6 @@ __pdata uint16_t ao_launch_tick; /* time of launch detect */
__pdata uint16_t ao_interval_end;
__pdata int16_t ao_interval_min_height;
__pdata int16_t ao_interval_max_height;
-
__pdata uint8_t ao_flight_force_idle;
/* We also have a clock, which can be used to sanity check things in
@@ -242,7 +241,7 @@ ao_flight(void)
/* initialize interval values */
ao_interval_end = ao_sample_tick + AO_INTERVAL_TICKS;
- ao_interval_min_height = ao_interval_max_height = ao_height;
+ ao_interval_min_height = ao_interval_max_height = ao_avg_height;
/* and enter drogue state */
ao_flight_state = ao_flight_drogue;
@@ -279,14 +278,14 @@ ao_flight(void)
* barometer: altitude stable and within 1000m of the launch altitude
*/
- if (ao_height < ao_interval_min_height)
- ao_interval_min_height = ao_height;
- if (ao_height > ao_interval_max_height)
- ao_interval_max_height = ao_height;
+ if (ao_avg_height < ao_interval_min_height)
+ ao_interval_min_height = ao_avg_height;
+ if (ao_avg_height > ao_interval_max_height)
+ ao_interval_max_height = ao_avg_height;
if ((int16_t) (ao_sample_tick - ao_interval_end) >= 0) {
if (ao_height < AO_M_TO_HEIGHT(1000) &&
- ao_interval_max_height - ao_interval_min_height < AO_M_TO_HEIGHT(5))
+ ao_interval_max_height - ao_interval_min_height <= AO_M_TO_HEIGHT(2))
{
ao_flight_state = ao_flight_landed;
@@ -295,7 +294,7 @@ ao_flight(void)
ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
}
- ao_interval_min_height = ao_interval_max_height = ao_height;
+ ao_interval_min_height = ao_interval_max_height = ao_avg_height;
ao_interval_end = ao_sample_tick + AO_INTERVAL_TICKS;
}
break;