altoslib: Move computed state from AltosRecord to AltosState
authorKeith Packard <keithp@keithp.com>
Sun, 21 Oct 2012 23:13:14 +0000 (16:13 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 21 Oct 2012 23:13:14 +0000 (16:13 -0700)
Make AltosRecord simply track the raw data and have AltosState hold
all computed values, including cross-packet averages and computed speeds.

Signed-off-by: Keith Packard <keithp@keithp.com>
21 files changed:
altoslib/AltosIdleMonitor.java
altoslib/AltosRecord.java
altoslib/AltosRecordMM.java
altoslib/AltosRecordTM.java
altoslib/AltosState.java
altoslib/AltosTelemetryRecordLegacy.java
altoslib/AltosTelemetryRecordMegaData.java
altoslib/AltosTelemetryRecordRaw.java
altoslib/AltosTelemetryRecordSensor.java
altoslib/Makefile.am
altosui/AltosAscent.java
altosui/AltosCSV.java
altosui/AltosDataPoint.java
altosui/AltosDataPointReader.java
altosui/AltosDescent.java
altosui/AltosDisplayThread.java
altosui/AltosFlightStats.java
altosui/AltosGraphUI.java
altosui/AltosInfoTable.java
altosui/AltosKML.java
altosui/AltosLanded.java

index 2c4965ff42047dc027f0073993b21ae4ce0375b8..07d8930d36e45a23229886957d8c577a61434556 100644 (file)
@@ -97,7 +97,7 @@ public class AltosIdleMonitor extends Thread {
                        else if (has_sensor_mm(config_data))
                                record = sensor_mm(config_data);
                        else
                        else if (has_sensor_mm(config_data))
                                record = sensor_mm(config_data);
                        else
-                               record = new AltosRecord();
+                               record = new AltosRecordNone();
 
                        if (has_gps(config_data))
                                gps = new AltosGPSQuery(link, config_data);
 
                        if (has_gps(config_data))
                                gps = new AltosGPSQuery(link, config_data);
index 8bab1d0cad2ad0c7b2700f809fc8ac09d14a6eff..091695154fea3cc01a2a5fecf7b2afebed47e218 100644 (file)
@@ -17,7 +17,7 @@
 
 package org.altusmetrum.AltosLib;
 
 
 package org.altusmetrum.AltosLib;
 
-public class AltosRecord implements Comparable <AltosRecord>, Cloneable {
+public abstract class AltosRecord implements Comparable <AltosRecord>, Cloneable {
 
        public static final int seen_flight = 1;
        public static final int seen_sensor = 2;
 
        public static final int seen_flight = 1;
        public static final int seen_sensor = 2;
@@ -43,11 +43,6 @@ public class AltosRecord implements Comparable <AltosRecord>, Cloneable {
        public int      state;
        public int      tick;
 
        public int      state;
        public int      tick;
 
-       /* Current flight dynamic state */
-       public double   acceleration;   /* m/s² */
-       public double   speed;          /* m/s */
-       public double   height;         /* m */
-
        public AltosGPS gps;
        public boolean  new_gps;
 
        public AltosGPS gps;
        public boolean  new_gps;
 
@@ -63,6 +58,11 @@ public class AltosRecord implements Comparable <AltosRecord>, Cloneable {
 
        public AltosRecordCompanion companion;
 
 
        public AltosRecordCompanion companion;
 
+       /* Telemetry sources have these values recorded from the flight computer */
+       public double   kalman_height;
+       public double   kalman_speed;
+       public double   kalman_acceleration;
+
        /*
         * Abstract methods that convert record data
         * to standard units:
        /*
         * Abstract methods that convert record data
         * to standard units:
@@ -75,76 +75,48 @@ public class AltosRecord implements Comparable <AltosRecord>, Cloneable {
         *      temperature:    °C
         */
 
         *      temperature:    °C
         */
 
-       public double raw_pressure() { return MISSING; }
-
-       public double filtered_pressure() { return MISSING; }
-
-       public double ground_pressure() { return MISSING; }
-
-       public double battery_voltage() { return MISSING; }
+       abstract public double pressure();
+       abstract public double ground_pressure();
+       abstract public double acceleration();
 
 
-       public double main_voltage() { return MISSING; }
+       public double altitude() {
+               double  p = pressure();
 
 
-       public double drogue_voltage() { return MISSING; }
-
-       public double temperature() { return MISSING; }
-       
-       public double acceleration() { return MISSING; }
-
-       public double accel_speed() { return MISSING; }
-
-       public AltosIMU imu() { return null; }
-
-       public AltosMag mag() { return null; }
-
-       /*
-        * Convert various pressure values to altitude
-        */
-
-       public double raw_altitude() {
-               double p = raw_pressure();
                if (p == MISSING)
                        return MISSING;
                return AltosConvert.pressure_to_altitude(p);
        }
 
        public double ground_altitude() {
                if (p == MISSING)
                        return MISSING;
                return AltosConvert.pressure_to_altitude(p);
        }
 
        public double ground_altitude() {
-               double p = ground_pressure();
+               double  p = ground_pressure();
+
                if (p == MISSING)
                        return MISSING;
                return AltosConvert.pressure_to_altitude(p);
        }
 
                if (p == MISSING)
                        return MISSING;
                return AltosConvert.pressure_to_altitude(p);
        }
 
-       public double filtered_altitude() {
-               double  ga = ground_altitude();
-               if (height != MISSING && ga != MISSING)
-                       return height + ga;
+       public double height() {
+               double  g = ground_altitude();
+               double  a = altitude();
 
 
-               double  p = filtered_pressure();
-               if (p == MISSING)
-                       return raw_altitude();
-               return AltosConvert.pressure_to_altitude(p);
+               if (g == MISSING)
+                       return MISSING;
+               if (a == MISSING)
+                       return MISSING;
+               return a - g;
        }
 
        }
 
-       public double filtered_height() {
-               if (height != MISSING)
-                       return height;
+       public double battery_voltage() { return MISSING; }
 
 
-               double f = filtered_altitude();
-               double g = ground_altitude();
-               if (f == MISSING || g == MISSING)
-                       return MISSING;
-               return f - g;
-       }
+       public double main_voltage() { return MISSING; }
 
 
-       public double raw_height() {
-               double r = raw_altitude();
-               double g = ground_altitude();
+       public double drogue_voltage() { return MISSING; }
 
 
-               if (r == MISSING || g == MISSING)
-                       return height;
-               return r - g;
-       }
+       public double temperature() { return MISSING; }
+       
+       public AltosIMU imu() { return null; }
+
+       public AltosMag mag() { return null; }
 
        public String state() {
                return AltosLib.state_name(state);
 
        public String state() {
                return AltosLib.state_name(state);
@@ -164,12 +136,12 @@ public class AltosRecord implements Comparable <AltosRecord>, Cloneable {
                status = old.status;
                state = old.state;
                tick = old.tick;
                status = old.status;
                state = old.state;
                tick = old.tick;
-               acceleration = old.acceleration;
-               speed = old.speed;
-               height = old.height;
                gps = new AltosGPS(old.gps);
                new_gps = old.new_gps;
                companion = old.companion;
                gps = new AltosGPS(old.gps);
                new_gps = old.new_gps;
                companion = old.companion;
+               kalman_acceleration = old.kalman_acceleration;
+               kalman_speed = old.kalman_speed;
+               kalman_height = old.kalman_height;
        }
 
        public AltosRecord clone() {
        }
 
        public AltosRecord clone() {
@@ -192,11 +164,12 @@ public class AltosRecord implements Comparable <AltosRecord>, Cloneable {
                status = 0;
                state = AltosLib.ao_flight_startup;
                tick = 0;
                status = 0;
                state = AltosLib.ao_flight_startup;
                tick = 0;
-               acceleration = MISSING;
-               speed = MISSING;
-               height = MISSING;
                gps = new AltosGPS();
                new_gps = false;
                companion = null;
                gps = new AltosGPS();
                new_gps = false;
                companion = null;
+
+               kalman_acceleration = MISSING;
+               kalman_speed = MISSING;
+               kalman_height = MISSING;
        }
 }
        }
 }
index 63b37f82c2c953965e7610dff47d20f5e451dec2..9f5292346a61e773aee88f2aa22e290fda86590f 100644 (file)
@@ -19,6 +19,7 @@ package org.altusmetrum.AltosLib;
 
 public class AltosRecordMM extends AltosRecord {
 
 
 public class AltosRecordMM extends AltosRecord {
 
+       /* Sensor values */
        public int      accel;
        public int      pres;
        public int      temp;
        public int      accel;
        public int      pres;
        public int      temp;
@@ -45,16 +46,12 @@ public class AltosRecordMM extends AltosRecord {
                return raw / 4095.0;
        }
 
                return raw / 4095.0;
        }
 
-       public double raw_pressure() {
+       public double pressure() {
                if (pres != MISSING)
                        return pres;
                return MISSING;
        }
 
                if (pres != MISSING)
                        return pres;
                return MISSING;
        }
 
-       public double filtered_pressure() {
-               return raw_pressure();
-       }
-
        public double ground_pressure() {
                if (ground_pres != MISSING)
                        return ground_pres;
        public double ground_pressure() {
                if (ground_pres != MISSING)
                        return ground_pres;
@@ -98,9 +95,6 @@ public class AltosRecordMM extends AltosRecord {
        }
 
        public double acceleration() {
        }
 
        public double acceleration() {
-               if (acceleration != MISSING)
-                       return acceleration;
-
                if (ground_accel == MISSING || accel == MISSING)
                        return MISSING;
 
                if (ground_accel == MISSING || accel == MISSING)
                        return MISSING;
 
@@ -110,14 +104,6 @@ public class AltosRecordMM extends AltosRecord {
                return (ground_accel - accel) / accel_counts_per_mss();
        }
 
                return (ground_accel - accel) / accel_counts_per_mss();
        }
 
-       public double accel_speed() {
-               if (speed != MISSING)
-                       return speed;
-               if (flight_vel == MISSING)
-                       return MISSING;
-               return flight_vel / (accel_counts_per_mss() * 100.0);
-       }
-
        public void copy (AltosRecordMM old) {
                super.copy(old);
 
        public void copy (AltosRecordMM old) {
                super.copy(old);
 
index 37accef60289cd8d2518d4217c5d9b22403cae26..9530be31fc4f26579cfb672654a6551b1b08d2bf 100644 (file)
@@ -18,6 +18,8 @@
 package org.altusmetrum.AltosLib;
 
 public class AltosRecordTM extends AltosRecord {
 package org.altusmetrum.AltosLib;
 
 public class AltosRecordTM extends AltosRecord {
+
+       /* Sensor values */
        public int      accel;
        public int      pres;
        public int      temp;
        public int      accel;
        public int      pres;
        public int      temp;
@@ -57,18 +59,12 @@ public class AltosRecordTM extends AltosRecord {
                return ((count / 16.0) / 2047.0 + 0.095) / 0.009 * 1000.0;
        }
 
                return ((count / 16.0) / 2047.0 + 0.095) / 0.009 * 1000.0;
        }
 
-       public double raw_pressure() {
+       public double pressure() {
                if (pres == MISSING)
                        return MISSING;
                return barometer_to_pressure(pres);
        }
 
                if (pres == MISSING)
                        return MISSING;
                return barometer_to_pressure(pres);
        }
 
-       public double filtered_pressure() {
-               if (flight_pres == MISSING)
-                       return MISSING;
-               return barometer_to_pressure(flight_pres);
-       }
-
        public double ground_pressure() {
                if (ground_pres == MISSING)
                        return MISSING;
        public double ground_pressure() {
                if (ground_pres == MISSING)
                        return MISSING;
@@ -121,22 +117,11 @@ public class AltosRecordTM extends AltosRecord {
        }
 
        public double acceleration() {
        }
 
        public double acceleration() {
-               if (acceleration != MISSING)
-                       return acceleration;
-
                if (ground_accel == MISSING || accel == MISSING)
                        return MISSING;
                return (ground_accel - accel) / accel_counts_per_mss();
        }
 
                if (ground_accel == MISSING || accel == MISSING)
                        return MISSING;
                return (ground_accel - accel) / accel_counts_per_mss();
        }
 
-       public double accel_speed() {
-               if (speed != MISSING)
-                       return speed;
-               if (flight_vel == MISSING)
-                       return MISSING;
-               return flight_vel / (accel_counts_per_mss() * 100.0);
-       }
-
        public void copy(AltosRecordTM old) {
                super.copy(old);
 
        public void copy(AltosRecordTM old) {
                super.copy(old);
 
index 2e4d8870e12684d5f6aa3ef6764f1338492f9281..f28dd1c6609f24070b7ba0fa4ce4e5f8f60205ed 100644 (file)
@@ -40,17 +40,17 @@ public class AltosState {
        public double   ground_altitude;
        public double   altitude;
        public double   height;
        public double   ground_altitude;
        public double   altitude;
        public double   height;
-       public double   speed;
        public double   acceleration;
        public double   battery;
        public double   temperature;
        public double   main_sense;
        public double   drogue_sense;
        public double   acceleration;
        public double   battery;
        public double   temperature;
        public double   main_sense;
        public double   drogue_sense;
+       public double   accel_speed;
        public double   baro_speed;
 
        public double   max_height;
        public double   max_acceleration;
        public double   baro_speed;
 
        public double   max_height;
        public double   max_acceleration;
-       public double   max_speed;
+       public double   max_accel_speed;
        public double   max_baro_speed;
 
        public AltosGPS gps;
        public double   max_baro_speed;
 
        public AltosGPS gps;
@@ -76,20 +76,39 @@ public class AltosState {
        public int      speak_tick;
        public double   speak_altitude;
 
        public int      speak_tick;
        public double   speak_altitude;
 
-       public void init (AltosRecord cur, AltosState prev_state) {
-               //int           i;
-               //AltosRecord prev;
+       public double speed() {
+               if (ascent)
+                       return accel_speed;
+               else
+                       return baro_speed;
+       }
+
+       public double max_speed() {
+               if (max_accel_speed != 0)
+                       return max_accel_speed;
+               return max_baro_speed;
+       }
 
 
+       public void init (AltosRecord cur, AltosState prev_state) {
                data = cur;
 
                ground_altitude = data.ground_altitude();
                data = cur;
 
                ground_altitude = data.ground_altitude();
-               altitude = data.raw_altitude();
-               height = data.filtered_height();
+
+               altitude = data.altitude();
+
+               if (data.kalman_height != AltosRecord.MISSING)
+                       height = data.kalman_height;
+               else {
+                       if (prev_state != null)
+                               height = (prev_state.height * 15 + altitude - ground_altitude) / 16.0;
+               }
 
                report_time = System.currentTimeMillis();
 
 
                report_time = System.currentTimeMillis();
 
-               acceleration = data.acceleration();
-               speed = data.accel_speed();
+               if (data.kalman_acceleration != AltosRecord.MISSING)
+                       acceleration = data.kalman_acceleration;
+               else
+                       acceleration = data.acceleration();
                temperature = data.temperature();
                drogue_sense = data.drogue_voltage();
                main_sense = data.main_voltage();
                temperature = data.temperature();
                drogue_sense = data.drogue_voltage();
                main_sense = data.main_voltage();
@@ -108,7 +127,7 @@ public class AltosState {
                        pad_alt = prev_state.pad_alt;
                        max_height = prev_state.max_height;
                        max_acceleration = prev_state.max_acceleration;
                        pad_alt = prev_state.pad_alt;
                        max_height = prev_state.max_height;
                        max_acceleration = prev_state.max_acceleration;
-                       max_speed = prev_state.max_speed;
+                       max_accel_speed = prev_state.max_accel_speed;
                        max_baro_speed = prev_state.max_baro_speed;
                        imu = prev_state.imu;
                        mag = prev_state.mag;
                        max_baro_speed = prev_state.max_baro_speed;
                        imu = prev_state.imu;
                        mag = prev_state.mag;
@@ -119,23 +138,39 @@ public class AltosState {
 
                        time_change = (tick - prev_state.tick) / 100.0;
 
 
                        time_change = (tick - prev_state.tick) / 100.0;
 
-                       /* compute barometric speed */
+                       if (data.kalman_speed != AltosRecord.MISSING) {
+                               baro_speed = accel_speed = data.kalman_speed;
+                       } else {
+                               /* compute barometric speed */
 
 
-                       double height_change = height - prev_state.height;
-                       if (data.speed != AltosRecord.MISSING)
-                               baro_speed = data.speed;
-                       else {
+                               double height_change = height - prev_state.height;
                                if (time_change > 0)
                                        baro_speed = (prev_state.baro_speed * 3 + (height_change / time_change)) / 4.0;
                                else
                                        baro_speed = prev_state.baro_speed;
                                if (time_change > 0)
                                        baro_speed = (prev_state.baro_speed * 3 + (height_change / time_change)) / 4.0;
                                else
                                        baro_speed = prev_state.baro_speed;
+
+                               if (acceleration == AltosRecord.MISSING) {
+                                       /* Fill in mising acceleration value */
+                                       accel_speed = baro_speed;
+                                       if (time_change > 0)
+                                               acceleration = (accel_speed - prev_state.accel_speed) / time_change;
+                                       else
+                                               acceleration = prev_state.acceleration;
+                               } else {
+                                       /* compute accelerometer speed */
+                                       accel_speed = prev_state.accel_speed + acceleration * time_change;
+                               }
                        }
                        }
+
                } else {
                        npad = 0;
                        ngps = 0;
                        gps = null;
                        baro_speed = 0;
                } else {
                        npad = 0;
                        ngps = 0;
                        gps = null;
                        baro_speed = 0;
+                       accel_speed = 0;
                        time_change = 0;
                        time_change = 0;
+                       if (acceleration == AltosRecord.MISSING)
+                               acceleration = 0;
                }
 
                time = tick / 100.0;
                }
 
                time = tick / 100.0;
@@ -180,8 +215,8 @@ public class AltosState {
                /* Only look at accelerometer data under boost */
                if (boost && acceleration > max_acceleration && acceleration != AltosRecord.MISSING)
                        max_acceleration = acceleration;
                /* Only look at accelerometer data under boost */
                if (boost && acceleration > max_acceleration && acceleration != AltosRecord.MISSING)
                        max_acceleration = acceleration;
-               if (boost && speed > max_speed && speed != AltosRecord.MISSING)
-                       max_speed = speed;
+               if (boost && accel_speed > max_accel_speed && accel_speed != AltosRecord.MISSING)
+                       max_accel_speed = accel_speed;
                if (boost && baro_speed > max_baro_speed && baro_speed != AltosRecord.MISSING)
                        max_baro_speed = baro_speed;
 
                if (boost && baro_speed > max_baro_speed && baro_speed != AltosRecord.MISSING)
                        max_baro_speed = baro_speed;
 
index 211760691e23668b3b52a0eda839861e10cbb61d..431897945549abdb521fcddca3f29497e64fc9dd 100644 (file)
@@ -257,9 +257,9 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord {
                record.accel_minus_g = map.get_int(AO_TELEM_CAL_ACCEL_MINUS, AltosRecord.MISSING);
 
                /* flight computer values */
                record.accel_minus_g = map.get_int(AO_TELEM_CAL_ACCEL_MINUS, AltosRecord.MISSING);
 
                /* flight computer values */
-               record.acceleration = map.get_double(AO_TELEM_KALMAN_ACCEL, AltosRecord.MISSING, 1/16.0);
-               record.speed = map.get_double(AO_TELEM_KALMAN_SPEED, AltosRecord.MISSING, 1/16.0);
-               record.height = map.get_int(AO_TELEM_KALMAN_HEIGHT, AltosRecord.MISSING);
+               record.kalman_acceleration = map.get_double(AO_TELEM_KALMAN_ACCEL, AltosRecord.MISSING, 1/16.0);
+               record.kalman_speed = map.get_double(AO_TELEM_KALMAN_SPEED, AltosRecord.MISSING, 1/16.0);
+               record.kalman_height = map.get_int(AO_TELEM_KALMAN_HEIGHT, AltosRecord.MISSING);
 
                record.flight_accel = map.get_int(AO_TELEM_ADHOC_ACCEL, AltosRecord.MISSING);
                record.flight_vel = map.get_int(AO_TELEM_ADHOC_SPEED, AltosRecord.MISSING);
 
                record.flight_accel = map.get_int(AO_TELEM_ADHOC_ACCEL, AltosRecord.MISSING);
                record.flight_vel = map.get_int(AO_TELEM_ADHOC_SPEED, AltosRecord.MISSING);
@@ -334,9 +334,9 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord {
 
                /* Old TeleDongle code with kalman-reporting TeleMetrum code */
                if ((record.flight_vel & 0xffff0000) == 0x80000000) {
 
                /* Old TeleDongle code with kalman-reporting TeleMetrum code */
                if ((record.flight_vel & 0xffff0000) == 0x80000000) {
-                       record.speed = ((short) record.flight_vel) / 16.0;
-                       record.acceleration = record.flight_accel / 16.0;
-                       record.height = record.flight_pres;
+                       record.kalman_speed = ((short) record.flight_vel) / 16.0;
+                       record.kalman_acceleration = record.flight_accel / 16.0;
+                       record.kalman_height = record.flight_pres;
                        record.flight_vel = AltosRecord.MISSING;
                        record.flight_pres = AltosRecord.MISSING;
                        record.flight_accel = AltosRecord.MISSING;
                        record.flight_vel = AltosRecord.MISSING;
                        record.flight_pres = AltosRecord.MISSING;
                        record.flight_accel = AltosRecord.MISSING;
@@ -455,9 +455,9 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord {
                record.accel_minus_g = int16(19);
 
                if (uint16(11) == 0x8000) {
                record.accel_minus_g = int16(19);
 
                if (uint16(11) == 0x8000) {
-                       record.acceleration = int16(5);
-                       record.speed = int16(9);
-                       record.height = int16(13);
+                       record.kalman_acceleration = int16(5);
+                       record.kalman_speed = int16(9);
+                       record.kalman_height = int16(13);
                        record.flight_accel = AltosRecord.MISSING;
                        record.flight_vel = AltosRecord.MISSING;
                        record.flight_pres = AltosRecord.MISSING;
                        record.flight_accel = AltosRecord.MISSING;
                        record.flight_vel = AltosRecord.MISSING;
                        record.flight_pres = AltosRecord.MISSING;
@@ -465,9 +465,9 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord {
                        record.flight_accel = int16(5);
                        record.flight_vel = uint32(9);
                        record.flight_pres = int16(13);
                        record.flight_accel = int16(5);
                        record.flight_vel = uint32(9);
                        record.flight_pres = int16(13);
-                       record.acceleration = AltosRecord.MISSING;
-                       record.speed = AltosRecord.MISSING;
-                       record.height = AltosRecord.MISSING;
+                       record.kalman_acceleration = AltosRecord.MISSING;
+                       record.kalman_speed = AltosRecord.MISSING;
+                       record.kalman_height = AltosRecord.MISSING;
                }
 
                record.gps = null;
                }
 
                record.gps = null;
index 8f55d238a3bae3689b96c7b816b8fac4efc731e3..16a7b80cc0f037a12e1cfc62c3f18c2a8982820a 100644 (file)
@@ -83,9 +83,9 @@ public class AltosTelemetryRecordMegaData extends AltosTelemetryRecordRaw {
                next.accel_plus_g = accel_plus_g;
                next.accel_minus_g = accel_minus_g;
 
                next.accel_plus_g = accel_plus_g;
                next.accel_minus_g = accel_minus_g;
 
-               next.acceleration = acceleration / 16.0;
-               next.speed = speed / 16.0;
-               next.height = height;
+               next.kalman_acceleration = acceleration / 16.0;
+               next.kalman_speed = speed / 16.0;
+               next.kalman_height = height;
 
                next.seen |= AltosRecord.seen_flight | AltosRecord.seen_temp_volt;
 
 
                next.seen |= AltosRecord.seen_flight | AltosRecord.seen_temp_volt;
 
index fbb373d54dcdfb9beaba3e3610150b255cd47ac2..c21da6fc1cbe26f87eb480f0ecf6fce9477cc6f0 100644 (file)
@@ -65,7 +65,7 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord {
                if (previous != null)
                        next = previous.clone();
                else
                if (previous != null)
                        next = previous.clone();
                else
-                       next = new AltosRecord();
+                       next = new AltosRecordNone();
                next.serial = serial;
                next.tick = tick;
                return next;
                next.serial = serial;
                next.tick = tick;
                return next;
index 319a91b39d78df1195a9f64860973170bb3d79ee..f1fc156c484717e37f24bbf31ec7c336336c1cb3 100644 (file)
@@ -86,9 +86,9 @@ public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw {
                        next.main = AltosRecord.MISSING;
                }
 
                        next.main = AltosRecord.MISSING;
                }
 
-               next.acceleration = acceleration / 16.0;
-               next.speed = speed / 16.0;
-               next.height = height;
+               next.kalman_acceleration = acceleration / 16.0;
+               next.kalman_speed = speed / 16.0;
+               next.kalman_height = height;
 
                next.ground_pres = ground_pres;
                if (type == packet_type_TM_sensor) {
 
                next.ground_pres = ground_pres;
                if (type == packet_type_TM_sensor) {
index b56d8af1e312a6af46a73683ad9ba746c8e1e2a6..f04c10c6aa7392798efe7143a3ee294d3be4e7d7 100644 (file)
@@ -46,6 +46,7 @@ AltosLib_JAVA = \
        $(SRC)/AltosRecordCompanion.java \
        $(SRC)/AltosRecordIterable.java \
        $(SRC)/AltosRecord.java \
        $(SRC)/AltosRecordCompanion.java \
        $(SRC)/AltosRecordIterable.java \
        $(SRC)/AltosRecord.java \
+       $(SRC)/AltosRecordNone.java \
        $(SRC)/AltosRecordTM.java \
        $(SRC)/AltosRecordMM.java \
        $(SRC)/AltosReplayReader.java \
        $(SRC)/AltosRecordTM.java \
        $(SRC)/AltosRecordMM.java \
        $(SRC)/AltosReplayReader.java \
index 007c74ec639694ea46aeda47d960e1886b3d06be..a05c44041ba2a91a4b681c9ceb3b7ad3080265b7 100644 (file)
@@ -251,7 +251,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
 
        class Speed extends AscentValueHold {
                void show (AltosState state, int crc_errors) {
 
        class Speed extends AscentValueHold {
                void show (AltosState state, int crc_errors) {
-                       double speed = state.speed;
+                       double speed = state.accel_speed;
                        if (!state.ascent)
                                speed = state.baro_speed;
                        show(AltosConvert.speed, speed);
                        if (!state.ascent)
                                speed = state.baro_speed;
                        show(AltosConvert.speed, speed);
index f8cc1ed6b1d12240a34ee74a7b28bfbc1018564c..1c929a7cd9d6a80946de1bc6792eb8528328c890 100644 (file)
@@ -128,10 +128,10 @@ public class AltosCSV implements AltosWriter {
        void write_basic(AltosRecord record) {
                out.printf("%8.2f,%10.2f,%8.2f,%8.2f,%8.2f,%8.2f,%5.1f,%5.2f,%5.2f,%5.2f",
                           record.acceleration(),
        void write_basic(AltosRecord record) {
                out.printf("%8.2f,%10.2f,%8.2f,%8.2f,%8.2f,%8.2f,%5.1f,%5.2f,%5.2f,%5.2f",
                           record.acceleration(),
-                          record.raw_pressure(),
-                          record.raw_altitude(),
-                          record.raw_height(),
-                          record.accel_speed(),
+                          record.pressure(),
+                          record.altitude(),
+                          record.height(),
+                          state.accel_speed,
                           state.baro_speed,
                           record.temperature(),
                           record.battery_voltage(),
                           state.baro_speed,
                           record.temperature(),
                           record.battery_voltage(),
index 5e07732026aeb2562b33eabeecfe7884b172c65c..4956e9f3c61eec2662056f746289c52db4abeb8a 100644 (file)
@@ -16,11 +16,8 @@ interface AltosDataPoint {
     String state_name();
 
     double acceleration();
     String state_name();
 
     double acceleration();
-    double pressure();
-    double altitude();
     double height();
     double height();
-    double accel_speed();
-    double baro_speed();
+    double speed();
     double temperature();
     double battery_voltage();
     double drogue_voltage();
     double temperature();
     double battery_voltage();
     double drogue_voltage();
index 2316cf97e1e36bcf447869b4dae248c4a9ab0999..88df081faeee4584d12113220eeaebbf443c1cd1 100644 (file)
@@ -12,7 +12,6 @@ import org.altusmetrum.AltosLib.*;
 class AltosDataPointReader implements Iterable<AltosDataPoint> {
     Iterator<AltosRecord> iter;
     AltosState state;
 class AltosDataPointReader implements Iterable<AltosDataPoint> {
     Iterator<AltosRecord> iter;
     AltosState state;
-    AltosRecord record;
     boolean has_gps;
     boolean has_accel;
     boolean has_ignite;
     boolean has_gps;
     boolean has_accel;
     boolean has_ignite;
@@ -22,7 +21,7 @@ class AltosDataPointReader implements Iterable<AltosDataPoint> {
     public AltosDataPointReader(AltosRecordIterable reader) {
         this.iter = reader.iterator();
         this.state = null;
     public AltosDataPointReader(AltosRecordIterable reader) {
         this.iter = reader.iterator();
         this.state = null;
-       has_accel = reader.has_accel();
+       has_accel = true;
        has_gps = reader.has_gps();
        has_ignite = reader.has_ignite();
     }
        has_gps = reader.has_gps();
        has_ignite = reader.has_ignite();
     }
@@ -30,35 +29,31 @@ class AltosDataPointReader implements Iterable<AltosDataPoint> {
     private void read_next_record() 
         throws NoSuchElementException
     {
     private void read_next_record() 
         throws NoSuchElementException
     {
-        record = iter.next();
-        state = new AltosState(record, state);
+        state = new AltosState(iter.next(), state);
     }
 
     private AltosDataPoint current_dp() {
     }
 
     private AltosDataPoint current_dp() {
-        assert this.record != null;
+        assert this.state != null;
         
         return new AltosDataPoint() {
         
         return new AltosDataPoint() {
-            public int version() { return record.version; }
-            public int serial() { return record.serial; }
-            public int flight() { return record.flight; }
-            public String callsign() { return record.callsign; }
-            public double time() { return record.time; }
-            public double rssi() { return record.rssi; }
+            public int version() { return state.data.version; }
+            public int serial() { return state.data.serial; }
+            public int flight() { return state.data.flight; }
+            public String callsign() { return state.data.callsign; }
+            public double time() { return state.data.time; }
+            public double rssi() { return state.data.rssi; }
 
 
-            public int state() { return record.state; }
-            public String state_name() { return record.state(); }
+            public int state() { return state.state; }
+            public String state_name() { return state.data.state(); }
 
 
-            public double acceleration() { return record.acceleration(); }
-            public double pressure() { return record.raw_pressure(); }
-            public double altitude() { return record.raw_altitude(); }
-           public double height() { return record.raw_height(); }
-            public double accel_speed() { return record.accel_speed(); }
-            public double baro_speed() { return state.baro_speed; }
-            public double temperature() { return record.temperature(); }
-            public double battery_voltage() { return record.battery_voltage(); }
-            public double drogue_voltage() { return record.drogue_voltage(); }
-            public double main_voltage() { return record.main_voltage(); }
-           public boolean has_accel() { return has_accel; }
+            public double acceleration() { return state.acceleration; }
+           public double height() { return state.height; }
+           public double speed() { return state.speed(); }
+            public double temperature() { return state.temperature; }
+            public double battery_voltage() { return state.battery; }
+            public double drogue_voltage() { return state.drogue_sense; }
+            public double main_voltage() { return state.main_sense; }
+           public boolean has_accel() { return true; } // return state.acceleration != AltosRecord.MISSING; }
         };
     }
 
         };
     }
 
@@ -68,14 +63,14 @@ class AltosDataPointReader implements Iterable<AltosDataPoint> {
                 throw new UnsupportedOperationException(); 
             }
             public boolean hasNext() {
                 throw new UnsupportedOperationException(); 
             }
             public boolean hasNext() {
-               if (record != null && record.state == Altos.ao_flight_landed)
+               if (state != null && state.state == Altos.ao_flight_landed)
                    return false;
                 return iter.hasNext();
             }
             public AltosDataPoint next() {
                do {
                    read_next_record();
                    return false;
                 return iter.hasNext();
             }
             public AltosDataPoint next() {
                do {
                    read_next_record();
-               } while (record.time < -1.0 && hasNext());
+               } while (state.data.time < -1.0 && hasNext());
                 return current_dp();
             }
         };
                 return current_dp();
             }
         };
index a71cdc10c0fc97f2305951365294cc165f1d3580..2ea7cbfa7058a219e0d8e8a5b4e7d999bc051e78 100644 (file)
@@ -256,7 +256,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
 
        class Speed extends DescentValue {
                void show (AltosState state, int crc_errors) {
 
        class Speed extends DescentValue {
                void show (AltosState state, int crc_errors) {
-                       double speed = state.speed;
+                       double speed = state.accel_speed;
                        if (!state.ascent)
                                speed = state.baro_speed;
                        show(AltosConvert.speed, speed);
                        if (!state.ascent)
                                speed = state.baro_speed;
                        show(AltosConvert.speed, speed);
index f7a1d03eb2ad7b1bfa0f9e8f6d6bc667eef23ddc..1ba70c7efb6cebc245692caf3883297c470cf2d3 100644 (file)
@@ -197,7 +197,7 @@ public class AltosDisplayThread extends Thread {
                        if ((old_state == null || old_state.state <= Altos.ao_flight_boost) &&
                            state.state > Altos.ao_flight_boost) {
                                voice.speak("max speed: %s.",
                        if ((old_state == null || old_state.state <= Altos.ao_flight_boost) &&
                            state.state > Altos.ao_flight_boost) {
                                voice.speak("max speed: %s.",
-                                           AltosConvert.speed.say_units(state.max_speed + 0.5));
+                                           AltosConvert.speed.say_units(state.max_accel_speed + 0.5));
                                ret = true;
                        } else if ((old_state == null || old_state.state < Altos.ao_flight_drogue) &&
                                   state.state >= Altos.ao_flight_drogue) {
                                ret = true;
                        } else if ((old_state == null || old_state.state < Altos.ao_flight_drogue) &&
                                   state.state >= Altos.ao_flight_drogue) {
index e48cb608189fa9d90f2fa2e4efbd60f21d0875fa..1653ca5708fef79092d0df7e6a1a1ddd8109f908 100644 (file)
@@ -24,7 +24,7 @@ public class AltosFlightStats {
        double          max_height;
        double          max_speed;
        double          max_acceleration;
        double          max_height;
        double          max_speed;
        double          max_acceleration;
-       double[]        state_speed = new double[Altos.ao_flight_invalid + 1];
+       double[]        state_accel_speed = new double[Altos.ao_flight_invalid + 1];
        double[]        state_baro_speed = new double[Altos.ao_flight_invalid + 1];
        double[]        state_accel = new double[Altos.ao_flight_invalid + 1];
        int[]           state_count = new int[Altos.ao_flight_invalid + 1];
        double[]        state_baro_speed = new double[Altos.ao_flight_invalid + 1];
        double[]        state_accel = new double[Altos.ao_flight_invalid + 1];
        int[]           state_count = new int[Altos.ao_flight_invalid + 1];
@@ -123,7 +123,7 @@ public class AltosFlightStats {
                                        }
                                }
                                state_accel[state.state] += state.acceleration;
                                        }
                                }
                                state_accel[state.state] += state.acceleration;
-                               state_speed[state.state] += state.speed;
+                               state_accel_speed[state.state] += state.accel_speed;
                                state_baro_speed[state.state] += state.baro_speed;
                                state_count[state.state]++;
                                if (state_start[state.state] == 0.0)
                                state_baro_speed[state.state] += state.baro_speed;
                                state_count[state.state]++;
                                if (state_start[state.state] == 0.0)
@@ -131,8 +131,8 @@ public class AltosFlightStats {
                                if (state_end[state.state] < state.time)
                                        state_end[state.state] = state.time;
                                max_height = state.max_height;
                                if (state_end[state.state] < state.time)
                                        state_end[state.state] = state.time;
                                max_height = state.max_height;
-                               if (state.max_speed != 0)
-                                       max_speed = state.max_speed;
+                               if (state.max_accel_speed != 0)
+                                       max_speed = state.max_accel_speed;
                                else
                                        max_speed = state.max_baro_speed;
                                max_acceleration = state.max_acceleration;
                                else
                                        max_speed = state.max_baro_speed;
                                max_acceleration = state.max_acceleration;
@@ -140,7 +140,7 @@ public class AltosFlightStats {
                }
                for (int s = Altos.ao_flight_startup; s <= Altos.ao_flight_landed; s++) {
                        if (state_count[s] > 0) {
                }
                for (int s = Altos.ao_flight_startup; s <= Altos.ao_flight_landed; s++) {
                        if (state_count[s] > 0) {
-                               state_speed[s] /= state_count[s];
+                               state_accel_speed[s] /= state_count[s];
                                state_baro_speed[s] /= state_count[s];
                                state_accel[s] /= state_count[s];
                        }
                                state_baro_speed[s] /= state_count[s];
                                state_accel[s] /= state_count[s];
                        }
index cb8e3d2072595d0ef0dcd6f8659fc7e7abb058e3..f59f70bab47781daf0783e747875e2ec45542152 100644 (file)
@@ -40,12 +40,7 @@ public class AltosGraphUI extends AltosFrame
         AltosGraphTime.Element speed =
                new AltosGraphTime.TimeSeries(String.format("Speed (%s)", AltosConvert.speed.show_units()), "Vertical Speed", green) { 
                 public void gotTimeData(double time, AltosDataPoint d) {
         AltosGraphTime.Element speed =
                new AltosGraphTime.TimeSeries(String.format("Speed (%s)", AltosConvert.speed.show_units()), "Vertical Speed", green) { 
                 public void gotTimeData(double time, AltosDataPoint d) {
-                   double      speed;
-                   if (d.state() < Altos.ao_flight_drogue && d.has_accel()) {
-                       speed = d.accel_speed();
-                    } else {
-                       speed = d.baro_speed();
-                    }
+                   double      speed = d.speed();
                    if (speed != AltosRecord.MISSING)
                            series.add(time, AltosConvert.speed.value(speed));
                 }
                    if (speed != AltosRecord.MISSING)
                            series.add(time, AltosConvert.speed.value(speed));
                 }
index 86e02ab1ddcbe07733f6063fefc44086f6d4fdc1..11d1b0c1942bd61911482a46a7141485df8975e1 100644 (file)
@@ -114,8 +114,8 @@ public class AltosInfoTable extends JTable {
                info_add_row(0, "Max height", "%6.0f    m", state.max_height);
                info_add_row(0, "Acceleration", "%8.1f  m/s²", state.acceleration);
                info_add_row(0, "Max acceleration", "%8.1f  m/s²", state.max_acceleration);
                info_add_row(0, "Max height", "%6.0f    m", state.max_height);
                info_add_row(0, "Acceleration", "%8.1f  m/s²", state.acceleration);
                info_add_row(0, "Max acceleration", "%8.1f  m/s²", state.max_acceleration);
-               info_add_row(0, "Speed", "%8.1f  m/s", state.ascent ? state.speed : state.baro_speed);
-               info_add_row(0, "Max Speed", "%8.1f  m/s", state.max_speed);
+               info_add_row(0, "Speed", "%8.1f  m/s", state.speed());
+               info_add_row(0, "Max Speed", "%8.1f  m/s", state.max_accel_speed);
                info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
                info_add_row(0, "Battery", "%9.2f V", state.battery);
                if (state.drogue_sense != AltosRecord.MISSING)
                info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
                info_add_row(0, "Battery", "%9.2f V", state.battery);
                if (state.drogue_sense != AltosRecord.MISSING)
index 57339b1962fd8dd87368817eee9680e361f64721..281638bf3e92c0b14b200e58a854677e9a173b33 100644 (file)
@@ -109,7 +109,7 @@ public class AltosKML implements AltosWriter {
                AltosGPS        gps = record.gps;
                out.printf(kml_coord_fmt,
                           gps.lon, gps.lat,
                AltosGPS        gps = record.gps;
                out.printf(kml_coord_fmt,
                           gps.lon, gps.lat,
-                          record.filtered_altitude(), (double) gps.alt,
+                          record.altitude(), (double) gps.alt,
                           record.time, gps.nsat);
        }
 
                           record.time, gps.nsat);
        }
 
index 57c2d476989e9b5b50d1ff2701ea85d59a2d9ca1..0111a08a0df6a596e8b0d32434a15a6e7e60d715 100644 (file)
@@ -173,7 +173,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
 
        class Speed extends LandedValue {
                void show (AltosState state, int crc_errors) {
 
        class Speed extends LandedValue {
                void show (AltosState state, int crc_errors) {
-                       show(AltosConvert.speed, state.max_speed);
+                       show(AltosConvert.speed, state.max_speed());
                }
                public Speed (GridBagLayout layout, int y) {
                        super (layout, y, "Maximum Speed");
                }
                public Speed (GridBagLayout layout, int y) {
                        super (layout, y, "Maximum Speed");