add thrust as a graphable time series type
[fw/altos] / altoslib / AltosState.java
index d359d67aa1ca16cbeaa94e69ed57485fd17ffe19..846bda42dd834f454c8dc225de5bc4a42a44643f 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,7 +24,7 @@ package org.altusmetrum.altoslib_11;
 
 import java.io.*;
 
-public class AltosState implements Cloneable, AltosHashable {
+public class AltosState extends AltosFlightListener implements Cloneable {
 
        public static final int set_position = 1;
        public static final int set_gps = 2;
@@ -42,11 +43,9 @@ public class AltosState implements Cloneable, AltosHashable {
        public double   time;
        public double   prev_time;
        public double   time_change;
-       public int      tick;
        private int     prev_tick;
-       public int      boost_tick;
 
-       class AltosValue implements AltosHashable {
+       class AltosValue {
                double  value;
                double  prev_value;
                private double  max_value;
@@ -177,28 +176,6 @@ public class AltosState implements Cloneable, AltosHashable {
                        prev_set_time = set_time;
                }
 
-               public AltosHashSet hashSet() {
-                       AltosHashSet h = new AltosHashSet();
-
-                       h.putDouble("value", value);
-                       h.putDouble("prev_value", prev_value);
-                       h.putDouble("max_value", max_value);
-                       h.putDouble("set_time", set_time);
-                       h.putDouble("prev_set_time", prev_set_time);
-                       return h;
-               }
-
-               AltosValue(AltosHashSet h) {
-                       this();
-                       if (h != null) {
-                               value = h.getDouble("value", value);
-                               prev_value = h.getDouble("prev_value", prev_value);
-                               max_value = h.getDouble("max_value", max_value);
-                               set_time = h.getDouble("set_time", 0);
-                               prev_set_time = h.getDouble("prev_set_time", 0);
-                       }
-               }
-
                AltosValue() {
                        value = AltosLib.MISSING;
                        prev_value = AltosLib.MISSING;
@@ -207,15 +184,9 @@ public class AltosState implements Cloneable, AltosHashable {
 
        }
 
-       AltosValue AltosValue_fromHashSet(AltosHashSet h, AltosValue def) {
-               if (h == null)
-                       return def;
-               return new AltosValue(h);
-       }
-
-       class AltosCValue implements AltosHashable {
+       class AltosCValue {
 
-               class AltosIValue extends AltosValue implements AltosHashable {
+               class AltosIValue extends AltosValue {
                        boolean can_max() {
                                return c_can_max();
                        }
@@ -223,10 +194,6 @@ public class AltosState implements Cloneable, AltosHashable {
                        AltosIValue() {
                                super();
                        }
-
-                       AltosIValue(AltosHashSet h) {
-                               super(h);
-                       }
                };
 
                public AltosIValue      measured;
@@ -315,30 +282,10 @@ public class AltosState implements Cloneable, AltosHashable {
                        computed.finish_update();
                }
 
-               AltosCValue() {
+               public AltosCValue() {
                        measured = new AltosIValue();
                        computed = new AltosIValue();
                }
-
-
-               public AltosHashSet hashSet() {
-                       AltosHashSet h = new AltosHashSet();
-
-                       h.putHashable("measured", measured);
-                       h.putHashable("computed", computed);
-                       return h;
-               }
-
-               AltosCValue(AltosHashSet h) {
-                       measured = new AltosIValue(h.getHash("measured"));
-                       computed = new AltosIValue(h.getHash("computed"));
-               }
-       }
-
-       AltosCValue AltosCValue_fromHashSet(AltosHashSet h, AltosCValue def) {
-               if (h == null)
-                       return def;
-               return new AltosCValue(h);
        }
 
        private int     state;
@@ -390,15 +337,6 @@ public class AltosState implements Cloneable, AltosHashable {
                AltosGpsGroundAltitude() {
                        super();
                }
-
-               AltosGpsGroundAltitude (AltosHashSet h) {
-                       super(h);
-               }
-       }
-
-       AltosGpsGroundAltitude AltosGpsGroundAltitude_fromHashSet(AltosHashSet h, AltosGpsGroundAltitude def) {
-               if (h == null) return def;
-               return new AltosGpsGroundAltitude(h);
        }
 
        private AltosGpsGroundAltitude gps_ground_altitude;
@@ -426,15 +364,6 @@ public class AltosState implements Cloneable, AltosHashable {
                AltosGroundPressure () {
                        super();
                }
-
-               AltosGroundPressure (AltosHashSet h) {
-                       super(h);
-               }
-       }
-
-       AltosGroundPressure AltosGroundPressure_fromHashSet(AltosHashSet h, AltosGroundPressure def) {
-               if (h == null) return def;
-               return new AltosGroundPressure(h);
        }
 
        private AltosGroundPressure ground_pressure;
@@ -447,7 +376,7 @@ public class AltosState implements Cloneable, AltosHashable {
                ground_pressure.set_measured(pressure, time);
        }
 
-       class AltosAltitude extends AltosCValue implements AltosHashable {
+       class AltosAltitude extends AltosCValue {
 
                private void set_speed(AltosValue v) {
                        if (!acceleration.is_measured() || !ascent)
@@ -469,20 +398,11 @@ public class AltosState implements Cloneable, AltosHashable {
                AltosAltitude() {
                        super();
                }
-
-               AltosAltitude (AltosHashSet h) {
-                       super(h);
-               }
-       }
-
-       AltosAltitude AltosAltitude_fromHashSet(AltosHashSet h, AltosAltitude def) {
-               if (h == null) return def;
-               return new AltosAltitude(h);
        }
 
        private AltosAltitude   altitude;
 
-       class AltosGpsAltitude extends AltosValue implements AltosHashable {
+       class AltosGpsAltitude extends AltosValue {
 
                private void set_gps_height() {
                        double  a = value();
@@ -502,15 +422,6 @@ public class AltosState implements Cloneable, AltosHashable {
                AltosGpsAltitude() {
                        super();
                }
-
-               AltosGpsAltitude (AltosHashSet h) {
-                       super(h);
-               }
-       }
-
-       AltosGpsAltitude AltosGpsAltitude_fromHashSet(AltosHashSet h, AltosGpsAltitude def) {
-               if (h == null) return def;
-               return new AltosGpsAltitude(h);
        }
 
        private AltosGpsAltitude        gps_altitude;
@@ -590,15 +501,6 @@ public class AltosState implements Cloneable, AltosHashable {
                AltosPressure() {
                        super();
                }
-
-               AltosPressure (AltosHashSet h) {
-                       super(h);
-               }
-       }
-
-       AltosPressure AltosPressure_fromHashSet(AltosHashSet h, AltosPressure def) {
-               if (h == null) return def;
-               return new AltosPressure(h);
        }
 
        private AltosPressure   pressure;
@@ -611,6 +513,25 @@ public class AltosState implements Cloneable, AltosHashable {
                pressure.set(p, time);
        }
 
+       class AltosForce extends AltosValue {
+               void set(double p, double time) {
+                       super.set(p, time);
+               }
+
+               AltosForce() {
+                       super();
+               }
+       }
+       private AltosForce      thrust;
+
+       public double thrust() {
+               return thrust.value();
+       }
+
+       public void set_thrust(double N) {
+               thrust.set(N, time);
+       }
+
        public double baro_height() {
                double a = altitude();
                double g = ground_altitude();
@@ -661,7 +582,7 @@ public class AltosState implements Cloneable, AltosHashable {
                return AltosLib.MISSING;
        }
 
-       class AltosSpeed extends AltosCValue implements AltosHashable {
+       class AltosSpeed extends AltosCValue {
 
                boolean can_max() {
                        return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
@@ -689,15 +610,6 @@ public class AltosState implements Cloneable, AltosHashable {
                AltosSpeed() {
                        super();
                }
-
-               AltosSpeed (AltosHashSet h) {
-                       super(h);
-               }
-       }
-
-       AltosSpeed AltosSpeed_fromHashSet(AltosHashSet h, AltosSpeed def) {
-               if (h == null) return def;
-               return new AltosSpeed(h);
        }
 
        private AltosSpeed speed;
@@ -728,7 +640,7 @@ public class AltosState implements Cloneable, AltosHashable {
                return AltosLib.MISSING;
        }
 
-       class AltosAccel extends AltosCValue implements AltosHashable {
+       class AltosAccel extends AltosCValue {
 
                boolean can_max() {
                        return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
@@ -743,15 +655,6 @@ public class AltosState implements Cloneable, AltosHashable {
                AltosAccel() {
                        super();
                }
-
-               AltosAccel (AltosHashSet h) {
-                       super(h);
-               }
-       }
-
-       AltosAccel AltosAccel_fromHashSet(AltosHashSet h, AltosAccel def) {
-               if (h == null) return def;
-               return new AltosAccel(h);
        }
 
        AltosAccel acceleration;
@@ -876,6 +779,7 @@ public class AltosState implements Cloneable, AltosHashable {
                ground_pressure = new AltosGroundPressure();
                altitude = new AltosAltitude();
                pressure = new AltosPressure();
+               thrust = new AltosForce();
                speed = new AltosSpeed();
                acceleration = new AltosAccel();
                orient = new AltosCValue();
@@ -984,6 +888,8 @@ public class AltosState implements Cloneable, AltosHashable {
                        return;
                }
 
+               super.copy(old);
+
                received_time = old.received_time;
                time = old.time;
                time_change = old.time_change;
@@ -1185,11 +1091,6 @@ public class AltosState implements Cloneable, AltosHashable {
                }
        }
 
-       public void set_boost_tick(int boost_tick) {
-               if (boost_tick != AltosLib.MISSING)
-                       this.boost_tick = boost_tick;
-       }
-
        public String state_name() {
                return AltosLib.state_name(state);
        }
@@ -1502,7 +1403,7 @@ public class AltosState implements Cloneable, AltosHashable {
        public void set_ms5607(AltosMs5607 ms5607) {
                baro = ms5607;
 
-               if (baro != null) {
+               if (baro != null && baro.pa != AltosLib.MISSING && baro.cc != AltosLib.MISSING) {
                        set_pressure(baro.pa);
                        set_temperature(baro.cc / 100.0);
                }
@@ -1616,39 +1517,56 @@ public class AltosState implements Cloneable, AltosHashable {
                return tick != AltosLib.MISSING && serial != AltosLib.MISSING;
        }
 
-       public AltosGPS make_temp_gps(boolean sats) {
-               if (temp_gps == null) {
-                       temp_gps = new AltosGPS(gps);
-               }
-               gps_pending = true;
-               if (sats) {
-                       if (tick != temp_gps_sat_tick)
-                               temp_gps.cc_gps_sat = null;
-                       temp_gps_sat_tick = tick;
-               }
-               return temp_gps;
-       }
-
        public void set_temp_gps() {
                set_gps(temp_gps, gps_sequence + 1);
                gps_pending = false;
-               temp_gps = null;
+               super.set_temp_gps();
+       }
+
+       public void set_config_data(AltosConfigData config_data) {
+               if (config_data.callsign != null)
+                       set_callsign(config_data.callsign);
+               if (config_data.accel_cal_plus != AltosLib.MISSING &&
+                   config_data.accel_cal_minus != AltosLib.MISSING)
+                       set_accel_g(config_data.accel_cal_plus, config_data.accel_cal_minus);
+               if (config_data.product != null)
+                       set_product(config_data.product);
+               if (config_data.log_format != AltosLib.MISSING)
+                       set_log_format(config_data.log_format);
+               if (config_data.serial != AltosLib.MISSING)
+                       set_serial(config_data.serial);
+               AltosMs5607 ms5607 = new AltosMs5607(config_data);
+               if (ms5607.valid_config())
+                       set_ms5607(ms5607);
        }
 
        public AltosState clone() {
                AltosState s = new AltosState();
                s.copy(this);
 
-               AltosHashSet    hash = hashSet();
-               String          onetrip = hash.toString();
-               AltosHashSet    back = AltosHashSet.fromString(onetrip);
-               AltosState      tripstate = AltosState.fromHashSet(back);
-               AltosHashSet    triphash = tripstate.hashSet();
-               String          twotrip = triphash.toString();
-
-               if (!onetrip.equals(twotrip)) {
-                       System.out.printf("%s\n%s\n", onetrip, twotrip);
-                       System.exit(1);
+               /* Code to test state save/restore. Enable only for that purpose
+                */
+               if (false) {
+                       AltosJson       json = new AltosJson(this);
+                       String          onetrip = json.toPrettyString();
+                       AltosJson       back = AltosJson.fromString(onetrip);
+                       AltosState      tripstate = (AltosState) back.make(this.getClass());
+                       AltosJson       tripjson = new AltosJson(tripstate);
+                       String          twotrip = tripjson.toPrettyString();
+
+                       if (!onetrip.equals(twotrip)) {
+                               try {
+                                       FileWriter one_file = new FileWriter("one.json", true);
+                                       one_file.write(onetrip);
+                                       one_file.flush();
+                                       FileWriter two_file = new FileWriter("two.json", true);
+                                       two_file.write(twotrip);
+                                       two_file.flush();
+                               } catch (Exception e) {
+                               }
+                               System.out.printf("json error\n");
+                               System.exit(1);
+                       }
                }
                return s;
        }
@@ -1656,222 +1574,4 @@ public class AltosState implements Cloneable, AltosHashable {
        public AltosState () {
                init();
        }
-
-       public AltosHashSet hashSet() {
-               AltosHashSet    h = new AltosHashSet();
-
-               h.putBoolean("valid", true);
-               h.putInt("set", set);
-               h.putLong("received_time", received_time);
-               h.putDouble("time", time);
-               h.putDouble("prev_time", prev_time);
-               h.putDouble("time_change", time_change);
-               h.putInt("tick", tick);
-               h.putInt("prev_tick", prev_tick);
-               h.putInt("boost_tick", boost_tick);
-               h.putInt("state", state);
-               h.putInt("flight", flight);
-               h.putInt("serial", serial);
-               h.putInt("altitude_32", altitude_32);
-               h.putInt("receiver_serial", receiver_serial);
-               h.putBoolean("landed", landed);
-               h.putBoolean("ascent", ascent);
-               h.putBoolean("boost", boost);
-               h.putInt("rssi", rssi);
-               h.putInt("status", status);
-               h.putInt("device_type", device_type);
-               h.putInt("config_major", config_major);
-               h.putInt("config_minor", config_minor);
-               h.putInt("apogee_delay", apogee_delay);
-               h.putInt("main_deploy", main_deploy);
-               h.putInt("flight_log_max", flight_log_max);
-               h.putHashable("ground_altitude", ground_altitude);
-               h.putHashable("gps_ground_altitude", gps_ground_altitude);
-               h.putHashable("ground_pressure", ground_pressure);
-               h.putHashable("altitude", altitude);
-               h.putHashable("gps_altitude", gps_altitude);
-               h.putHashable("gps_ground_speed", gps_ground_speed);
-               h.putHashable("gps_ascent_rate", gps_ascent_rate);
-               h.putHashable("gps_course", gps_course);
-               h.putHashable("gps_speed", gps_speed);
-               h.putHashable("pressure", pressure);
-               h.putHashable("speed", speed);
-               h.putHashable("acceleration", acceleration);
-               h.putHashable("orient", orient);
-               h.putHashable("kalman_height", kalman_height);
-               h.putHashable("kalman_speed", kalman_speed);
-               h.putHashable("kalman_acceleration", kalman_acceleration);
-
-               h.putDouble("battery_voltage",battery_voltage);
-               h.putDouble("pyro_voltage",pyro_voltage);
-               h.putDouble("temperature",temperature);
-               h.putDouble("apogee_voltage",apogee_voltage);
-               h.putDouble("main_voltage",main_voltage);
-               h.putDoubleArray("ignitor_voltage",ignitor_voltage);
-               h.putHashable("gps", gps);
-               h.putHashable("temp_gps", temp_gps);
-               h.putInt("temp_gps_sat_tick", temp_gps_sat_tick);
-               h.putBoolean("gps_pending", gps_pending);
-               h.putInt("gps_sequence", gps_sequence);
-               h.putHashable("imu", imu);
-               h.putHashable("mag", mag);
-
-               h.putInt("npad", npad);
-               h.putInt("gps_waiting", gps_waiting);
-               h.putBoolean("gps_ready", gps_ready);
-               h.putInt("ngps", ngps);
-               h.putHashable("from_pad", from_pad);
-               h.putDouble("elevation", elevation);
-               h.putDouble("range", range);
-               h.putDouble("gps_height", gps_height);
-               h.putDouble("pad_lat", pad_lat);
-               h.putDouble("pad_lon", pad_lon);
-               h.putDouble("pad_alt", pad_alt);
-               h.putInt("speak_tick", speak_tick);
-               h.putDouble("speak_altitude", speak_altitude);
-               h.putString("callsign", callsign);
-               h.putString("firmware_version", firmware_version);
-               h.putDouble("accel_plus_g", accel_plus_g);
-               h.putDouble("accel_minus_g", accel_minus_g);
-               h.putDouble("accel", accel);
-               h.putDouble("ground_accel", ground_accel);
-               h.putDouble("ground_accel_avg", ground_accel_avg);
-               h.putInt("log_format", log_format);
-               h.putInt("log_space", log_space);
-               h.putString("product", product);
-               h.putHashable("baro", baro);
-               h.putHashable("companion", companion);
-               h.putInt("pyro_fired", pyro_fired);
-               h.putDouble("accel_zero_along", accel_zero_along);
-               h.putDouble("accel_zero_across", accel_zero_across);
-               h.putDouble("accel_zero_through", accel_zero_through);
-
-               h.putHashable("rotation", rotation);
-               h.putHashable("ground_rotation", ground_rotation);
-
-               h.putInt("pad_orientation", pad_orientation);
-
-               h.putDouble("accel_ground_along", accel_ground_along);
-               h.putDouble("accel_ground_across", accel_ground_across);
-               h.putDouble("accel_ground_through", accel_ground_through);
-
-               h.putDouble("gyro_zero_roll", gyro_zero_roll);
-               h.putDouble("gyro_zero_pitch", gyro_zero_pitch);
-               h.putDouble("gyro_zero_yaw", gyro_zero_yaw);
-
-               h.putDouble("last_imu_time", last_imu_time);
-               return h;
-       }
-
-       public AltosState(AltosHashSet h) {
-               this();
-
-               set = h.getInt("set", set);
-               received_time = h.getLong("received_time", received_time);
-               time = h.getDouble("time", time);
-               prev_time = h.getDouble("prev_time", prev_time);
-               time_change = h.getDouble("time_change", time_change);
-               tick = h.getInt("tick", tick);
-               prev_tick = h.getInt("prev_tick", prev_tick);
-               boost_tick = h.getInt("boost_tick", boost_tick);
-               state = h.getInt("state", state);
-               flight = h.getInt("flight", flight);
-               serial = h.getInt("serial", serial);
-               altitude_32 = h.getInt("altitude_32", altitude_32);
-               receiver_serial = h.getInt("receiver_serial", receiver_serial);
-               landed = h.getBoolean("landed", landed);
-               ascent = h.getBoolean("ascent", ascent);
-               boost = h.getBoolean("boost", boost);
-               rssi = h.getInt("rssi", rssi);
-               status = h.getInt("status", status);
-               device_type = h.getInt("device_type", device_type);
-               config_major = h.getInt("config_major", config_major);
-               config_minor = h.getInt("config_minor", config_minor);
-               apogee_delay = h.getInt("apogee_delay", apogee_delay);
-               main_deploy = h.getInt("main_deploy", main_deploy);
-               flight_log_max = h.getInt("flight_log_max", flight_log_max);
-               ground_altitude = AltosCValue_fromHashSet(h.getHash("ground_altitude"), ground_altitude);
-               gps_ground_altitude = AltosGpsGroundAltitude_fromHashSet(h.getHash("gps_ground_altitude"), gps_ground_altitude);
-               ground_pressure = AltosGroundPressure_fromHashSet(h.getHash("ground_pressure"), ground_pressure);
-               altitude = AltosAltitude_fromHashSet(h.getHash("altitude"), altitude);
-               gps_altitude = AltosGpsAltitude_fromHashSet(h.getHash("gps_altitude"), gps_altitude);
-               gps_ground_speed = AltosValue_fromHashSet(h.getHash("gps_ground_speed"), gps_ground_speed);
-               gps_ascent_rate = AltosValue_fromHashSet(h.getHash("gps_ascent_rate"), gps_ascent_rate);
-               gps_course = AltosValue_fromHashSet(h.getHash("gps_course"), gps_course);
-               gps_speed = AltosValue_fromHashSet(h.getHash("gps_speed"), gps_speed);
-               pressure = AltosPressure_fromHashSet(h.getHash("pressure"), pressure);
-               speed = AltosSpeed_fromHashSet(h.getHash("speed"), speed);
-               acceleration = AltosAccel_fromHashSet(h.getHash("acceleration"), acceleration);
-               orient = AltosCValue_fromHashSet(h.getHash("orient"), orient);
-               kalman_height = AltosValue_fromHashSet(h.getHash("kalman_height"), kalman_height);
-               kalman_speed = AltosValue_fromHashSet(h.getHash("kalman_speed"), kalman_speed);
-               kalman_acceleration = AltosValue_fromHashSet(h.getHash("kalman_acceleration"), kalman_acceleration);
-
-               battery_voltage = h.getDouble("battery_voltage", battery_voltage);
-               pyro_voltage = h.getDouble("pyro_voltage", pyro_voltage);
-               temperature = h.getDouble("temperature", temperature);
-               apogee_voltage = h.getDouble("apogee_voltage", apogee_voltage);
-               main_voltage=  h.getDouble("main_voltage", main_voltage);
-               ignitor_voltage = h.getDoubleArray("ignitor_voltage", ignitor_voltage);
-               gps = AltosGPS.fromHashSet(h.getHash("gps"), gps);
-               temp_gps = AltosGPS.fromHashSet(h.getHash("temp_gps"), temp_gps);
-               temp_gps_sat_tick = h.getInt("temp_gps_sat_tick", temp_gps_sat_tick);
-               gps_pending = h.getBoolean("gps_pending", gps_pending);
-               gps_sequence = h.getInt("gps_sequence", gps_sequence);
-               imu = AltosIMU.fromHashSet(h.getHash("imu"), imu);
-               mag = AltosMag.fromHashSet(h.getHash("mag"), mag);
-
-               npad = h.getInt("npad", npad);
-               gps_waiting = h.getInt("gps_waiting", gps_waiting);
-               gps_ready = h.getBoolean("gps_ready", gps_ready);
-               ngps = h.getInt("ngps", ngps);
-               from_pad = AltosGreatCircle.fromHashSet(h.getHash("from_pad"), from_pad);
-               elevation = h.getDouble("elevation", elevation);
-               range = h.getDouble("range", range);
-               gps_height = h.getDouble("gps_height", gps_height);
-               pad_lat = h.getDouble("pad_lat", pad_lat);
-               pad_lon = h.getDouble("pad_lon", pad_lon);
-               pad_alt = h.getDouble("pad_alt", pad_alt);
-               speak_tick = h.getInt("speak_tick", speak_tick);
-               speak_altitude = h.getDouble("speak_altitude", speak_altitude);
-               callsign = h.getString("callsign", callsign);
-               firmware_version = h.getString("firmware_version", firmware_version);
-               accel_plus_g = h.getDouble("accel_plus_g", accel_plus_g);
-               accel_minus_g = h.getDouble("accel_minus_g", accel_minus_g);
-               accel = h.getDouble("accel", accel);
-               ground_accel = h.getDouble("ground_accel", ground_accel);
-               ground_accel_avg = h.getDouble("ground_accel_avg", ground_accel_avg);
-               log_format = h.getInt("log_format", log_format);
-               log_space = h.getInt("log_space", log_space);
-               product = h.getString("product", product);
-               baro = AltosMs5607.fromHashSet(h.getHash("baro"), baro);
-               companion = AltosCompanion.fromHashSet(h.getHash("companion"), companion);
-               pyro_fired = h.getInt("pyro_fired", pyro_fired);
-               accel_zero_along = h.getDouble("accel_zero_along", accel_zero_along);
-               accel_zero_across = h.getDouble("accel_zero_across", accel_zero_across);
-               accel_zero_through = h.getDouble("accel_zero_through", accel_zero_through);
-
-               rotation = AltosRotation.fromHashSet(h.getHash("rotation"), rotation);
-               ground_rotation = AltosRotation.fromHashSet(h.getHash("ground_rotation"), ground_rotation);
-
-               pad_orientation = h.getInt("pad_orientation", pad_orientation);
-
-               accel_ground_along = h.getDouble("accel_ground_along", accel_ground_along);
-               accel_ground_across = h.getDouble("accel_ground_across", accel_ground_across);
-               accel_ground_through = h.getDouble("accel_ground_through", accel_ground_through);
-
-               gyro_zero_roll = h.getDouble("gyro_zero_roll", gyro_zero_roll);
-               gyro_zero_pitch = h.getDouble("gyro_zero_pitch", gyro_zero_pitch);
-               gyro_zero_yaw = h.getDouble("gyro_zero_yaw", gyro_zero_yaw);
-
-               last_imu_time = h.getDouble("last_imu_time", last_imu_time);
-       }
-
-       public static AltosState fromHashSet(AltosHashSet h) {
-               if (h == null)
-                       return null;
-               if (!h.getBoolean("valid", false))
-                       return null;
-               return new AltosState(h);
-       }
 }