2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 * Track flight state from telemetry or eeprom data stream
22 package org.altusmetrum.altoslib_11;
26 public class AltosState implements Cloneable, AltosHashable {
28 public static final int set_position = 1;
29 public static final int set_gps = 2;
30 public static final int set_data = 4;
34 static final double filter_len = 2.0;
35 static final double ascent_filter_len = 0.5;
36 static final double descent_filter_len = 5.0;
40 public long received_time;
43 public double prev_time;
44 public double time_change;
46 private int prev_tick;
47 public int boost_tick;
49 class AltosValue implements AltosHashable {
52 private double max_value;
53 private double set_time;
54 private double prev_set_time;
56 boolean can_max() { return true; }
58 void set(double new_value, double time) {
59 if (new_value != AltosLib.MISSING) {
61 if (can_max() && (max_value == AltosLib.MISSING || value > max_value))
67 void set_filtered(double new_value, double time) {
68 if (prev_value != AltosLib.MISSING) {
69 double f = 1/Math.exp((time - prev_set_time) / filter_len);
70 new_value = f * new_value + (1-f) * prev_value;
88 if (value != AltosLib.MISSING && prev_value != AltosLib.MISSING)
89 return value - prev_value;
90 return AltosLib.MISSING;
95 double t = set_time - prev_set_time;
97 if (c != AltosLib.MISSING && t != 0)
99 return AltosLib.MISSING;
103 if (value == AltosLib.MISSING)
104 return AltosLib.MISSING;
105 if (prev_value == AltosLib.MISSING)
106 return AltosLib.MISSING;
108 return (value + prev_value) / 2 * (set_time - prev_set_time);
115 void set_derivative(AltosValue in) {
116 double n = in.rate();
118 if (n == AltosLib.MISSING)
121 double p = prev_value;
122 double pt = prev_set_time;
124 if (p == AltosLib.MISSING) {
126 pt = in.time() - 0.01;
129 /* Clip changes to reduce noise */
130 double ddt = in.time() - pt;
131 double ddv = (n - p) / ddt;
133 final double max = 100000;
136 if (Math.abs(ddv) > max) {
146 filter_len = ascent_filter_len;
148 filter_len = descent_filter_len;
150 double f = 1/Math.exp(ddt/ filter_len);
151 n = p * f + n * (1-f);
156 void set_integral(AltosValue in) {
157 double change = in.integrate();
159 if (change != AltosLib.MISSING) {
160 double prev = prev_value;
161 if (prev == AltosLib.MISSING)
163 set(prev + change, in.time());
167 void copy(AltosValue old) {
169 set_time = old.set_time;
170 prev_value = old.value;
171 prev_set_time = old.set_time;
172 max_value = old.max_value;
175 void finish_update() {
177 prev_set_time = set_time;
180 public AltosHashSet hashSet() {
181 AltosHashSet h = new AltosHashSet();
183 h.putDouble("value", value);
184 h.putDouble("prev_value", prev_value);
185 h.putDouble("max_value", max_value);
186 h.putDouble("set_time", set_time);
187 h.putDouble("prev_set_time", prev_set_time);
191 AltosValue(AltosHashSet h) {
194 value = h.getDouble("value", value);
195 prev_value = h.getDouble("prev_value", prev_value);
196 max_value = h.getDouble("max_value", max_value);
197 set_time = h.getDouble("set_time", 0);
198 prev_set_time = h.getDouble("prev_set_time", 0);
203 value = AltosLib.MISSING;
204 prev_value = AltosLib.MISSING;
205 max_value = AltosLib.MISSING;
210 AltosValue AltosValue_fromHashSet(AltosHashSet h, AltosValue def) {
213 return new AltosValue(h);
216 class AltosCValue implements AltosHashable {
218 class AltosIValue extends AltosValue implements AltosHashable {
227 AltosIValue(AltosHashSet h) {
232 public AltosIValue measured;
233 public AltosIValue computed;
235 boolean can_max() { return true; }
237 boolean c_can_max() { return can_max(); }
240 double v = measured.value();
241 if (v != AltosLib.MISSING)
243 return computed.value();
246 boolean is_measured() {
247 return measured.value() != AltosLib.MISSING;
251 double m = measured.max();
253 if (m != AltosLib.MISSING)
255 return computed.max();
258 double prev_value() {
259 if (measured.value != AltosLib.MISSING && measured.prev_value != AltosLib.MISSING)
260 return measured.prev_value;
261 return computed.prev_value;
264 AltosValue altos_value() {
265 if (measured.value() != AltosLib.MISSING)
271 double c = measured.change();
272 if (c == AltosLib.MISSING)
273 c = computed.change();
278 double r = measured.rate();
279 if (r == AltosLib.MISSING)
284 void set_measured(double new_value, double time) {
285 measured.set(new_value, time);
288 void set_computed(double new_value, double time) {
289 computed.set(new_value, time);
292 void set_derivative(AltosValue in) {
293 computed.set_derivative(in);
296 void set_derivative(AltosCValue in) {
297 set_derivative(in.altos_value());
300 void set_integral(AltosValue in) {
301 computed.set_integral(in);
304 void set_integral(AltosCValue in) {
305 set_integral(in.altos_value());
308 void copy(AltosCValue old) {
309 measured.copy(old.measured);
310 computed.copy(old.computed);
313 void finish_update() {
314 measured.finish_update();
315 computed.finish_update();
319 measured = new AltosIValue();
320 computed = new AltosIValue();
324 public AltosHashSet hashSet() {
325 AltosHashSet h = new AltosHashSet();
327 h.putHashable("measured", measured);
328 h.putHashable("computed", computed);
332 AltosCValue(AltosHashSet h) {
333 measured = new AltosIValue(h.getHash("measured"));
334 computed = new AltosIValue(h.getHash("computed"));
338 AltosCValue AltosCValue_fromHashSet(AltosHashSet h, AltosCValue def) {
341 return new AltosCValue(h);
347 public int altitude_32;
348 public int receiver_serial;
349 public boolean landed;
350 public boolean ascent; /* going up? */
351 public boolean boost; /* under power */
354 public int device_type;
355 public int config_major;
356 public int config_minor;
357 public int apogee_delay;
358 public int main_deploy;
359 public int flight_log_max;
361 private double pressure_to_altitude(double p) {
362 if (p == AltosLib.MISSING)
363 return AltosLib.MISSING;
364 return AltosConvert.pressure_to_altitude(p);
367 private AltosCValue ground_altitude;
369 public double ground_altitude() {
370 return ground_altitude.value();
373 public void set_ground_altitude(double a) {
374 ground_altitude.set_measured(a, time);
377 class AltosGpsGroundAltitude extends AltosValue {
378 void set(double a, double t) {
381 gps_altitude.set_gps_height();
384 void set_filtered(double a, double t) {
385 super.set_filtered(a, t);
387 gps_altitude.set_gps_height();
390 AltosGpsGroundAltitude() {
394 AltosGpsGroundAltitude (AltosHashSet h) {
399 AltosGpsGroundAltitude AltosGpsGroundAltitude_fromHashSet(AltosHashSet h, AltosGpsGroundAltitude def) {
400 if (h == null) return def;
401 return new AltosGpsGroundAltitude(h);
404 private AltosGpsGroundAltitude gps_ground_altitude;
406 public double gps_ground_altitude() {
407 return gps_ground_altitude.value();
410 public void set_gps_ground_altitude(double a) {
411 gps_ground_altitude.set(a, time);
414 class AltosGroundPressure extends AltosCValue {
415 void set_filtered(double p, double time) {
416 computed.set_filtered(p, time);
418 ground_altitude.set_computed(pressure_to_altitude(computed.value()), time);
421 void set_measured(double p, double time) {
422 super.set_measured(p, time);
423 ground_altitude.set_computed(pressure_to_altitude(p), time);
426 AltosGroundPressure () {
430 AltosGroundPressure (AltosHashSet h) {
435 AltosGroundPressure AltosGroundPressure_fromHashSet(AltosHashSet h, AltosGroundPressure def) {
436 if (h == null) return def;
437 return new AltosGroundPressure(h);
440 private AltosGroundPressure ground_pressure;
442 public double ground_pressure() {
443 return ground_pressure.value();
446 public void set_ground_pressure (double pressure) {
447 ground_pressure.set_measured(pressure, time);
450 class AltosAltitude extends AltosCValue implements AltosHashable {
452 private void set_speed(AltosValue v) {
453 if (!acceleration.is_measured() || !ascent)
454 speed.set_derivative(this);
457 void set_computed(double a, double time) {
458 super.set_computed(a,time);
463 void set_measured(double a, double time) {
464 super.set_measured(a,time);
473 AltosAltitude (AltosHashSet h) {
478 AltosAltitude AltosAltitude_fromHashSet(AltosHashSet h, AltosAltitude def) {
479 if (h == null) return def;
480 return new AltosAltitude(h);
483 private AltosAltitude altitude;
485 class AltosGpsAltitude extends AltosValue implements AltosHashable {
487 private void set_gps_height() {
489 double g = gps_ground_altitude.value();
491 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
494 gps_height = AltosLib.MISSING;
497 void set(double a, double t) {
506 AltosGpsAltitude (AltosHashSet h) {
511 AltosGpsAltitude AltosGpsAltitude_fromHashSet(AltosHashSet h, AltosGpsAltitude def) {
512 if (h == null) return def;
513 return new AltosGpsAltitude(h);
516 private AltosGpsAltitude gps_altitude;
518 private AltosValue gps_ground_speed;
519 private AltosValue gps_ascent_rate;
520 private AltosValue gps_course;
521 private AltosValue gps_speed;
523 public double altitude() {
524 double a = altitude.value();
525 if (a != AltosLib.MISSING)
527 return gps_altitude.value();
530 public double max_altitude() {
531 double a = altitude.max();
532 if (a != AltosLib.MISSING)
534 return gps_altitude.max();
537 public void set_altitude(double new_altitude) {
538 altitude.set_measured(new_altitude, time);
541 public double gps_altitude() {
542 return gps_altitude.value();
545 public double max_gps_altitude() {
546 return gps_altitude.max();
549 public void set_gps_altitude(double new_gps_altitude) {
550 gps_altitude.set(new_gps_altitude, time);
553 public double gps_ground_speed() {
554 return gps_ground_speed.value();
557 public double max_gps_ground_speed() {
558 return gps_ground_speed.max();
561 public double gps_ascent_rate() {
562 return gps_ascent_rate.value();
565 public double max_gps_ascent_rate() {
566 return gps_ascent_rate.max();
569 public double gps_course() {
570 return gps_course.value();
573 public double gps_speed() {
574 return gps_speed.value();
577 public double max_gps_speed() {
578 return gps_speed.max();
581 class AltosPressure extends AltosValue {
582 void set(double p, double time) {
584 if (state == AltosLib.ao_flight_pad)
585 ground_pressure.set_filtered(p, time);
586 double a = pressure_to_altitude(p);
587 altitude.set_computed(a, time);
594 AltosPressure (AltosHashSet h) {
599 AltosPressure AltosPressure_fromHashSet(AltosHashSet h, AltosPressure def) {
600 if (h == null) return def;
601 return new AltosPressure(h);
604 private AltosPressure pressure;
606 public double pressure() {
607 return pressure.value();
610 public void set_pressure(double p) {
611 pressure.set(p, time);
614 public double baro_height() {
615 double a = altitude();
616 double g = ground_altitude();
617 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
619 return AltosLib.MISSING;
622 public double height() {
623 double k = kalman_height.value();
624 if (k != AltosLib.MISSING)
627 double b = baro_height();
628 if (b != AltosLib.MISSING)
634 public double max_height() {
635 double k = kalman_height.max();
636 if (k != AltosLib.MISSING)
639 double a = altitude.max();
640 double g = ground_altitude();
641 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
643 return max_gps_height();
646 public double gps_height() {
647 double a = gps_altitude();
648 double g = gps_ground_altitude();
650 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
652 return AltosLib.MISSING;
655 public double max_gps_height() {
656 double a = gps_altitude.max();
657 double g = gps_ground_altitude();
659 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
661 return AltosLib.MISSING;
664 class AltosSpeed extends AltosCValue implements AltosHashable {
667 return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
671 acceleration.set_derivative(this);
674 void set_derivative(AltosCValue in) {
675 super.set_derivative(in);
679 void set_computed(double new_value, double time) {
680 super.set_computed(new_value, time);
684 void set_measured(double new_value, double time) {
685 super.set_measured(new_value, time);
693 AltosSpeed (AltosHashSet h) {
698 AltosSpeed AltosSpeed_fromHashSet(AltosHashSet h, AltosSpeed def) {
699 if (h == null) return def;
700 return new AltosSpeed(h);
703 private AltosSpeed speed;
705 public double speed() {
706 double v = kalman_speed.value();
707 if (v != AltosLib.MISSING)
710 if (v != AltosLib.MISSING)
713 if (v != AltosLib.MISSING)
715 return AltosLib.MISSING;
718 public double max_speed() {
719 double v = kalman_speed.max();
720 if (v != AltosLib.MISSING)
723 if (v != AltosLib.MISSING)
726 if (v != AltosLib.MISSING)
728 return AltosLib.MISSING;
731 class AltosAccel extends AltosCValue implements AltosHashable {
734 return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
737 void set_measured(double a, double time) {
738 super.set_measured(a, time);
740 speed.set_integral(this.measured);
747 AltosAccel (AltosHashSet h) {
752 AltosAccel AltosAccel_fromHashSet(AltosHashSet h, AltosAccel def) {
753 if (h == null) return def;
754 return new AltosAccel(h);
757 AltosAccel acceleration;
759 public double acceleration() {
760 return acceleration.value();
763 public double max_acceleration() {
764 return acceleration.max();
767 public AltosCValue orient;
769 public void set_orient(double new_orient) {
770 orient.set_measured(new_orient, time);
773 public double orient() {
774 return orient.value();
777 public double max_orient() {
781 public AltosValue kalman_height, kalman_speed, kalman_acceleration;
783 public void set_kalman(double height, double speed, double acceleration) {
784 kalman_height.set(height, time);
785 kalman_speed.set(speed, time);
786 kalman_acceleration.set(acceleration, time);
789 public double battery_voltage;
790 public double pyro_voltage;
791 public double temperature;
792 public double apogee_voltage;
793 public double main_voltage;
795 public double ignitor_voltage[];
798 public AltosGPS temp_gps;
799 public int temp_gps_sat_tick;
800 public boolean gps_pending;
801 public int gps_sequence;
806 public static final int MIN_PAD_SAMPLES = 10;
809 public int gps_waiting;
810 public boolean gps_ready;
814 public AltosGreatCircle from_pad;
815 public double elevation; /* from pad */
816 public double range; /* total distance */
818 public double gps_height;
820 public double pad_lat, pad_lon, pad_alt;
822 public int speak_tick;
823 public double speak_altitude;
825 public String callsign;
826 public String firmware_version;
828 public double accel_plus_g;
829 public double accel_minus_g;
831 public double ground_accel;
832 public double ground_accel_avg;
834 public int log_format;
835 public String product;
837 public AltosMs5607 baro;
839 public AltosCompanion companion;
841 public int pyro_fired;
843 public void set_npad(int npad) {
845 gps_waiting = MIN_PAD_SAMPLES - npad;
846 if (this.gps_waiting < 0)
848 gps_ready = gps_waiting == 0;
854 received_time = System.currentTimeMillis();
855 time = AltosLib.MISSING;
856 time_change = AltosLib.MISSING;
857 prev_time = AltosLib.MISSING;
858 tick = AltosLib.MISSING;
859 prev_tick = AltosLib.MISSING;
860 boost_tick = AltosLib.MISSING;
861 state = AltosLib.ao_flight_invalid;
862 flight = AltosLib.MISSING;
865 rssi = AltosLib.MISSING;
867 device_type = AltosLib.MISSING;
868 config_major = AltosLib.MISSING;
869 config_minor = AltosLib.MISSING;
870 apogee_delay = AltosLib.MISSING;
871 main_deploy = AltosLib.MISSING;
872 flight_log_max = AltosLib.MISSING;
874 ground_altitude = new AltosCValue();
875 ground_pressure = new AltosGroundPressure();
876 altitude = new AltosAltitude();
877 pressure = new AltosPressure();
878 speed = new AltosSpeed();
879 acceleration = new AltosAccel();
880 orient = new AltosCValue();
882 temperature = AltosLib.MISSING;
883 battery_voltage = AltosLib.MISSING;
884 pyro_voltage = AltosLib.MISSING;
885 apogee_voltage = AltosLib.MISSING;
886 main_voltage = AltosLib.MISSING;
887 ignitor_voltage = null;
889 kalman_height = new AltosValue();
890 kalman_speed = new AltosValue();
891 kalman_acceleration = new AltosValue();
895 temp_gps_sat_tick = 0;
900 last_imu_time = AltosLib.MISSING;
902 ground_rotation = null;
905 accel_zero_along = AltosLib.MISSING;
906 accel_zero_across = AltosLib.MISSING;
907 accel_zero_through = AltosLib.MISSING;
909 accel_ground_along = AltosLib.MISSING;
910 accel_ground_across = AltosLib.MISSING;
911 accel_ground_through = AltosLib.MISSING;
913 pad_orientation = AltosLib.MISSING;
915 gyro_zero_roll = AltosLib.MISSING;
916 gyro_zero_pitch = AltosLib.MISSING;
917 gyro_zero_yaw = AltosLib.MISSING;
923 elevation = AltosLib.MISSING;
924 range = AltosLib.MISSING;
925 gps_height = AltosLib.MISSING;
927 pad_lat = AltosLib.MISSING;
928 pad_lon = AltosLib.MISSING;
929 pad_alt = AltosLib.MISSING;
931 gps_altitude = new AltosGpsAltitude();
932 gps_ground_altitude = new AltosGpsGroundAltitude();
933 gps_ground_speed = new AltosValue();
934 gps_speed = new AltosValue();
935 gps_ascent_rate = new AltosValue();
936 gps_course = new AltosValue();
938 speak_tick = AltosLib.MISSING;
939 speak_altitude = AltosLib.MISSING;
942 firmware_version = null;
944 accel_plus_g = AltosLib.MISSING;
945 accel_minus_g = AltosLib.MISSING;
946 accel = AltosLib.MISSING;
948 ground_accel = AltosLib.MISSING;
949 ground_accel_avg = AltosLib.MISSING;
951 log_format = AltosLib.MISSING;
953 serial = AltosLib.MISSING;
954 receiver_serial = AltosLib.MISSING;
955 altitude_32 = AltosLib.MISSING;
963 void finish_update() {
966 ground_altitude.finish_update();
967 altitude.finish_update();
968 pressure.finish_update();
969 speed.finish_update();
970 acceleration.finish_update();
971 orient.finish_update();
973 kalman_height.finish_update();
974 kalman_speed.finish_update();
975 kalman_acceleration.finish_update();
978 void copy(AltosState old) {
985 received_time = old.received_time;
987 time_change = old.time_change;
988 prev_time = old.time;
991 prev_tick = old.tick;
992 boost_tick = old.boost_tick;
1000 status = old.status;
1001 device_type = old.device_type;
1002 config_major = old.config_major;
1003 config_minor = old.config_minor;
1004 apogee_delay = old.apogee_delay;
1005 main_deploy = old.main_deploy;
1006 flight_log_max = old.flight_log_max;
1010 ground_pressure.copy(old.ground_pressure);
1011 ground_altitude.copy(old.ground_altitude);
1012 altitude.copy(old.altitude);
1013 pressure.copy(old.pressure);
1014 speed.copy(old.speed);
1015 acceleration.copy(old.acceleration);
1016 orient.copy(old.orient);
1018 battery_voltage = old.battery_voltage;
1019 pyro_voltage = old.pyro_voltage;
1020 temperature = old.temperature;
1021 apogee_voltage = old.apogee_voltage;
1022 main_voltage = old.main_voltage;
1023 ignitor_voltage = old.ignitor_voltage;
1025 kalman_height.copy(old.kalman_height);
1026 kalman_speed.copy(old.kalman_speed);
1027 kalman_acceleration.copy(old.kalman_acceleration);
1029 if (old.gps != null)
1030 gps = old.gps.clone();
1033 if (old.temp_gps != null)
1034 temp_gps = old.temp_gps.clone();
1037 temp_gps_sat_tick = old.temp_gps_sat_tick;
1038 gps_sequence = old.gps_sequence;
1039 gps_pending = old.gps_pending;
1041 if (old.imu != null)
1042 imu = old.imu.clone();
1045 last_imu_time = old.last_imu_time;
1047 if (old.rotation != null)
1048 rotation = new AltosRotation (old.rotation);
1050 if (old.ground_rotation != null) {
1051 ground_rotation = new AltosRotation(old.ground_rotation);
1054 accel_zero_along = old.accel_zero_along;
1055 accel_zero_across = old.accel_zero_across;
1056 accel_zero_through = old.accel_zero_through;
1058 accel_ground_along = old.accel_ground_along;
1059 accel_ground_across = old.accel_ground_across;
1060 accel_ground_through = old.accel_ground_through;
1061 pad_orientation = old.pad_orientation;
1063 gyro_zero_roll = old.gyro_zero_roll;
1064 gyro_zero_pitch = old.gyro_zero_pitch;
1065 gyro_zero_yaw = old.gyro_zero_yaw;
1067 if (old.mag != null)
1068 mag = old.mag.clone();
1073 gps_waiting = old.gps_waiting;
1074 gps_ready = old.gps_ready;
1077 if (old.from_pad != null)
1078 from_pad = old.from_pad.clone();
1082 elevation = old.elevation;
1085 gps_height = old.gps_height;
1087 gps_altitude.copy(old.gps_altitude);
1088 gps_ground_altitude.copy(old.gps_ground_altitude);
1089 gps_ground_speed.copy(old.gps_ground_speed);
1090 gps_ascent_rate.copy(old.gps_ascent_rate);
1091 gps_course.copy(old.gps_course);
1092 gps_speed.copy(old.gps_speed);
1094 pad_lat = old.pad_lat;
1095 pad_lon = old.pad_lon;
1096 pad_alt = old.pad_alt;
1098 speak_tick = old.speak_tick;
1099 speak_altitude = old.speak_altitude;
1101 callsign = old.callsign;
1102 firmware_version = old.firmware_version;
1104 accel_plus_g = old.accel_plus_g;
1105 accel_minus_g = old.accel_minus_g;
1107 ground_accel = old.ground_accel;
1108 ground_accel_avg = old.ground_accel_avg;
1110 log_format = old.log_format;
1111 product = old.product;
1112 serial = old.serial;
1113 receiver_serial = old.receiver_serial;
1114 altitude_32 = old.altitude_32;
1117 companion = old.companion;
1119 pyro_fired = old.pyro_fired;
1122 void update_time() {
1126 elevation = AltosLib.MISSING;
1127 range = AltosLib.MISSING;
1132 if (gps.locked && gps.nsat >= 4) {
1133 /* Track consecutive 'good' gps reports, waiting for 10 of them */
1134 if (state == AltosLib.ao_flight_pad || state == AltosLib.ao_flight_stateless) {
1136 if (pad_lat != AltosLib.MISSING && (npad < 10 || state == AltosLib.ao_flight_pad)) {
1137 pad_lat = (pad_lat * 31 + gps.lat) / 32;
1138 pad_lon = (pad_lon * 31 + gps.lon) / 32;
1139 gps_ground_altitude.set_filtered(gps.alt, time);
1142 if (pad_lat == AltosLib.MISSING) {
1145 gps_ground_altitude.set(gps.alt, time);
1147 gps_altitude.set(gps.alt, time);
1148 if (gps.climb_rate != AltosLib.MISSING)
1149 gps_ascent_rate.set(gps.climb_rate, time);
1150 if (gps.ground_speed != AltosLib.MISSING)
1151 gps_ground_speed.set(gps.ground_speed, time);
1152 if (gps.climb_rate != AltosLib.MISSING && gps.ground_speed != AltosLib.MISSING)
1153 gps_speed.set(Math.sqrt(gps.ground_speed * gps.ground_speed +
1154 gps.climb_rate * gps.climb_rate), time);
1155 if (gps.course != AltosLib.MISSING)
1156 gps_course.set(gps.course, time);
1158 if (gps.lat != 0 && gps.lon != 0 &&
1159 pad_lat != AltosLib.MISSING &&
1160 pad_lon != AltosLib.MISSING)
1162 double h = height();
1164 if (h == AltosLib.MISSING)
1166 from_pad = new AltosGreatCircle(pad_lat, pad_lon, 0, gps.lat, gps.lon, h);
1167 elevation = from_pad.elevation;
1168 range = from_pad.range;
1172 public void set_tick(int new_tick) {
1173 if (new_tick != AltosLib.MISSING) {
1174 if (prev_tick != AltosLib.MISSING) {
1175 while (new_tick < prev_tick - 1000) {
1180 time = tick / 100.0;
1181 time_change = time - prev_time;
1185 public void set_boost_tick(int boost_tick) {
1186 if (boost_tick != AltosLib.MISSING)
1187 this.boost_tick = boost_tick;
1190 public String state_name() {
1191 return AltosLib.state_name(state);
1194 public void set_product(String product) {
1195 this.product = product;
1198 public void set_state(int state) {
1199 if (state != AltosLib.ao_flight_invalid) {
1201 ascent = (AltosLib.ao_flight_boost <= state &&
1202 state <= AltosLib.ao_flight_coast);
1203 boost = (AltosLib.ao_flight_boost == state);
1207 public int state() {
1211 public void set_device_type(int device_type) {
1212 this.device_type = device_type;
1213 switch (device_type) {
1214 case AltosLib.product_telegps:
1215 this.state = AltosLib.ao_flight_stateless;
1220 public void set_log_format(int log_format) {
1221 this.log_format = log_format;
1222 switch (log_format) {
1223 case AltosLib.AO_LOG_FORMAT_TELEGPS:
1224 this.state = AltosLib.ao_flight_stateless;
1229 public void set_flight_params(int apogee_delay, int main_deploy) {
1230 this.apogee_delay = apogee_delay;
1231 this.main_deploy = main_deploy;
1234 public void set_config(int major, int minor, int flight_log_max) {
1235 config_major = major;
1236 config_minor = minor;
1237 this.flight_log_max = flight_log_max;
1240 public void set_callsign(String callsign) {
1241 this.callsign = callsign;
1244 public void set_firmware_version(String version) {
1245 firmware_version = version;
1248 public int compare_version(String other_version) {
1249 if (firmware_version == null)
1250 return AltosLib.MISSING;
1251 return AltosLib.compare_version(firmware_version, other_version);
1254 private void re_init() {
1255 int bt = boost_tick;
1256 int rs = receiver_serial;
1259 receiver_serial = rs;
1262 public void set_flight(int flight) {
1264 /* When the flight changes, reset the state */
1265 if (flight != AltosLib.MISSING) {
1266 if (this.flight != AltosLib.MISSING &&
1267 this.flight != flight) {
1270 this.flight = flight;
1274 public void set_serial(int serial) {
1275 /* When the serial changes, reset the state */
1276 if (serial != AltosLib.MISSING) {
1277 if (this.serial != AltosLib.MISSING &&
1278 this.serial != serial) {
1281 this.serial = serial;
1285 public void set_receiver_serial(int serial) {
1286 if (serial != AltosLib.MISSING)
1287 receiver_serial = serial;
1290 public boolean altitude_32() {
1291 return altitude_32 == 1;
1294 public void set_altitude_32(int altitude_32) {
1295 if (altitude_32 != AltosLib.MISSING)
1296 this.altitude_32 = altitude_32;
1300 if (rssi == AltosLib.MISSING)
1305 public void set_rssi(int rssi, int status) {
1306 if (rssi != AltosLib.MISSING) {
1308 this.status = status;
1312 public void set_received_time(long ms) {
1316 public void set_gps(AltosGPS gps, int sequence) {
1318 this.gps = gps.clone();
1319 gps_sequence = sequence;
1326 public double accel_zero_along;
1327 public double accel_zero_across;
1328 public double accel_zero_through;
1330 public AltosRotation rotation;
1331 public AltosRotation ground_rotation;
1333 public void set_accel_zero(double zero_along, double zero_across, double zero_through) {
1334 if (zero_along != AltosLib.MISSING) {
1335 accel_zero_along = zero_along;
1336 accel_zero_across = zero_across;
1337 accel_zero_through = zero_through;
1341 public int pad_orientation;
1343 public double accel_ground_along, accel_ground_across, accel_ground_through;
1345 void update_pad_rotation() {
1346 if (pad_orientation != AltosLib.MISSING && accel_ground_along != AltosLib.MISSING) {
1347 rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - accel_zero_across),
1348 AltosIMU.convert_accel(accel_ground_through - accel_zero_through),
1349 AltosIMU.convert_accel(accel_ground_along - accel_zero_along),
1351 ground_rotation = rotation;
1352 orient.set_computed(rotation.tilt(), time);
1356 public void set_accel_ground(double ground_along, double ground_across, double ground_through) {
1357 accel_ground_along = ground_along;
1358 accel_ground_across = ground_across;
1359 accel_ground_through = ground_through;
1360 update_pad_rotation();
1363 public void set_pad_orientation(int pad_orientation) {
1364 this.pad_orientation = pad_orientation;
1365 update_pad_rotation();
1368 public double gyro_zero_roll;
1369 public double gyro_zero_pitch;
1370 public double gyro_zero_yaw;
1372 public void set_gyro_zero(double roll, double pitch, double yaw) {
1373 if (roll != AltosLib.MISSING) {
1374 gyro_zero_roll = roll;
1375 gyro_zero_pitch = pitch;
1376 gyro_zero_yaw = yaw;
1380 public double last_imu_time;
1382 private double radians(double degrees) {
1383 if (degrees == AltosLib.MISSING)
1384 return AltosLib.MISSING;
1385 return degrees * Math.PI / 180.0;
1388 private void update_orient() {
1389 if (last_imu_time != AltosLib.MISSING) {
1390 double t = time - last_imu_time;
1392 double pitch = radians(gyro_pitch());
1393 double yaw = radians(gyro_yaw());
1394 double roll = radians(gyro_roll());
1396 if (t > 0 & pitch != AltosLib.MISSING && rotation != null) {
1397 rotation.rotate(t, pitch, yaw, roll);
1398 orient.set_computed(rotation.tilt(), time);
1401 last_imu_time = time;
1404 public void set_imu(AltosIMU imu) {
1411 private double gyro_zero_overflow(double first) {
1412 double v = first / 128.0;
1420 public void check_imu_wrap(AltosIMU imu) {
1421 if (this.imu == null) {
1422 gyro_zero_roll += gyro_zero_overflow(imu.gyro_roll);
1423 gyro_zero_pitch += gyro_zero_overflow(imu.gyro_pitch);
1424 gyro_zero_yaw += gyro_zero_overflow(imu.gyro_yaw);
1428 public double accel_along() {
1429 if (imu != null && accel_zero_along != AltosLib.MISSING)
1430 return AltosIMU.convert_accel(imu.accel_along - accel_zero_along);
1431 return AltosLib.MISSING;
1434 public double accel_across() {
1435 if (imu != null && accel_zero_across != AltosLib.MISSING)
1436 return AltosIMU.convert_accel(imu.accel_across - accel_zero_across);
1437 return AltosLib.MISSING;
1440 public double accel_through() {
1441 if (imu != null && accel_zero_through != AltosLib.MISSING)
1442 return AltosIMU.convert_accel(imu.accel_through - accel_zero_through);
1443 return AltosLib.MISSING;
1446 public double gyro_roll() {
1447 if (imu != null && gyro_zero_roll != AltosLib.MISSING) {
1448 return AltosIMU.convert_gyro(imu.gyro_roll - gyro_zero_roll);
1450 return AltosLib.MISSING;
1453 public double gyro_pitch() {
1454 if (imu != null && gyro_zero_pitch != AltosLib.MISSING) {
1455 return AltosIMU.convert_gyro(imu.gyro_pitch - gyro_zero_pitch);
1457 return AltosLib.MISSING;
1460 public double gyro_yaw() {
1461 if (imu != null && gyro_zero_yaw != AltosLib.MISSING) {
1462 return AltosIMU.convert_gyro(imu.gyro_yaw - gyro_zero_yaw);
1464 return AltosLib.MISSING;
1467 public void set_mag(AltosMag mag) {
1468 this.mag = mag.clone();
1471 public double mag_along() {
1473 return AltosMag.convert_gauss(mag.along);
1474 return AltosLib.MISSING;
1477 public double mag_across() {
1479 return AltosMag.convert_gauss(mag.across);
1480 return AltosLib.MISSING;
1483 public double mag_through() {
1485 return AltosMag.convert_gauss(mag.through);
1486 return AltosLib.MISSING;
1489 public AltosMs5607 make_baro() {
1491 baro = new AltosMs5607();
1495 public void set_ms5607(AltosMs5607 ms5607) {
1499 set_pressure(baro.pa);
1500 set_temperature(baro.cc / 100.0);
1504 public void set_ms5607(int pres, int temp) {
1506 baro.set(pres, temp);
1508 set_pressure(baro.pa);
1509 set_temperature(baro.cc / 100.0);
1513 public void set_companion(AltosCompanion companion) {
1514 this.companion = companion;
1517 void update_accel() {
1518 if (accel == AltosLib.MISSING)
1520 if (accel_plus_g == AltosLib.MISSING)
1522 if (accel_minus_g == AltosLib.MISSING)
1525 double counts_per_g = (accel_minus_g - accel_plus_g) / 2.0;
1526 double counts_per_mss = counts_per_g / 9.80665;
1527 acceleration.set_measured((accel_plus_g - accel) / counts_per_mss, time);
1530 public void set_accel_g(double accel_plus_g, double accel_minus_g) {
1531 if (accel_plus_g != AltosLib.MISSING) {
1532 this.accel_plus_g = accel_plus_g;
1533 this.accel_minus_g = accel_minus_g;
1538 public void set_ground_accel(double ground_accel) {
1539 if (ground_accel != AltosLib.MISSING)
1540 this.ground_accel = ground_accel;
1543 public void set_accel(double accel) {
1544 if (accel != AltosLib.MISSING) {
1546 if (state == AltosLib.ao_flight_pad) {
1547 if (ground_accel_avg == AltosLib.MISSING)
1548 ground_accel_avg = accel;
1550 ground_accel_avg = (ground_accel_avg * 7 + accel) / 8;
1556 public void set_temperature(double temperature) {
1557 if (temperature != AltosLib.MISSING) {
1558 this.temperature = temperature;
1563 public void set_battery_voltage(double battery_voltage) {
1564 if (battery_voltage != AltosLib.MISSING) {
1565 this.battery_voltage = battery_voltage;
1570 public void set_pyro_voltage(double pyro_voltage) {
1571 if (pyro_voltage != AltosLib.MISSING) {
1572 this.pyro_voltage = pyro_voltage;
1577 public void set_apogee_voltage(double apogee_voltage) {
1578 if (apogee_voltage != AltosLib.MISSING) {
1579 this.apogee_voltage = apogee_voltage;
1584 public void set_main_voltage(double main_voltage) {
1585 if (main_voltage != AltosLib.MISSING) {
1586 this.main_voltage = main_voltage;
1591 public void set_ignitor_voltage(double[] voltage) {
1592 this.ignitor_voltage = voltage;
1595 public void set_pyro_fired(int fired) {
1596 this.pyro_fired = fired;
1599 public double time_since_boost() {
1600 if (tick == AltosLib.MISSING)
1603 if (boost_tick == AltosLib.MISSING)
1604 return tick / 100.0;
1605 return (tick - boost_tick) / 100.0;
1608 public boolean valid() {
1609 return tick != AltosLib.MISSING && serial != AltosLib.MISSING;
1612 public AltosGPS make_temp_gps(boolean sats) {
1613 if (temp_gps == null) {
1614 temp_gps = new AltosGPS(gps);
1618 if (tick != temp_gps_sat_tick)
1619 temp_gps.cc_gps_sat = null;
1620 temp_gps_sat_tick = tick;
1625 public void set_temp_gps() {
1626 set_gps(temp_gps, gps_sequence + 1);
1627 gps_pending = false;
1631 public AltosState clone() {
1632 AltosState s = new AltosState();
1635 AltosHashSet hash = hashSet();
1636 String onetrip = hash.toString();
1637 AltosHashSet back = AltosHashSet.fromString(onetrip);
1638 AltosState tripstate = AltosState.fromHashSet(back);
1639 AltosHashSet triphash = tripstate.hashSet();
1640 String twotrip = triphash.toString();
1642 if (!onetrip.equals(twotrip)) {
1643 System.out.printf("%s\n%s\n", onetrip, twotrip);
1649 public AltosState () {
1653 public AltosHashSet hashSet() {
1654 AltosHashSet h = new AltosHashSet();
1656 h.putBoolean("valid", true);
1657 h.putInt("set", set);
1658 h.putLong("received_time", received_time);
1659 h.putDouble("time", time);
1660 h.putDouble("prev_time", prev_time);
1661 h.putDouble("time_change", time_change);
1662 h.putInt("tick", tick);
1663 h.putInt("prev_tick", prev_tick);
1664 h.putInt("boost_tick", boost_tick);
1665 h.putInt("state", state);
1666 h.putInt("flight", flight);
1667 h.putInt("serial", serial);
1668 h.putInt("altitude_32", altitude_32);
1669 h.putInt("receiver_serial", receiver_serial);
1670 h.putBoolean("landed", landed);
1671 h.putBoolean("ascent", ascent);
1672 h.putBoolean("boost", boost);
1673 h.putInt("rssi", rssi);
1674 h.putInt("status", status);
1675 h.putInt("device_type", device_type);
1676 h.putInt("config_major", config_major);
1677 h.putInt("config_minor", config_minor);
1678 h.putInt("apogee_delay", apogee_delay);
1679 h.putInt("main_deploy", main_deploy);
1680 h.putInt("flight_log_max", flight_log_max);
1681 h.putHashable("ground_altitude", ground_altitude);
1682 h.putHashable("gps_ground_altitude", gps_ground_altitude);
1683 h.putHashable("ground_pressure", ground_pressure);
1684 h.putHashable("altitude", altitude);
1685 h.putHashable("gps_altitude", gps_altitude);
1686 h.putHashable("gps_ground_speed", gps_ground_speed);
1687 h.putHashable("gps_ascent_rate", gps_ascent_rate);
1688 h.putHashable("gps_course", gps_course);
1689 h.putHashable("gps_speed", gps_speed);
1690 h.putHashable("pressure", pressure);
1691 h.putHashable("speed", speed);
1692 h.putHashable("acceleration", acceleration);
1693 h.putHashable("orient", orient);
1694 h.putHashable("kalman_height", kalman_height);
1695 h.putHashable("kalman_speed", kalman_speed);
1696 h.putHashable("kalman_acceleration", kalman_acceleration);
1698 h.putDouble("battery_voltage",battery_voltage);
1699 h.putDouble("pyro_voltage",pyro_voltage);
1700 h.putDouble("temperature",temperature);
1701 h.putDouble("apogee_voltage",apogee_voltage);
1702 h.putDouble("main_voltage",main_voltage);
1703 h.putDoubleArray("ignitor_voltage",ignitor_voltage);
1704 h.putHashable("gps", gps);
1705 h.putHashable("temp_gps", temp_gps);
1706 h.putInt("temp_gps_sat_tick", temp_gps_sat_tick);
1707 h.putBoolean("gps_pending", gps_pending);
1708 h.putInt("gps_sequence", gps_sequence);
1709 h.putHashable("imu", imu);
1710 h.putHashable("mag", mag);
1712 h.putInt("npad", npad);
1713 h.putInt("gps_waiting", gps_waiting);
1714 h.putBoolean("gps_ready", gps_ready);
1715 h.putInt("ngps", ngps);
1716 h.putHashable("from_pad", from_pad);
1717 h.putDouble("elevation", elevation);
1718 h.putDouble("range", range);
1719 h.putDouble("gps_height", gps_height);
1720 h.putDouble("pad_lat", pad_lat);
1721 h.putDouble("pad_lon", pad_lon);
1722 h.putDouble("pad_alt", pad_alt);
1723 h.putInt("speak_tick", speak_tick);
1724 h.putDouble("speak_altitude", speak_altitude);
1725 h.putString("callsign", callsign);
1726 h.putString("firmware_version", firmware_version);
1727 h.putDouble("accel_plus_g", accel_plus_g);
1728 h.putDouble("accel_minus_g", accel_minus_g);
1729 h.putDouble("accel", accel);
1730 h.putDouble("ground_accel", ground_accel);
1731 h.putDouble("ground_accel_avg", ground_accel_avg);
1732 h.putInt("log_format", log_format);
1733 h.putString("product", product);
1734 h.putHashable("baro", baro);
1735 h.putHashable("companion", companion);
1736 h.putInt("pyro_fired", pyro_fired);
1737 h.putDouble("accel_zero_along", accel_zero_along);
1738 h.putDouble("accel_zero_across", accel_zero_across);
1739 h.putDouble("accel_zero_through", accel_zero_through);
1741 h.putHashable("rotation", rotation);
1742 h.putHashable("ground_rotation", ground_rotation);
1744 h.putInt("pad_orientation", pad_orientation);
1746 h.putDouble("accel_ground_along", accel_ground_along);
1747 h.putDouble("accel_ground_across", accel_ground_across);
1748 h.putDouble("accel_ground_through", accel_ground_through);
1750 h.putDouble("gyro_zero_roll", gyro_zero_roll);
1751 h.putDouble("gyro_zero_pitch", gyro_zero_pitch);
1752 h.putDouble("gyro_zero_yaw", gyro_zero_yaw);
1754 h.putDouble("last_imu_time", last_imu_time);
1758 public AltosState(AltosHashSet h) {
1761 set = h.getInt("set", set);
1762 received_time = h.getLong("received_time", received_time);
1763 time = h.getDouble("time", time);
1764 prev_time = h.getDouble("prev_time", prev_time);
1765 time_change = h.getDouble("time_change", time_change);
1766 tick = h.getInt("tick", tick);
1767 prev_tick = h.getInt("prev_tick", prev_tick);
1768 boost_tick = h.getInt("boost_tick", boost_tick);
1769 state = h.getInt("state", state);
1770 flight = h.getInt("flight", flight);
1771 serial = h.getInt("serial", serial);
1772 altitude_32 = h.getInt("altitude_32", altitude_32);
1773 receiver_serial = h.getInt("receiver_serial", receiver_serial);
1774 landed = h.getBoolean("landed", landed);
1775 ascent = h.getBoolean("ascent", ascent);
1776 boost = h.getBoolean("boost", boost);
1777 rssi = h.getInt("rssi", rssi);
1778 status = h.getInt("status", status);
1779 device_type = h.getInt("device_type", device_type);
1780 config_major = h.getInt("config_major", config_major);
1781 config_minor = h.getInt("config_minor", config_minor);
1782 apogee_delay = h.getInt("apogee_delay", apogee_delay);
1783 main_deploy = h.getInt("main_deploy", main_deploy);
1784 flight_log_max = h.getInt("flight_log_max", flight_log_max);
1785 ground_altitude = AltosCValue_fromHashSet(h.getHash("ground_altitude"), ground_altitude);
1786 gps_ground_altitude = AltosGpsGroundAltitude_fromHashSet(h.getHash("gps_ground_altitude"), gps_ground_altitude);
1787 ground_pressure = AltosGroundPressure_fromHashSet(h.getHash("ground_pressure"), ground_pressure);
1788 altitude = AltosAltitude_fromHashSet(h.getHash("altitude"), altitude);
1789 gps_altitude = AltosGpsAltitude_fromHashSet(h.getHash("gps_altitude"), gps_altitude);
1790 gps_ground_speed = AltosValue_fromHashSet(h.getHash("gps_ground_speed"), gps_ground_speed);
1791 gps_ascent_rate = AltosValue_fromHashSet(h.getHash("gps_ascent_rate"), gps_ascent_rate);
1792 gps_course = AltosValue_fromHashSet(h.getHash("gps_course"), gps_course);
1793 gps_speed = AltosValue_fromHashSet(h.getHash("gps_speed"), gps_speed);
1794 pressure = AltosPressure_fromHashSet(h.getHash("pressure"), pressure);
1795 speed = AltosSpeed_fromHashSet(h.getHash("speed"), speed);
1796 acceleration = AltosAccel_fromHashSet(h.getHash("acceleration"), acceleration);
1797 orient = AltosCValue_fromHashSet(h.getHash("orient"), orient);
1798 kalman_height = AltosValue_fromHashSet(h.getHash("kalman_height"), kalman_height);
1799 kalman_speed = AltosValue_fromHashSet(h.getHash("kalman_speed"), kalman_speed);
1800 kalman_acceleration = AltosValue_fromHashSet(h.getHash("kalman_acceleration"), kalman_acceleration);
1802 battery_voltage = h.getDouble("battery_voltage", battery_voltage);
1803 pyro_voltage = h.getDouble("pyro_voltage", pyro_voltage);
1804 temperature = h.getDouble("temperature", temperature);
1805 apogee_voltage = h.getDouble("apogee_voltage", apogee_voltage);
1806 main_voltage= h.getDouble("main_voltage", main_voltage);
1807 ignitor_voltage = h.getDoubleArray("ignitor_voltage", ignitor_voltage);
1808 gps = AltosGPS.fromHashSet(h.getHash("gps"), gps);
1809 temp_gps = AltosGPS.fromHashSet(h.getHash("temp_gps"), temp_gps);
1810 temp_gps_sat_tick = h.getInt("temp_gps_sat_tick", temp_gps_sat_tick);
1811 gps_pending = h.getBoolean("gps_pending", gps_pending);
1812 gps_sequence = h.getInt("gps_sequence", gps_sequence);
1813 imu = AltosIMU.fromHashSet(h.getHash("imu"), imu);
1814 mag = AltosMag.fromHashSet(h.getHash("mag"), mag);
1816 npad = h.getInt("npad", npad);
1817 gps_waiting = h.getInt("gps_waiting", gps_waiting);
1818 gps_ready = h.getBoolean("gps_ready", gps_ready);
1819 ngps = h.getInt("ngps", ngps);
1820 from_pad = AltosGreatCircle.fromHashSet(h.getHash("from_pad"), from_pad);
1821 elevation = h.getDouble("elevation", elevation);
1822 range = h.getDouble("range", range);
1823 gps_height = h.getDouble("gps_height", gps_height);
1824 pad_lat = h.getDouble("pad_lat", pad_lat);
1825 pad_lon = h.getDouble("pad_lon", pad_lon);
1826 pad_alt = h.getDouble("pad_alt", pad_alt);
1827 speak_tick = h.getInt("speak_tick", speak_tick);
1828 speak_altitude = h.getDouble("speak_altitude", speak_altitude);
1829 callsign = h.getString("callsign", callsign);
1830 firmware_version = h.getString("firmware_version", firmware_version);
1831 accel_plus_g = h.getDouble("accel_plus_g", accel_plus_g);
1832 accel_minus_g = h.getDouble("accel_minus_g", accel_minus_g);
1833 accel = h.getDouble("accel", accel);
1834 ground_accel = h.getDouble("ground_accel", ground_accel);
1835 ground_accel_avg = h.getDouble("ground_accel_avg", ground_accel_avg);
1836 log_format = h.getInt("log_format", log_format);
1837 product = h.getString("product", product);
1838 baro = AltosMs5607.fromHashSet(h.getHash("baro"), baro);
1839 companion = AltosCompanion.fromHashSet(h.getHash("companion"), companion);
1840 pyro_fired = h.getInt("pyro_fired", pyro_fired);
1841 accel_zero_along = h.getDouble("accel_zero_along", accel_zero_along);
1842 accel_zero_across = h.getDouble("accel_zero_across", accel_zero_across);
1843 accel_zero_through = h.getDouble("accel_zero_through", accel_zero_through);
1845 rotation = AltosRotation.fromHashSet(h.getHash("rotation"), rotation);
1846 ground_rotation = AltosRotation.fromHashSet(h.getHash("ground_rotation"), ground_rotation);
1848 pad_orientation = h.getInt("pad_orientation", pad_orientation);
1850 accel_ground_along = h.getDouble("accel_ground_along", accel_ground_along);
1851 accel_ground_across = h.getDouble("accel_ground_across", accel_ground_across);
1852 accel_ground_through = h.getDouble("accel_ground_through", accel_ground_through);
1854 gyro_zero_roll = h.getDouble("gyro_zero_roll", gyro_zero_roll);
1855 gyro_zero_pitch = h.getDouble("gyro_zero_pitch", gyro_zero_pitch);
1856 gyro_zero_yaw = h.getDouble("gyro_zero_yaw", gyro_zero_yaw);
1858 last_imu_time = h.getDouble("last_imu_time", last_imu_time);
1861 public static AltosState fromHashSet(AltosHashSet h) {
1864 if (!h.getBoolean("valid", false))
1866 return new AltosState(h);