altoslib: Add 'motor_pressure' data value
authorKeith Packard <keithp@keithp.com>
Mon, 12 Oct 2020 23:46:28 +0000 (16:46 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 22 Oct 2020 04:33:59 +0000 (21:33 -0700)
This value tracks the internal pressure of a motor in Pa.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosDataListener.java
altoslib/AltosEepromDownload.java
altoslib/AltosFlightSeries.java
altoslib/AltosReplayReader.java
altoslib/AltosState.java
altoslib/AltosTelemetryFile.java

index ad76f833456fc0985572774f097134776bbe486d..db2c14faba1e11f17b735b65388c358679273c4c 100644 (file)
@@ -140,6 +140,7 @@ public abstract class AltosDataListener {
        public abstract void set_igniter_voltage(double[] voltage);
        public abstract void set_pyro_fired(int pyro_mask);
        public abstract void set_companion(AltosCompanion companion);
+       public abstract void set_motor_pressure(double motor_pressure);
 
        public AltosDataListener() {
        }
index 8d0738dc941ee0618aa65e8c1b388959b2966ed4..a3c15112318c7cae3c4503ba3ce1d50849190c95 100644 (file)
@@ -71,6 +71,7 @@ class AltosEepromNameData extends AltosDataListener {
        public void set_companion(AltosCompanion companion) { }
        public void set_kalman(double height, double speed, double acceleration) { }
        public void set_orient(double new_orient) { }
+       public void set_motor_pressure(double motor_pressure) { }
 
        public AltosEepromNameData(AltosCalData cal_data) {
                super(cal_data);
index ef4ef4dfc6dcebb8432a5192b793e06b0b650006..38256f0e4ca515d73eadc88c0866b7c7c73e96a0 100644 (file)
@@ -286,11 +286,16 @@ public class AltosFlightSeries extends AltosDataListener {
        }
 
        private void compute_height() {
-               double ground_altitude = cal_data().ground_altitude;
-               if (height_series == null && ground_altitude != AltosLib.MISSING && altitude_series != null) {
-                       height_series = add_series(height_name, AltosConvert.height);
-                       for (AltosTimeValue alt : altitude_series)
-                               height_series.add(alt.time, alt.value - ground_altitude);
+               if (height_series == null) {
+                       double ground_altitude = cal_data().ground_altitude;
+                       if (ground_altitude != AltosLib.MISSING && altitude_series != null) {
+                               height_series = add_series(height_name, AltosConvert.height);
+                               for (AltosTimeValue alt : altitude_series)
+                                       height_series.add(alt.time, alt.value - ground_altitude);
+                       } else if (speed_series != null) {
+                               height_series = add_series(height_name, AltosConvert.height);
+                               speed_series.integrate(height_series);
+                       }
                }
 
                if (gps_height == null && cal_data().gps_pad != null && cal_data().gps_pad.alt != AltosLib.MISSING && gps_altitude != null) {
@@ -401,6 +406,9 @@ public class AltosFlightSeries extends AltosDataListener {
                if (cal_data.accel_zero_across == AltosLib.MISSING)
                        return;
 
+               if (cal_data.gyro_zero_roll == AltosLib.MISSING)
+                       return;
+
                AltosRotation rotation = new AltosRotation(accel_ground_across,
                                                           accel_ground_through,
                                                           accel_ground_along,
@@ -758,6 +766,16 @@ public class AltosFlightSeries extends AltosDataListener {
        public void set_companion(AltosCompanion companion) {
        }
 
+       public static final String motor_pressure_name = "Motor Pressure";
+
+       public AltosTimeSeries motor_pressure_series;
+
+       public void set_motor_pressure(double motor_pressure) {
+               if (motor_pressure_series == null)
+                       motor_pressure_series = add_series(motor_pressure_name, AltosConvert.pressure);
+               motor_pressure_series.add(time(), motor_pressure);
+       }
+
        public void finish() {
                compute_orient();
                if (speed_series == null) {
index 07f62427a3861ac92de1f433b9755e859d3e4f42..bcabf750c2b424fccfad3f34de8cb8b5d25e58d8 100644 (file)
@@ -86,6 +86,7 @@ class AltosReplay extends AltosDataListener implements Runnable {
        public void set_igniter_voltage(double[] voltage) { state.set_igniter_voltage(voltage); }
        public void set_pyro_fired(int pyro_mask) { state.set_pyro_fired(pyro_mask); }
        public void set_companion(AltosCompanion companion) { state.set_companion(companion); }
+       public void set_motor_pressure(double motor_pressure) { state.set_motor_pressure(motor_pressure); }
 
        public void run () {
                /* Run the flight */
index fc9727481201162bf636e6c4324b2d3140458310..28fdbb244c3afffd6da9e530da4c84fce71bafec 100644 (file)
@@ -703,6 +703,8 @@ public class AltosState extends AltosDataListener {
 
        public int      pyro_fired;
 
+       public double   motor_pressure;
+
        public void set_npad(int npad) {
                this.npad = npad;
                gps_waiting = MIN_PAD_SAMPLES - npad;
@@ -1047,6 +1049,10 @@ public class AltosState extends AltosDataListener {
                this.pyro_fired = fired;
        }
 
+       public void set_motor_pressure(double motor_pressure) {
+               this.motor_pressure = motor_pressure;
+       }
+
        public AltosState() {
                init();
        }
index 052b0fbad247c1af1b52b6134a9eeb839346dfec..6f01f51c180be81d53f54471401a14c328ef23bc 100644 (file)
@@ -49,6 +49,7 @@ class AltosTelemetryNullListener extends AltosDataListener {
        public void set_igniter_voltage(double[] voltage) { }
        public void set_pyro_fired(int pyro_mask) { }
        public void set_companion(AltosCompanion companion) { }
+       public void set_motor_pressure(double motor_pressure) { }
 
        public boolean cal_data_complete() {
                /* All telemetry packets */