altos: Require sequencing through 'main' state before landing
authorKeith Packard <keithp@keithp.com>
Tue, 2 Aug 2011 09:09:23 +0000 (02:09 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 2 Aug 2011 09:09:23 +0000 (02:09 -0700)
The old version of the code would permit the flight to go straight
from 'drogue' to 'landed' without passing through 'main' at all. This
meant that a false landing detection would leave the main charge
unfired, potentially causing the airframe to land on drogue alone.

Requiring that the flight sequence pass through main ensures that the
main charge will get fired at the right time, although if the airframe
lands higher than that altitude, it will not go to 'landed' mode ever.

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

index a8760ff09a897aee05de58892f7d39ffcdfe565d..af3d6bfa36c2292ecc07e366a6edb7574e4a8df3 100644 (file)
@@ -233,16 +233,6 @@ ao_flight(void)
                                /* Turn the RDF beacon back on */
                                ao_rdf_set(1);
 
                                /* Turn the RDF beacon back on */
                                ao_rdf_set(1);
 
-                               /*
-                                * Start recording min/max height
-                                * to figure out when the rocket has landed
-                                */
-
-                               /* initialize interval values */
-                               ao_interval_end = ao_sample_tick + AO_INTERVAL_TICKS;
-
-                               ao_interval_min_height = ao_interval_max_height = ao_avg_height;
-
                                /* and enter drogue state */
                                ao_flight_state = ao_flight_drogue;
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                                /* and enter drogue state */
                                ao_flight_state = ao_flight_drogue;
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
@@ -266,16 +256,28 @@ ao_flight(void)
                        if (ao_height <= ao_config.main_deploy)
                        {
                                ao_ignite(ao_igniter_main);
                        if (ao_height <= ao_config.main_deploy)
                        {
                                ao_ignite(ao_igniter_main);
+
+                               /*
+                                * Start recording min/max height
+                                * to figure out when the rocket has landed
+                                */
+
+                               /* initialize interval values */
+                               ao_interval_end = ao_sample_tick + AO_INTERVAL_TICKS;
+
+                               ao_interval_min_height = ao_interval_max_height = ao_avg_height;
+
                                ao_flight_state = ao_flight_main;
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                        }
                                ao_flight_state = ao_flight_main;
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                        }
+                       break;
 
                        /* fall through... */
                case ao_flight_main:
 
 
                        /* fall through... */
                case ao_flight_main:
 
-                       /* drogue/main to land:
+                       /* main to land:
                         *
                         *
-                        * barometer: altitude stable and within 1000m of the launch altitude
+                        * barometer: altitude stable
                         */
 
                        if (ao_avg_height < ao_interval_min_height)
                         */
 
                        if (ao_avg_height < ao_interval_min_height)
@@ -284,8 +286,7 @@ ao_flight(void)
                                ao_interval_max_height = ao_avg_height;
 
                        if ((int16_t) (ao_sample_tick - ao_interval_end) >= 0) {
                                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(2))
+                               if (ao_interval_max_height - ao_interval_min_height <= AO_M_TO_HEIGHT(2))
                                {
                                        ao_flight_state = ao_flight_landed;
 
                                {
                                        ao_flight_state = ao_flight_landed;