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 int log_space;
836 public String product;
838 public AltosMs5607 baro;
840 public AltosCompanion companion;
842 public int pyro_fired;
844 public void set_npad(int npad) {
846 gps_waiting = MIN_PAD_SAMPLES - npad;
847 if (this.gps_waiting < 0)
849 gps_ready = gps_waiting == 0;
855 received_time = System.currentTimeMillis();
856 time = AltosLib.MISSING;
857 time_change = AltosLib.MISSING;
858 prev_time = AltosLib.MISSING;
859 tick = AltosLib.MISSING;
860 prev_tick = AltosLib.MISSING;
861 boost_tick = AltosLib.MISSING;
862 state = AltosLib.ao_flight_invalid;
863 flight = AltosLib.MISSING;
866 rssi = AltosLib.MISSING;
868 device_type = AltosLib.MISSING;
869 config_major = AltosLib.MISSING;
870 config_minor = AltosLib.MISSING;
871 apogee_delay = AltosLib.MISSING;
872 main_deploy = AltosLib.MISSING;
873 flight_log_max = AltosLib.MISSING;
875 ground_altitude = new AltosCValue();
876 ground_pressure = new AltosGroundPressure();
877 altitude = new AltosAltitude();
878 pressure = new AltosPressure();
879 speed = new AltosSpeed();
880 acceleration = new AltosAccel();
881 orient = new AltosCValue();
883 temperature = AltosLib.MISSING;
884 battery_voltage = AltosLib.MISSING;
885 pyro_voltage = AltosLib.MISSING;
886 apogee_voltage = AltosLib.MISSING;
887 main_voltage = AltosLib.MISSING;
888 ignitor_voltage = null;
890 kalman_height = new AltosValue();
891 kalman_speed = new AltosValue();
892 kalman_acceleration = new AltosValue();
896 temp_gps_sat_tick = 0;
901 last_imu_time = AltosLib.MISSING;
903 ground_rotation = null;
906 accel_zero_along = AltosLib.MISSING;
907 accel_zero_across = AltosLib.MISSING;
908 accel_zero_through = AltosLib.MISSING;
910 accel_ground_along = AltosLib.MISSING;
911 accel_ground_across = AltosLib.MISSING;
912 accel_ground_through = AltosLib.MISSING;
914 pad_orientation = AltosLib.MISSING;
916 gyro_zero_roll = AltosLib.MISSING;
917 gyro_zero_pitch = AltosLib.MISSING;
918 gyro_zero_yaw = AltosLib.MISSING;
924 elevation = AltosLib.MISSING;
925 range = AltosLib.MISSING;
926 gps_height = AltosLib.MISSING;
928 pad_lat = AltosLib.MISSING;
929 pad_lon = AltosLib.MISSING;
930 pad_alt = AltosLib.MISSING;
932 gps_altitude = new AltosGpsAltitude();
933 gps_ground_altitude = new AltosGpsGroundAltitude();
934 gps_ground_speed = new AltosValue();
935 gps_speed = new AltosValue();
936 gps_ascent_rate = new AltosValue();
937 gps_course = new AltosValue();
939 speak_tick = AltosLib.MISSING;
940 speak_altitude = AltosLib.MISSING;
943 firmware_version = null;
945 accel_plus_g = AltosLib.MISSING;
946 accel_minus_g = AltosLib.MISSING;
947 accel = AltosLib.MISSING;
949 ground_accel = AltosLib.MISSING;
950 ground_accel_avg = AltosLib.MISSING;
952 log_format = AltosLib.MISSING;
953 log_space = AltosLib.MISSING;
955 serial = AltosLib.MISSING;
956 receiver_serial = AltosLib.MISSING;
957 altitude_32 = AltosLib.MISSING;
965 void finish_update() {
968 ground_altitude.finish_update();
969 altitude.finish_update();
970 pressure.finish_update();
971 speed.finish_update();
972 acceleration.finish_update();
973 orient.finish_update();
975 kalman_height.finish_update();
976 kalman_speed.finish_update();
977 kalman_acceleration.finish_update();
980 void copy(AltosState old) {
987 received_time = old.received_time;
989 time_change = old.time_change;
990 prev_time = old.time;
993 prev_tick = old.tick;
994 boost_tick = old.boost_tick;
1002 status = old.status;
1003 device_type = old.device_type;
1004 config_major = old.config_major;
1005 config_minor = old.config_minor;
1006 apogee_delay = old.apogee_delay;
1007 main_deploy = old.main_deploy;
1008 flight_log_max = old.flight_log_max;
1012 ground_pressure.copy(old.ground_pressure);
1013 ground_altitude.copy(old.ground_altitude);
1014 altitude.copy(old.altitude);
1015 pressure.copy(old.pressure);
1016 speed.copy(old.speed);
1017 acceleration.copy(old.acceleration);
1018 orient.copy(old.orient);
1020 battery_voltage = old.battery_voltage;
1021 pyro_voltage = old.pyro_voltage;
1022 temperature = old.temperature;
1023 apogee_voltage = old.apogee_voltage;
1024 main_voltage = old.main_voltage;
1025 ignitor_voltage = old.ignitor_voltage;
1027 kalman_height.copy(old.kalman_height);
1028 kalman_speed.copy(old.kalman_speed);
1029 kalman_acceleration.copy(old.kalman_acceleration);
1031 if (old.gps != null)
1032 gps = old.gps.clone();
1035 if (old.temp_gps != null)
1036 temp_gps = old.temp_gps.clone();
1039 temp_gps_sat_tick = old.temp_gps_sat_tick;
1040 gps_sequence = old.gps_sequence;
1041 gps_pending = old.gps_pending;
1043 if (old.imu != null)
1044 imu = old.imu.clone();
1047 last_imu_time = old.last_imu_time;
1049 if (old.rotation != null)
1050 rotation = new AltosRotation (old.rotation);
1052 if (old.ground_rotation != null) {
1053 ground_rotation = new AltosRotation(old.ground_rotation);
1056 accel_zero_along = old.accel_zero_along;
1057 accel_zero_across = old.accel_zero_across;
1058 accel_zero_through = old.accel_zero_through;
1060 accel_ground_along = old.accel_ground_along;
1061 accel_ground_across = old.accel_ground_across;
1062 accel_ground_through = old.accel_ground_through;
1063 pad_orientation = old.pad_orientation;
1065 gyro_zero_roll = old.gyro_zero_roll;
1066 gyro_zero_pitch = old.gyro_zero_pitch;
1067 gyro_zero_yaw = old.gyro_zero_yaw;
1069 if (old.mag != null)
1070 mag = old.mag.clone();
1075 gps_waiting = old.gps_waiting;
1076 gps_ready = old.gps_ready;
1079 if (old.from_pad != null)
1080 from_pad = old.from_pad.clone();
1084 elevation = old.elevation;
1087 gps_height = old.gps_height;
1089 gps_altitude.copy(old.gps_altitude);
1090 gps_ground_altitude.copy(old.gps_ground_altitude);
1091 gps_ground_speed.copy(old.gps_ground_speed);
1092 gps_ascent_rate.copy(old.gps_ascent_rate);
1093 gps_course.copy(old.gps_course);
1094 gps_speed.copy(old.gps_speed);
1096 pad_lat = old.pad_lat;
1097 pad_lon = old.pad_lon;
1098 pad_alt = old.pad_alt;
1100 speak_tick = old.speak_tick;
1101 speak_altitude = old.speak_altitude;
1103 callsign = old.callsign;
1104 firmware_version = old.firmware_version;
1106 accel_plus_g = old.accel_plus_g;
1107 accel_minus_g = old.accel_minus_g;
1109 ground_accel = old.ground_accel;
1110 ground_accel_avg = old.ground_accel_avg;
1112 log_format = old.log_format;
1113 log_space = old.log_space;
1114 product = old.product;
1115 serial = old.serial;
1116 receiver_serial = old.receiver_serial;
1117 altitude_32 = old.altitude_32;
1120 companion = old.companion;
1122 pyro_fired = old.pyro_fired;
1125 void update_time() {
1129 elevation = AltosLib.MISSING;
1130 range = AltosLib.MISSING;
1135 if (gps.locked && gps.nsat >= 4) {
1136 /* Track consecutive 'good' gps reports, waiting for 10 of them */
1137 if (state == AltosLib.ao_flight_pad || state == AltosLib.ao_flight_stateless) {
1139 if (pad_lat != AltosLib.MISSING && (npad < 10 || state == AltosLib.ao_flight_pad)) {
1140 pad_lat = (pad_lat * 31 + gps.lat) / 32;
1141 pad_lon = (pad_lon * 31 + gps.lon) / 32;
1142 gps_ground_altitude.set_filtered(gps.alt, time);
1145 if (pad_lat == AltosLib.MISSING) {
1148 gps_ground_altitude.set(gps.alt, time);
1150 gps_altitude.set(gps.alt, time);
1151 if (gps.climb_rate != AltosLib.MISSING)
1152 gps_ascent_rate.set(gps.climb_rate, time);
1153 if (gps.ground_speed != AltosLib.MISSING)
1154 gps_ground_speed.set(gps.ground_speed, time);
1155 if (gps.climb_rate != AltosLib.MISSING && gps.ground_speed != AltosLib.MISSING)
1156 gps_speed.set(Math.sqrt(gps.ground_speed * gps.ground_speed +
1157 gps.climb_rate * gps.climb_rate), time);
1158 if (gps.course != AltosLib.MISSING)
1159 gps_course.set(gps.course, time);
1161 if (gps.lat != 0 && gps.lon != 0 &&
1162 pad_lat != AltosLib.MISSING &&
1163 pad_lon != AltosLib.MISSING)
1165 double h = height();
1167 if (h == AltosLib.MISSING)
1169 from_pad = new AltosGreatCircle(pad_lat, pad_lon, 0, gps.lat, gps.lon, h);
1170 elevation = from_pad.elevation;
1171 range = from_pad.range;
1175 public void set_tick(int new_tick) {
1176 if (new_tick != AltosLib.MISSING) {
1177 if (prev_tick != AltosLib.MISSING) {
1178 while (new_tick < prev_tick - 1000) {
1183 time = tick / 100.0;
1184 time_change = time - prev_time;
1188 public void set_boost_tick(int boost_tick) {
1189 if (boost_tick != AltosLib.MISSING)
1190 this.boost_tick = boost_tick;
1193 public String state_name() {
1194 return AltosLib.state_name(state);
1197 public void set_product(String product) {
1198 this.product = product;
1201 public void set_state(int state) {
1202 if (state != AltosLib.ao_flight_invalid) {
1204 ascent = (AltosLib.ao_flight_boost <= state &&
1205 state <= AltosLib.ao_flight_coast);
1206 boost = (AltosLib.ao_flight_boost == state);
1210 public int state() {
1214 public void set_device_type(int device_type) {
1215 this.device_type = device_type;
1216 switch (device_type) {
1217 case AltosLib.product_telegps:
1218 this.state = AltosLib.ao_flight_stateless;
1223 public void set_log_format(int log_format) {
1224 this.log_format = log_format;
1225 switch (log_format) {
1226 case AltosLib.AO_LOG_FORMAT_TELEGPS:
1227 this.state = AltosLib.ao_flight_stateless;
1232 public void set_log_space(int log_space) {
1233 this.log_space = log_space;
1236 public void set_flight_params(int apogee_delay, int main_deploy) {
1237 this.apogee_delay = apogee_delay;
1238 this.main_deploy = main_deploy;
1241 public void set_config(int major, int minor, int flight_log_max) {
1242 config_major = major;
1243 config_minor = minor;
1244 this.flight_log_max = flight_log_max;
1247 public void set_callsign(String callsign) {
1248 this.callsign = callsign;
1251 public void set_firmware_version(String version) {
1252 firmware_version = version;
1255 public int compare_version(String other_version) {
1256 if (firmware_version == null)
1257 return AltosLib.MISSING;
1258 return AltosLib.compare_version(firmware_version, other_version);
1261 private void re_init() {
1262 int bt = boost_tick;
1263 int rs = receiver_serial;
1266 receiver_serial = rs;
1269 public void set_flight(int flight) {
1271 /* When the flight changes, reset the state */
1272 if (flight != AltosLib.MISSING) {
1273 if (this.flight != AltosLib.MISSING &&
1274 this.flight != flight) {
1277 this.flight = flight;
1281 public void set_serial(int serial) {
1282 /* When the serial changes, reset the state */
1283 if (serial != AltosLib.MISSING) {
1284 if (this.serial != AltosLib.MISSING &&
1285 this.serial != serial) {
1288 this.serial = serial;
1292 public void set_receiver_serial(int serial) {
1293 if (serial != AltosLib.MISSING)
1294 receiver_serial = serial;
1297 public boolean altitude_32() {
1298 return altitude_32 == 1;
1301 public void set_altitude_32(int altitude_32) {
1302 if (altitude_32 != AltosLib.MISSING)
1303 this.altitude_32 = altitude_32;
1307 if (rssi == AltosLib.MISSING)
1312 public void set_rssi(int rssi, int status) {
1313 if (rssi != AltosLib.MISSING) {
1315 this.status = status;
1319 public void set_received_time(long ms) {
1323 public void set_gps(AltosGPS gps, int sequence) {
1325 this.gps = gps.clone();
1326 gps_sequence = sequence;
1333 public double accel_zero_along;
1334 public double accel_zero_across;
1335 public double accel_zero_through;
1337 public AltosRotation rotation;
1338 public AltosRotation ground_rotation;
1340 public void set_accel_zero(double zero_along, double zero_across, double zero_through) {
1341 if (zero_along != AltosLib.MISSING) {
1342 accel_zero_along = zero_along;
1343 accel_zero_across = zero_across;
1344 accel_zero_through = zero_through;
1348 public int pad_orientation;
1350 public double accel_ground_along, accel_ground_across, accel_ground_through;
1352 void update_pad_rotation() {
1353 if (pad_orientation != AltosLib.MISSING && accel_ground_along != AltosLib.MISSING) {
1354 rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - accel_zero_across),
1355 AltosIMU.convert_accel(accel_ground_through - accel_zero_through),
1356 AltosIMU.convert_accel(accel_ground_along - accel_zero_along),
1358 ground_rotation = rotation;
1359 orient.set_computed(rotation.tilt(), time);
1363 public void set_accel_ground(double ground_along, double ground_across, double ground_through) {
1364 accel_ground_along = ground_along;
1365 accel_ground_across = ground_across;
1366 accel_ground_through = ground_through;
1367 update_pad_rotation();
1370 public void set_pad_orientation(int pad_orientation) {
1371 this.pad_orientation = pad_orientation;
1372 update_pad_rotation();
1375 public double gyro_zero_roll;
1376 public double gyro_zero_pitch;
1377 public double gyro_zero_yaw;
1379 public void set_gyro_zero(double roll, double pitch, double yaw) {
1380 if (roll != AltosLib.MISSING) {
1381 gyro_zero_roll = roll;
1382 gyro_zero_pitch = pitch;
1383 gyro_zero_yaw = yaw;
1387 public double last_imu_time;
1389 private double radians(double degrees) {
1390 if (degrees == AltosLib.MISSING)
1391 return AltosLib.MISSING;
1392 return degrees * Math.PI / 180.0;
1395 private void update_orient() {
1396 if (last_imu_time != AltosLib.MISSING) {
1397 double t = time - last_imu_time;
1399 double pitch = radians(gyro_pitch());
1400 double yaw = radians(gyro_yaw());
1401 double roll = radians(gyro_roll());
1403 if (t > 0 & pitch != AltosLib.MISSING && rotation != null) {
1404 rotation.rotate(t, pitch, yaw, roll);
1405 orient.set_computed(rotation.tilt(), time);
1408 last_imu_time = time;
1411 public void set_imu(AltosIMU imu) {
1418 private double gyro_zero_overflow(double first) {
1419 double v = first / 128.0;
1427 public void check_imu_wrap(AltosIMU imu) {
1428 if (this.imu == null) {
1429 gyro_zero_roll += gyro_zero_overflow(imu.gyro_roll);
1430 gyro_zero_pitch += gyro_zero_overflow(imu.gyro_pitch);
1431 gyro_zero_yaw += gyro_zero_overflow(imu.gyro_yaw);
1435 public double accel_along() {
1436 if (imu != null && accel_zero_along != AltosLib.MISSING)
1437 return AltosIMU.convert_accel(imu.accel_along - accel_zero_along);
1438 return AltosLib.MISSING;
1441 public double accel_across() {
1442 if (imu != null && accel_zero_across != AltosLib.MISSING)
1443 return AltosIMU.convert_accel(imu.accel_across - accel_zero_across);
1444 return AltosLib.MISSING;
1447 public double accel_through() {
1448 if (imu != null && accel_zero_through != AltosLib.MISSING)
1449 return AltosIMU.convert_accel(imu.accel_through - accel_zero_through);
1450 return AltosLib.MISSING;
1453 public double gyro_roll() {
1454 if (imu != null && gyro_zero_roll != AltosLib.MISSING) {
1455 return AltosIMU.convert_gyro(imu.gyro_roll - gyro_zero_roll);
1457 return AltosLib.MISSING;
1460 public double gyro_pitch() {
1461 if (imu != null && gyro_zero_pitch != AltosLib.MISSING) {
1462 return AltosIMU.convert_gyro(imu.gyro_pitch - gyro_zero_pitch);
1464 return AltosLib.MISSING;
1467 public double gyro_yaw() {
1468 if (imu != null && gyro_zero_yaw != AltosLib.MISSING) {
1469 return AltosIMU.convert_gyro(imu.gyro_yaw - gyro_zero_yaw);
1471 return AltosLib.MISSING;
1474 public void set_mag(AltosMag mag) {
1475 this.mag = mag.clone();
1478 public double mag_along() {
1480 return AltosMag.convert_gauss(mag.along);
1481 return AltosLib.MISSING;
1484 public double mag_across() {
1486 return AltosMag.convert_gauss(mag.across);
1487 return AltosLib.MISSING;
1490 public double mag_through() {
1492 return AltosMag.convert_gauss(mag.through);
1493 return AltosLib.MISSING;
1496 public AltosMs5607 make_baro() {
1498 baro = new AltosMs5607();
1502 public void set_ms5607(AltosMs5607 ms5607) {
1506 set_pressure(baro.pa);
1507 set_temperature(baro.cc / 100.0);
1511 public void set_ms5607(int pres, int temp) {
1513 baro.set(pres, temp);
1515 set_pressure(baro.pa);
1516 set_temperature(baro.cc / 100.0);
1520 public void set_companion(AltosCompanion companion) {
1521 this.companion = companion;
1524 void update_accel() {
1525 if (accel == AltosLib.MISSING)
1527 if (accel_plus_g == AltosLib.MISSING)
1529 if (accel_minus_g == AltosLib.MISSING)
1532 double counts_per_g = (accel_minus_g - accel_plus_g) / 2.0;
1533 double counts_per_mss = counts_per_g / 9.80665;
1534 acceleration.set_measured((accel_plus_g - accel) / counts_per_mss, time);
1537 public void set_accel_g(double accel_plus_g, double accel_minus_g) {
1538 if (accel_plus_g != AltosLib.MISSING) {
1539 this.accel_plus_g = accel_plus_g;
1540 this.accel_minus_g = accel_minus_g;
1545 public void set_ground_accel(double ground_accel) {
1546 if (ground_accel != AltosLib.MISSING)
1547 this.ground_accel = ground_accel;
1550 public void set_accel(double accel) {
1551 if (accel != AltosLib.MISSING) {
1553 if (state == AltosLib.ao_flight_pad) {
1554 if (ground_accel_avg == AltosLib.MISSING)
1555 ground_accel_avg = accel;
1557 ground_accel_avg = (ground_accel_avg * 7 + accel) / 8;
1563 public void set_temperature(double temperature) {
1564 if (temperature != AltosLib.MISSING) {
1565 this.temperature = temperature;
1570 public void set_battery_voltage(double battery_voltage) {
1571 if (battery_voltage != AltosLib.MISSING) {
1572 this.battery_voltage = battery_voltage;
1577 public void set_pyro_voltage(double pyro_voltage) {
1578 if (pyro_voltage != AltosLib.MISSING) {
1579 this.pyro_voltage = pyro_voltage;
1584 public void set_apogee_voltage(double apogee_voltage) {
1585 if (apogee_voltage != AltosLib.MISSING) {
1586 this.apogee_voltage = apogee_voltage;
1591 public void set_main_voltage(double main_voltage) {
1592 if (main_voltage != AltosLib.MISSING) {
1593 this.main_voltage = main_voltage;
1598 public void set_ignitor_voltage(double[] voltage) {
1599 this.ignitor_voltage = voltage;
1602 public void set_pyro_fired(int fired) {
1603 this.pyro_fired = fired;
1606 public double time_since_boost() {
1607 if (tick == AltosLib.MISSING)
1610 if (boost_tick == AltosLib.MISSING)
1611 return tick / 100.0;
1612 return (tick - boost_tick) / 100.0;
1615 public boolean valid() {
1616 return tick != AltosLib.MISSING && serial != AltosLib.MISSING;
1619 public AltosGPS make_temp_gps(boolean sats) {
1620 if (temp_gps == null) {
1621 temp_gps = new AltosGPS(gps);
1625 if (tick != temp_gps_sat_tick)
1626 temp_gps.cc_gps_sat = null;
1627 temp_gps_sat_tick = tick;
1632 public void set_temp_gps() {
1633 set_gps(temp_gps, gps_sequence + 1);
1634 gps_pending = false;
1638 public AltosState clone() {
1639 AltosState s = new AltosState();
1642 AltosHashSet hash = hashSet();
1643 String onetrip = hash.toString();
1644 AltosHashSet back = AltosHashSet.fromString(onetrip);
1645 AltosState tripstate = AltosState.fromHashSet(back);
1646 AltosHashSet triphash = tripstate.hashSet();
1647 String twotrip = triphash.toString();
1649 if (!onetrip.equals(twotrip)) {
1650 System.out.printf("%s\n%s\n", onetrip, twotrip);
1656 public AltosState () {
1660 public AltosHashSet hashSet() {
1661 AltosHashSet h = new AltosHashSet();
1663 h.putBoolean("valid", true);
1664 h.putInt("set", set);
1665 h.putLong("received_time", received_time);
1666 h.putDouble("time", time);
1667 h.putDouble("prev_time", prev_time);
1668 h.putDouble("time_change", time_change);
1669 h.putInt("tick", tick);
1670 h.putInt("prev_tick", prev_tick);
1671 h.putInt("boost_tick", boost_tick);
1672 h.putInt("state", state);
1673 h.putInt("flight", flight);
1674 h.putInt("serial", serial);
1675 h.putInt("altitude_32", altitude_32);
1676 h.putInt("receiver_serial", receiver_serial);
1677 h.putBoolean("landed", landed);
1678 h.putBoolean("ascent", ascent);
1679 h.putBoolean("boost", boost);
1680 h.putInt("rssi", rssi);
1681 h.putInt("status", status);
1682 h.putInt("device_type", device_type);
1683 h.putInt("config_major", config_major);
1684 h.putInt("config_minor", config_minor);
1685 h.putInt("apogee_delay", apogee_delay);
1686 h.putInt("main_deploy", main_deploy);
1687 h.putInt("flight_log_max", flight_log_max);
1688 h.putHashable("ground_altitude", ground_altitude);
1689 h.putHashable("gps_ground_altitude", gps_ground_altitude);
1690 h.putHashable("ground_pressure", ground_pressure);
1691 h.putHashable("altitude", altitude);
1692 h.putHashable("gps_altitude", gps_altitude);
1693 h.putHashable("gps_ground_speed", gps_ground_speed);
1694 h.putHashable("gps_ascent_rate", gps_ascent_rate);
1695 h.putHashable("gps_course", gps_course);
1696 h.putHashable("gps_speed", gps_speed);
1697 h.putHashable("pressure", pressure);
1698 h.putHashable("speed", speed);
1699 h.putHashable("acceleration", acceleration);
1700 h.putHashable("orient", orient);
1701 h.putHashable("kalman_height", kalman_height);
1702 h.putHashable("kalman_speed", kalman_speed);
1703 h.putHashable("kalman_acceleration", kalman_acceleration);
1705 h.putDouble("battery_voltage",battery_voltage);
1706 h.putDouble("pyro_voltage",pyro_voltage);
1707 h.putDouble("temperature",temperature);
1708 h.putDouble("apogee_voltage",apogee_voltage);
1709 h.putDouble("main_voltage",main_voltage);
1710 h.putDoubleArray("ignitor_voltage",ignitor_voltage);
1711 h.putHashable("gps", gps);
1712 h.putHashable("temp_gps", temp_gps);
1713 h.putInt("temp_gps_sat_tick", temp_gps_sat_tick);
1714 h.putBoolean("gps_pending", gps_pending);
1715 h.putInt("gps_sequence", gps_sequence);
1716 h.putHashable("imu", imu);
1717 h.putHashable("mag", mag);
1719 h.putInt("npad", npad);
1720 h.putInt("gps_waiting", gps_waiting);
1721 h.putBoolean("gps_ready", gps_ready);
1722 h.putInt("ngps", ngps);
1723 h.putHashable("from_pad", from_pad);
1724 h.putDouble("elevation", elevation);
1725 h.putDouble("range", range);
1726 h.putDouble("gps_height", gps_height);
1727 h.putDouble("pad_lat", pad_lat);
1728 h.putDouble("pad_lon", pad_lon);
1729 h.putDouble("pad_alt", pad_alt);
1730 h.putInt("speak_tick", speak_tick);
1731 h.putDouble("speak_altitude", speak_altitude);
1732 h.putString("callsign", callsign);
1733 h.putString("firmware_version", firmware_version);
1734 h.putDouble("accel_plus_g", accel_plus_g);
1735 h.putDouble("accel_minus_g", accel_minus_g);
1736 h.putDouble("accel", accel);
1737 h.putDouble("ground_accel", ground_accel);
1738 h.putDouble("ground_accel_avg", ground_accel_avg);
1739 h.putInt("log_format", log_format);
1740 h.putInt("log_space", log_space);
1741 h.putString("product", product);
1742 h.putHashable("baro", baro);
1743 h.putHashable("companion", companion);
1744 h.putInt("pyro_fired", pyro_fired);
1745 h.putDouble("accel_zero_along", accel_zero_along);
1746 h.putDouble("accel_zero_across", accel_zero_across);
1747 h.putDouble("accel_zero_through", accel_zero_through);
1749 h.putHashable("rotation", rotation);
1750 h.putHashable("ground_rotation", ground_rotation);
1752 h.putInt("pad_orientation", pad_orientation);
1754 h.putDouble("accel_ground_along", accel_ground_along);
1755 h.putDouble("accel_ground_across", accel_ground_across);
1756 h.putDouble("accel_ground_through", accel_ground_through);
1758 h.putDouble("gyro_zero_roll", gyro_zero_roll);
1759 h.putDouble("gyro_zero_pitch", gyro_zero_pitch);
1760 h.putDouble("gyro_zero_yaw", gyro_zero_yaw);
1762 h.putDouble("last_imu_time", last_imu_time);
1766 public AltosState(AltosHashSet h) {
1769 set = h.getInt("set", set);
1770 received_time = h.getLong("received_time", received_time);
1771 time = h.getDouble("time", time);
1772 prev_time = h.getDouble("prev_time", prev_time);
1773 time_change = h.getDouble("time_change", time_change);
1774 tick = h.getInt("tick", tick);
1775 prev_tick = h.getInt("prev_tick", prev_tick);
1776 boost_tick = h.getInt("boost_tick", boost_tick);
1777 state = h.getInt("state", state);
1778 flight = h.getInt("flight", flight);
1779 serial = h.getInt("serial", serial);
1780 altitude_32 = h.getInt("altitude_32", altitude_32);
1781 receiver_serial = h.getInt("receiver_serial", receiver_serial);
1782 landed = h.getBoolean("landed", landed);
1783 ascent = h.getBoolean("ascent", ascent);
1784 boost = h.getBoolean("boost", boost);
1785 rssi = h.getInt("rssi", rssi);
1786 status = h.getInt("status", status);
1787 device_type = h.getInt("device_type", device_type);
1788 config_major = h.getInt("config_major", config_major);
1789 config_minor = h.getInt("config_minor", config_minor);
1790 apogee_delay = h.getInt("apogee_delay", apogee_delay);
1791 main_deploy = h.getInt("main_deploy", main_deploy);
1792 flight_log_max = h.getInt("flight_log_max", flight_log_max);
1793 ground_altitude = AltosCValue_fromHashSet(h.getHash("ground_altitude"), ground_altitude);
1794 gps_ground_altitude = AltosGpsGroundAltitude_fromHashSet(h.getHash("gps_ground_altitude"), gps_ground_altitude);
1795 ground_pressure = AltosGroundPressure_fromHashSet(h.getHash("ground_pressure"), ground_pressure);
1796 altitude = AltosAltitude_fromHashSet(h.getHash("altitude"), altitude);
1797 gps_altitude = AltosGpsAltitude_fromHashSet(h.getHash("gps_altitude"), gps_altitude);
1798 gps_ground_speed = AltosValue_fromHashSet(h.getHash("gps_ground_speed"), gps_ground_speed);
1799 gps_ascent_rate = AltosValue_fromHashSet(h.getHash("gps_ascent_rate"), gps_ascent_rate);
1800 gps_course = AltosValue_fromHashSet(h.getHash("gps_course"), gps_course);
1801 gps_speed = AltosValue_fromHashSet(h.getHash("gps_speed"), gps_speed);
1802 pressure = AltosPressure_fromHashSet(h.getHash("pressure"), pressure);
1803 speed = AltosSpeed_fromHashSet(h.getHash("speed"), speed);
1804 acceleration = AltosAccel_fromHashSet(h.getHash("acceleration"), acceleration);
1805 orient = AltosCValue_fromHashSet(h.getHash("orient"), orient);
1806 kalman_height = AltosValue_fromHashSet(h.getHash("kalman_height"), kalman_height);
1807 kalman_speed = AltosValue_fromHashSet(h.getHash("kalman_speed"), kalman_speed);
1808 kalman_acceleration = AltosValue_fromHashSet(h.getHash("kalman_acceleration"), kalman_acceleration);
1810 battery_voltage = h.getDouble("battery_voltage", battery_voltage);
1811 pyro_voltage = h.getDouble("pyro_voltage", pyro_voltage);
1812 temperature = h.getDouble("temperature", temperature);
1813 apogee_voltage = h.getDouble("apogee_voltage", apogee_voltage);
1814 main_voltage= h.getDouble("main_voltage", main_voltage);
1815 ignitor_voltage = h.getDoubleArray("ignitor_voltage", ignitor_voltage);
1816 gps = AltosGPS.fromHashSet(h.getHash("gps"), gps);
1817 temp_gps = AltosGPS.fromHashSet(h.getHash("temp_gps"), temp_gps);
1818 temp_gps_sat_tick = h.getInt("temp_gps_sat_tick", temp_gps_sat_tick);
1819 gps_pending = h.getBoolean("gps_pending", gps_pending);
1820 gps_sequence = h.getInt("gps_sequence", gps_sequence);
1821 imu = AltosIMU.fromHashSet(h.getHash("imu"), imu);
1822 mag = AltosMag.fromHashSet(h.getHash("mag"), mag);
1824 npad = h.getInt("npad", npad);
1825 gps_waiting = h.getInt("gps_waiting", gps_waiting);
1826 gps_ready = h.getBoolean("gps_ready", gps_ready);
1827 ngps = h.getInt("ngps", ngps);
1828 from_pad = AltosGreatCircle.fromHashSet(h.getHash("from_pad"), from_pad);
1829 elevation = h.getDouble("elevation", elevation);
1830 range = h.getDouble("range", range);
1831 gps_height = h.getDouble("gps_height", gps_height);
1832 pad_lat = h.getDouble("pad_lat", pad_lat);
1833 pad_lon = h.getDouble("pad_lon", pad_lon);
1834 pad_alt = h.getDouble("pad_alt", pad_alt);
1835 speak_tick = h.getInt("speak_tick", speak_tick);
1836 speak_altitude = h.getDouble("speak_altitude", speak_altitude);
1837 callsign = h.getString("callsign", callsign);
1838 firmware_version = h.getString("firmware_version", firmware_version);
1839 accel_plus_g = h.getDouble("accel_plus_g", accel_plus_g);
1840 accel_minus_g = h.getDouble("accel_minus_g", accel_minus_g);
1841 accel = h.getDouble("accel", accel);
1842 ground_accel = h.getDouble("ground_accel", ground_accel);
1843 ground_accel_avg = h.getDouble("ground_accel_avg", ground_accel_avg);
1844 log_format = h.getInt("log_format", log_format);
1845 log_space = h.getInt("log_space", log_space);
1846 product = h.getString("product", product);
1847 baro = AltosMs5607.fromHashSet(h.getHash("baro"), baro);
1848 companion = AltosCompanion.fromHashSet(h.getHash("companion"), companion);
1849 pyro_fired = h.getInt("pyro_fired", pyro_fired);
1850 accel_zero_along = h.getDouble("accel_zero_along", accel_zero_along);
1851 accel_zero_across = h.getDouble("accel_zero_across", accel_zero_across);
1852 accel_zero_through = h.getDouble("accel_zero_through", accel_zero_through);
1854 rotation = AltosRotation.fromHashSet(h.getHash("rotation"), rotation);
1855 ground_rotation = AltosRotation.fromHashSet(h.getHash("ground_rotation"), ground_rotation);
1857 pad_orientation = h.getInt("pad_orientation", pad_orientation);
1859 accel_ground_along = h.getDouble("accel_ground_along", accel_ground_along);
1860 accel_ground_across = h.getDouble("accel_ground_across", accel_ground_across);
1861 accel_ground_through = h.getDouble("accel_ground_through", accel_ground_through);
1863 gyro_zero_roll = h.getDouble("gyro_zero_roll", gyro_zero_roll);
1864 gyro_zero_pitch = h.getDouble("gyro_zero_pitch", gyro_zero_pitch);
1865 gyro_zero_yaw = h.getDouble("gyro_zero_yaw", gyro_zero_yaw);
1867 last_imu_time = h.getDouble("last_imu_time", last_imu_time);
1870 public static AltosState fromHashSet(AltosHashSet h) {
1873 if (!h.getBoolean("valid", false))
1875 return new AltosState(h);