altosui: Integrate accel speed from very start of eeprom record
authorKeith Packard <keithp@keithp.com>
Sun, 8 Apr 2012 01:35:26 +0000 (18:35 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 8 Apr 2012 01:35:26 +0000 (18:35 -0700)
Don't wait for the flight computer to have detected boost--that's
often several samples after boost actually occurred, which can leave a
bunch of acceleration out of the speed computation.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosEepromIterable.java

index d8205816b2674bffa20f7934b7a421505c6f8e8b..6fdaf8e04949cf6b85319647ad049acacabdc7fd 100644 (file)
@@ -99,6 +99,7 @@ public class AltosEepromIterable extends AltosRecordIterable {
                double  ground_pres;
                int     gps_tick;
                int     boost_tick;
+               int     sensor_tick;
 
                EepromState() {
                        seen = 0;
@@ -128,10 +129,13 @@ public class AltosEepromIterable extends AltosRecordIterable {
                                state.flight_pres = state.ground_pres;
                        } else {
                                state.flight_pres = (state.flight_pres * 15 + state.pres) / 16;
-                               state.flight_accel = (state.flight_accel * 15 + state.accel) / 16;
-                               state.flight_vel += (state.accel_plus_g - state.accel);
                        }
+                       state.flight_accel = (state.flight_accel * 15 + state.accel) / 16;
+                       if ((eeprom.seen & seen_sensor) == 0)
+                               eeprom.sensor_tick = record.tick - 1;
+                       state.flight_vel += (state.accel_plus_g - state.accel) * (record.tick - eeprom.sensor_tick);
                        eeprom.seen |= seen_sensor;
+                       eeprom.sensor_tick = record.tick;
                        has_accel = true;
                        break;
                case Altos.AO_LOG_PRESSURE: