altos: Eliminate height requirement for coast detect
authorKeith Packard <keithp@keithp.com>
Mon, 7 May 2018 15:51:36 +0000 (08:51 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 7 May 2018 16:21:56 +0000 (09:21 -0700)
We had required a minimum altitude of 100m to transition from boost to
coast. With small motors in a heavy multi-staged rocket, this can fail
to detect coast in time to light the second motor.

Also, this would fail to deploy recovery systems if the flight failed
before reaching 100m.

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

index cb02c4549ee20564981f8fafa7c2072b1bdd1b65..7b3cb9fa6411055667c4fb82844c6582029a4c1b 100644 (file)
@@ -233,7 +233,7 @@ ao_flight(void)
                         * deceleration, or by waiting until the maximum burn duration
                         * (15 seconds) has past.
                         */
-                       if ((ao_accel < AO_MSS_TO_ACCEL(-2.5) && ao_height > AO_M_TO_HEIGHT(100)) ||
+                       if ((ao_accel < AO_MSS_TO_ACCEL(-2.5)) ||
                            (int16_t) (ao_sample_tick - ao_boost_tick) > BOOST_TICKS_MAX)
                        {
 #if HAS_ACCEL
@@ -310,7 +310,7 @@ ao_flight(void)
 #if HAS_ACCEL
                        else {
                        check_re_boost:
-                               ao_coast_avg_accel = ao_coast_avg_accel - (ao_coast_avg_accel >> 6) + (ao_accel >> 6);
+                               ao_coast_avg_accel = ao_coast_avg_accel + ((ao_accel - ao_coast_avg_accel) >> 5);
                                if (ao_coast_avg_accel > AO_MSS_TO_ACCEL(20)) {
                                        ao_boost_tick = ao_sample_tick;
                                        ao_flight_state = ao_flight_boost;