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_4;
24 public class AltosState implements Cloneable {
26 public static final int set_position = 1;
27 public static final int set_gps = 2;
28 public static final int set_data = 4;
32 static final double ascent_filter_len = 0.5;
33 static final double descent_filter_len = 0.5;
37 public long received_time;
40 public double prev_time;
41 public double time_change;
43 private int prev_tick;
44 public int boost_tick;
48 private double prev_value;
49 private double max_value;
50 private double set_time;
51 private double prev_set_time;
53 boolean can_max() { return true; }
55 void set(double new_value, double time) {
56 if (new_value != AltosLib.MISSING) {
58 if (can_max() && (max_value == AltosLib.MISSING || value > max_value))
64 void set_filtered(double new_value, double time) {
65 if (prev_value != AltosLib.MISSING)
66 new_value = (prev_value * 15.0 + new_value) / 16.0;
83 if (value != AltosLib.MISSING && prev_value != AltosLib.MISSING)
84 return value - prev_value;
85 return AltosLib.MISSING;
90 double t = set_time - prev_set_time;
92 if (c != AltosLib.MISSING && t != 0)
94 return AltosLib.MISSING;
98 if (value == AltosLib.MISSING)
99 return AltosLib.MISSING;
100 if (prev_value == AltosLib.MISSING)
101 return AltosLib.MISSING;
103 return (value + prev_value) / 2 * (set_time - prev_set_time);
110 void set_derivative(AltosValue in) {
111 double n = in.rate();
113 if (n == AltosLib.MISSING)
116 double p = prev_value;
117 double pt = prev_set_time;
119 if (p == AltosLib.MISSING) {
121 pt = in.time() - 0.01;
124 /* Clip changes to reduce noise */
125 double ddt = in.time() - pt;
126 double ddv = (n - p) / ddt;
128 final double max = 100000;
131 if (Math.abs(ddv) > max) {
141 filter_len = ascent_filter_len;
143 filter_len = descent_filter_len;
145 double f = 1/Math.exp(ddt/ filter_len);
146 n = p * f + n * (1-f);
151 void set_integral(AltosValue in) {
152 double change = in.integrate();
154 if (change != AltosLib.MISSING) {
155 double prev = prev_value;
156 if (prev == AltosLib.MISSING)
158 set(prev + change, in.time());
162 void copy(AltosValue old) {
164 set_time = old.set_time;
165 prev_value = old.value;
166 prev_set_time = old.set_time;
167 max_value = old.max_value;
170 void finish_update() {
172 prev_set_time = set_time;
176 value = AltosLib.MISSING;
177 prev_value = AltosLib.MISSING;
178 max_value = AltosLib.MISSING;
187 double v = measured.value();
188 if (v != AltosLib.MISSING)
190 return computed.value();
193 boolean is_measured() {
194 return measured.value() != AltosLib.MISSING;
198 double m = measured.max();
200 if (m != AltosLib.MISSING)
202 return computed.max();
205 double prev_value() {
206 if (measured.value != AltosLib.MISSING && measured.prev_value != AltosLib.MISSING)
207 return measured.prev_value;
208 return computed.prev_value;
211 AltosValue altos_value() {
212 if (measured.value() != AltosLib.MISSING)
218 double c = measured.change();
219 if (c == AltosLib.MISSING)
220 c = computed.change();
225 double r = measured.rate();
226 if (r == AltosLib.MISSING)
231 void set_measured(double new_value, double time) {
232 measured.set(new_value, time);
235 void set_computed(double new_value, double time) {
236 computed.set(new_value, time);
239 void set_derivative(AltosValue in) {
240 computed.set_derivative(in);
243 void set_derivative(AltosCValue in) {
244 set_derivative(in.altos_value());
247 void set_integral(AltosValue in) {
248 computed.set_integral(in);
251 void set_integral(AltosCValue in) {
252 set_integral(in.altos_value());
255 void copy(AltosCValue old) {
256 measured.copy(old.measured);
257 computed.copy(old.computed);
260 void finish_update() {
261 measured.finish_update();
262 computed.finish_update();
266 measured = new AltosValue();
267 computed = new AltosValue();
274 public int receiver_serial;
275 public boolean landed;
276 public boolean ascent; /* going up? */
277 public boolean boost; /* under power */
280 public int device_type;
281 public int config_major;
282 public int config_minor;
283 public int apogee_delay;
284 public int main_deploy;
285 public int flight_log_max;
287 private double pressure_to_altitude(double p) {
288 if (p == AltosLib.MISSING)
289 return AltosLib.MISSING;
290 return AltosConvert.pressure_to_altitude(p);
293 private AltosCValue ground_altitude;
295 public double ground_altitude() {
296 return ground_altitude.value();
299 public void set_ground_altitude(double a) {
300 ground_altitude.set_measured(a, time);
303 class AltosGpsGroundAltitude extends AltosValue {
304 void set(double a, double t) {
307 gps_altitude.set_gps_height();
310 void set_filtered(double a, double t) {
311 super.set_filtered(a, t);
313 gps_altitude.set_gps_height();
317 private AltosGpsGroundAltitude gps_ground_altitude;
319 public double gps_ground_altitude() {
320 return gps_ground_altitude.value();
323 public void set_gps_ground_altitude(double a) {
324 gps_ground_altitude.set(a, time);
327 class AltosGroundPressure extends AltosCValue {
328 void set_filtered(double p, double time) {
329 computed.set_filtered(p, time);
331 ground_altitude.set_computed(pressure_to_altitude(computed.value()), time);
334 void set_measured(double p, double time) {
335 super.set_measured(p, time);
336 ground_altitude.set_computed(pressure_to_altitude(p), time);
340 private AltosGroundPressure ground_pressure;
342 public double ground_pressure() {
343 return ground_pressure.value();
346 public void set_ground_pressure (double pressure) {
347 ground_pressure.set_measured(pressure, time);
350 class AltosAltitude extends AltosCValue {
352 private void set_speed(AltosValue v) {
353 if (!acceleration.is_measured() || !ascent)
354 speed.set_derivative(this);
357 void set_computed(double a, double time) {
358 super.set_computed(a,time);
363 void set_measured(double a, double time) {
364 super.set_measured(a,time);
370 private AltosAltitude altitude;
372 class AltosGpsAltitude extends AltosValue {
374 private void set_gps_height() {
376 double g = gps_ground_altitude.value();
378 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
381 gps_height = AltosLib.MISSING;
384 void set(double a, double t) {
390 private AltosGpsAltitude gps_altitude;
392 private AltosValue gps_ground_speed;
393 private AltosValue gps_ascent_rate;
394 private AltosValue gps_course;
395 private AltosValue gps_speed;
397 public double altitude() {
398 double a = altitude.value();
399 if (a != AltosLib.MISSING)
401 return gps_altitude.value();
404 public double max_altitude() {
405 double a = altitude.max();
406 if (a != AltosLib.MISSING)
408 return gps_altitude.max();
411 public void set_altitude(double new_altitude) {
412 altitude.set_measured(new_altitude, time);
415 public double gps_altitude() {
416 return gps_altitude.value();
419 public double max_gps_altitude() {
420 return gps_altitude.max();
423 public void set_gps_altitude(double new_gps_altitude) {
424 gps_altitude.set(new_gps_altitude, time);
427 public double gps_ground_speed() {
428 return gps_ground_speed.value();
431 public double max_gps_ground_speed() {
432 return gps_ground_speed.max();
435 public double gps_ascent_rate() {
436 return gps_ascent_rate.value();
439 public double max_gps_ascent_rate() {
440 return gps_ascent_rate.max();
443 public double gps_course() {
444 return gps_course.value();
447 public double gps_speed() {
448 return gps_speed.value();
451 public double max_gps_speed() {
452 return gps_speed.max();
455 class AltosPressure extends AltosValue {
456 void set(double p, double time) {
458 if (state == AltosLib.ao_flight_pad)
459 ground_pressure.set_filtered(p, time);
460 double a = pressure_to_altitude(p);
461 altitude.set_computed(a, time);
465 private AltosPressure pressure;
467 public double pressure() {
468 return pressure.value();
471 public void set_pressure(double p) {
472 pressure.set(p, time);
475 public double height() {
476 double k = kalman_height.value();
477 if (k != AltosLib.MISSING)
480 double a = altitude();
481 double g = ground_altitude();
482 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
487 public double max_height() {
488 double k = kalman_height.max();
489 if (k != AltosLib.MISSING)
492 double a = altitude.max();
493 double g = ground_altitude();
494 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
496 return max_gps_height();
499 public double gps_height() {
500 double a = gps_altitude();
501 double g = gps_ground_altitude();
503 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
505 return AltosLib.MISSING;
508 public double max_gps_height() {
509 double a = gps_altitude.max();
510 double g = gps_ground_altitude();
512 if (a != AltosLib.MISSING && g != AltosLib.MISSING)
514 return AltosLib.MISSING;
517 class AltosSpeed extends AltosCValue {
520 return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
524 acceleration.set_derivative(this);
527 void set_derivative(AltosCValue in) {
528 super.set_derivative(in);
532 void set_computed(double new_value, double time) {
533 super.set_computed(new_value, time);
537 void set_measured(double new_value, double time) {
538 super.set_measured(new_value, time);
543 private AltosSpeed speed;
545 public double speed() {
546 double v = kalman_speed.value();
547 if (v != AltosLib.MISSING)
550 if (v != AltosLib.MISSING)
553 if (v != AltosLib.MISSING)
555 return AltosLib.MISSING;
558 public double max_speed() {
559 double v = kalman_speed.max();
560 if (v != AltosLib.MISSING)
563 if (v != AltosLib.MISSING)
566 if (v != AltosLib.MISSING)
568 return AltosLib.MISSING;
571 class AltosAccel extends AltosCValue {
574 return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
577 void set_measured(double a, double time) {
578 super.set_measured(a, time);
580 speed.set_integral(this.measured);
584 AltosAccel acceleration;
586 public double acceleration() {
587 return acceleration.value();
590 public double max_acceleration() {
591 return acceleration.max();
594 public AltosValue orient;
596 public void set_orient(double new_orient) {
597 orient.set(new_orient, time);
600 public double orient() {
601 return orient.value();
604 public double max_orient() {
608 public AltosValue kalman_height, kalman_speed, kalman_acceleration;
610 public void set_kalman(double height, double speed, double acceleration) {
611 kalman_height.set(height, time);
612 kalman_speed.set(speed, time);
613 kalman_acceleration.set(acceleration, time);
616 public double battery_voltage;
617 public double pyro_voltage;
618 public double temperature;
619 public double apogee_voltage;
620 public double main_voltage;
622 public double ignitor_voltage[];
625 public AltosGPS temp_gps;
626 public int temp_gps_sat_tick;
627 public boolean gps_pending;
628 public int gps_sequence;
633 public static final int MIN_PAD_SAMPLES = 10;
636 public int gps_waiting;
637 public boolean gps_ready;
641 public AltosGreatCircle from_pad;
642 public double elevation; /* from pad */
643 public double range; /* total distance */
645 public double gps_height;
647 public double pad_lat, pad_lon, pad_alt;
649 public int speak_tick;
650 public double speak_altitude;
652 public String callsign;
653 public String firmware_version;
655 public double accel_plus_g;
656 public double accel_minus_g;
658 public double ground_accel;
659 public double ground_accel_avg;
661 public int log_format;
662 public String product;
664 public AltosMs5607 baro;
666 public AltosCompanion companion;
668 public int pyro_fired;
670 public void set_npad(int npad) {
672 gps_waiting = MIN_PAD_SAMPLES - npad;
673 if (this.gps_waiting < 0)
675 gps_ready = gps_waiting == 0;
681 received_time = System.currentTimeMillis();
682 time = AltosLib.MISSING;
683 time_change = AltosLib.MISSING;
684 prev_time = AltosLib.MISSING;
685 tick = AltosLib.MISSING;
686 prev_tick = AltosLib.MISSING;
687 boost_tick = AltosLib.MISSING;
688 state = AltosLib.ao_flight_invalid;
689 flight = AltosLib.MISSING;
692 rssi = AltosLib.MISSING;
694 device_type = AltosLib.MISSING;
695 config_major = AltosLib.MISSING;
696 config_minor = AltosLib.MISSING;
697 apogee_delay = AltosLib.MISSING;
698 main_deploy = AltosLib.MISSING;
699 flight_log_max = AltosLib.MISSING;
701 ground_altitude = new AltosCValue();
702 ground_pressure = new AltosGroundPressure();
703 altitude = new AltosAltitude();
704 pressure = new AltosPressure();
705 speed = new AltosSpeed();
706 acceleration = new AltosAccel();
707 orient = new AltosValue();
709 temperature = AltosLib.MISSING;
710 battery_voltage = AltosLib.MISSING;
711 pyro_voltage = AltosLib.MISSING;
712 apogee_voltage = AltosLib.MISSING;
713 main_voltage = AltosLib.MISSING;
714 ignitor_voltage = null;
716 kalman_height = new AltosValue();
717 kalman_speed = new AltosValue();
718 kalman_acceleration = new AltosValue();
722 temp_gps_sat_tick = 0;
733 elevation = AltosLib.MISSING;
734 range = AltosLib.MISSING;
735 gps_height = AltosLib.MISSING;
737 pad_lat = AltosLib.MISSING;
738 pad_lon = AltosLib.MISSING;
739 pad_alt = AltosLib.MISSING;
741 gps_altitude = new AltosGpsAltitude();
742 gps_ground_altitude = new AltosGpsGroundAltitude();
743 gps_ground_speed = new AltosValue();
744 gps_speed = new AltosValue();
745 gps_ascent_rate = new AltosValue();
746 gps_course = new AltosValue();
748 speak_tick = AltosLib.MISSING;
749 speak_altitude = AltosLib.MISSING;
753 accel_plus_g = AltosLib.MISSING;
754 accel_minus_g = AltosLib.MISSING;
755 accel = AltosLib.MISSING;
757 ground_accel = AltosLib.MISSING;
758 ground_accel_avg = AltosLib.MISSING;
760 log_format = AltosLib.MISSING;
762 serial = AltosLib.MISSING;
763 receiver_serial = AltosLib.MISSING;
771 void finish_update() {
774 ground_altitude.finish_update();
775 altitude.finish_update();
776 pressure.finish_update();
777 speed.finish_update();
778 acceleration.finish_update();
779 orient.finish_update();
781 kalman_height.finish_update();
782 kalman_speed.finish_update();
783 kalman_acceleration.finish_update();
786 void copy(AltosState old) {
793 received_time = old.received_time;
795 time_change = old.time_change;
796 prev_time = old.time;
799 prev_tick = old.tick;
800 boost_tick = old.boost_tick;
809 device_type = old.device_type;
810 config_major = old.config_major;
811 config_minor = old.config_minor;
812 apogee_delay = old.apogee_delay;
813 main_deploy = old.main_deploy;
814 flight_log_max = old.flight_log_max;
818 ground_pressure.copy(old.ground_pressure);
819 ground_altitude.copy(old.ground_altitude);
820 altitude.copy(old.altitude);
821 pressure.copy(old.pressure);
822 speed.copy(old.speed);
823 acceleration.copy(old.acceleration);
824 orient.copy(old.orient);
826 battery_voltage = old.battery_voltage;
827 pyro_voltage = old.pyro_voltage;
828 temperature = old.temperature;
829 apogee_voltage = old.apogee_voltage;
830 main_voltage = old.main_voltage;
831 ignitor_voltage = old.ignitor_voltage;
833 kalman_height.copy(old.kalman_height);
834 kalman_speed.copy(old.kalman_speed);
835 kalman_acceleration.copy(old.kalman_acceleration);
838 gps = old.gps.clone();
841 if (old.temp_gps != null)
842 temp_gps = old.temp_gps.clone();
845 temp_gps_sat_tick = old.temp_gps_sat_tick;
846 gps_sequence = old.gps_sequence;
847 gps_pending = old.gps_pending;
850 imu = old.imu.clone();
855 mag = old.mag.clone();
860 gps_waiting = old.gps_waiting;
861 gps_ready = old.gps_ready;
864 if (old.from_pad != null)
865 from_pad = old.from_pad.clone();
869 elevation = old.elevation;
872 gps_height = old.gps_height;
874 gps_altitude.copy(old.gps_altitude);
875 gps_ground_altitude.copy(old.gps_ground_altitude);
876 gps_ground_speed.copy(old.gps_ground_speed);
877 gps_ascent_rate.copy(old.gps_ascent_rate);
878 gps_course.copy(old.gps_course);
879 gps_speed.copy(old.gps_speed);
881 pad_lat = old.pad_lat;
882 pad_lon = old.pad_lon;
883 pad_alt = old.pad_alt;
885 speak_tick = old.speak_tick;
886 speak_altitude = old.speak_altitude;
888 callsign = old.callsign;
890 accel_plus_g = old.accel_plus_g;
891 accel_minus_g = old.accel_minus_g;
893 ground_accel = old.ground_accel;
894 ground_accel_avg = old.ground_accel_avg;
896 log_format = old.log_format;
897 product = old.product;
899 receiver_serial = old.receiver_serial;
902 companion = old.companion;
904 pyro_fired = old.pyro_fired;
917 if (gps.locked && gps.nsat >= 4) {
918 /* Track consecutive 'good' gps reports, waiting for 10 of them */
919 if (state == AltosLib.ao_flight_pad || state == AltosLib.ao_flight_stateless) {
921 if (pad_lat != AltosLib.MISSING && (npad < 10 || state == AltosLib.ao_flight_pad)) {
922 pad_lat = (pad_lat * 31 + gps.lat) / 32;
923 pad_lon = (pad_lon * 31 + gps.lon) / 32;
924 gps_ground_altitude.set_filtered(gps.alt, time);
927 if (pad_lat == AltosLib.MISSING) {
930 gps_ground_altitude.set(gps.alt, time);
932 gps_altitude.set(gps.alt, time);
933 if (gps.climb_rate != AltosLib.MISSING)
934 gps_ascent_rate.set(gps.climb_rate, time);
935 if (gps.ground_speed != AltosLib.MISSING)
936 gps_ground_speed.set(gps.ground_speed, time);
937 if (gps.climb_rate != AltosLib.MISSING && gps.ground_speed != AltosLib.MISSING)
938 gps_speed.set(Math.sqrt(gps.ground_speed * gps.ground_speed +
939 gps.climb_rate * gps.climb_rate), time);
940 if (gps.course != AltosLib.MISSING)
941 gps_course.set(gps.course, time);
943 if (gps.lat != 0 && gps.lon != 0 &&
944 pad_lat != AltosLib.MISSING &&
945 pad_lon != AltosLib.MISSING)
949 if (h == AltosLib.MISSING)
951 from_pad = new AltosGreatCircle(pad_lat, pad_lon, 0, gps.lat, gps.lon, h);
952 elevation = from_pad.elevation;
953 range = from_pad.range;
957 public void set_tick(int new_tick) {
958 if (new_tick != AltosLib.MISSING) {
959 if (prev_tick != AltosLib.MISSING) {
960 while (new_tick < prev_tick - 1000) {
966 time_change = time - prev_time;
970 public void set_boost_tick(int boost_tick) {
971 if (boost_tick != AltosLib.MISSING)
972 this.boost_tick = boost_tick;
975 public String state_name() {
976 return AltosLib.state_name(state);
979 public void set_state(int state) {
980 if (state != AltosLib.ao_flight_invalid) {
982 ascent = (AltosLib.ao_flight_boost <= state &&
983 state <= AltosLib.ao_flight_coast);
984 boost = (AltosLib.ao_flight_boost == state);
988 public void set_device_type(int device_type) {
989 this.device_type = device_type;
990 switch (device_type) {
991 case AltosLib.product_telegps:
992 this.state = AltosLib.ao_flight_stateless;
997 public void set_log_format(int log_format) {
998 this.log_format = log_format;
999 switch (log_format) {
1000 case AltosLib.AO_LOG_FORMAT_TELEGPS:
1001 this.state = AltosLib.ao_flight_stateless;
1006 public void set_flight_params(int apogee_delay, int main_deploy) {
1007 this.apogee_delay = apogee_delay;
1008 this.main_deploy = main_deploy;
1011 public void set_config(int major, int minor, int flight_log_max) {
1012 config_major = major;
1013 config_minor = minor;
1014 this.flight_log_max = flight_log_max;
1017 public void set_callsign(String callsign) {
1018 this.callsign = callsign;
1021 public void set_firmware_version(String version) {
1022 firmware_version = version;
1025 public void set_flight(int flight) {
1027 /* When the flight changes, reset the state */
1028 if (flight != AltosLib.MISSING && flight != 0) {
1029 if (this.flight != AltosLib.MISSING &&
1030 this.flight != flight) {
1031 int bt = boost_tick;
1035 this.flight = flight;
1039 public void set_serial(int serial) {
1040 /* When the serial changes, reset the state */
1041 if (serial != AltosLib.MISSING) {
1042 if (this.serial != AltosLib.MISSING &&
1043 this.serial != serial) {
1044 int bt = boost_tick;
1048 this.serial = serial;
1052 public void set_receiver_serial(int serial) {
1053 if (serial != AltosLib.MISSING)
1054 receiver_serial = serial;
1058 if (rssi == AltosLib.MISSING)
1063 public void set_rssi(int rssi, int status) {
1064 if (rssi != AltosLib.MISSING) {
1066 this.status = status;
1070 public void set_received_time(long ms) {
1074 public void set_gps(AltosGPS gps, int sequence) {
1076 this.gps = gps.clone();
1077 gps_sequence = sequence;
1083 public void set_imu(AltosIMU imu) {
1089 public void set_mag(AltosMag mag) {
1090 this.mag = mag.clone();
1093 public AltosMs5607 make_baro() {
1095 baro = new AltosMs5607();
1099 public void set_ms5607(AltosMs5607 ms5607) {
1103 set_pressure(baro.pa);
1104 set_temperature(baro.cc / 100.0);
1108 public void set_ms5607(int pres, int temp) {
1110 baro.set(pres, temp);
1112 set_pressure(baro.pa);
1113 set_temperature(baro.cc / 100.0);
1117 public void make_companion (int nchannels) {
1118 if (companion == null)
1119 companion = new AltosCompanion(nchannels);
1122 public void set_companion(AltosCompanion companion) {
1123 this.companion = companion;
1126 void update_accel() {
1127 if (accel == AltosLib.MISSING)
1129 if (accel_plus_g == AltosLib.MISSING)
1131 if (accel_minus_g == AltosLib.MISSING)
1134 double counts_per_g = (accel_minus_g - accel_plus_g) / 2.0;
1135 double counts_per_mss = counts_per_g / 9.80665;
1136 acceleration.set_measured((accel_plus_g - accel) / counts_per_mss, time);
1139 public void set_accel_g(double accel_plus_g, double accel_minus_g) {
1140 if (accel_plus_g != AltosLib.MISSING) {
1141 this.accel_plus_g = accel_plus_g;
1142 this.accel_minus_g = accel_minus_g;
1147 public void set_ground_accel(double ground_accel) {
1148 if (ground_accel != AltosLib.MISSING)
1149 this.ground_accel = ground_accel;
1152 public void set_accel(double accel) {
1153 if (accel != AltosLib.MISSING) {
1155 if (state == AltosLib.ao_flight_pad) {
1156 if (ground_accel_avg == AltosLib.MISSING)
1157 ground_accel_avg = accel;
1159 ground_accel_avg = (ground_accel_avg * 7 + accel) / 8;
1165 public void set_temperature(double temperature) {
1166 if (temperature != AltosLib.MISSING) {
1167 this.temperature = temperature;
1172 public void set_battery_voltage(double battery_voltage) {
1173 if (battery_voltage != AltosLib.MISSING) {
1174 this.battery_voltage = battery_voltage;
1179 public void set_pyro_voltage(double pyro_voltage) {
1180 if (pyro_voltage != AltosLib.MISSING) {
1181 this.pyro_voltage = pyro_voltage;
1186 public void set_apogee_voltage(double apogee_voltage) {
1187 if (apogee_voltage != AltosLib.MISSING) {
1188 this.apogee_voltage = apogee_voltage;
1193 public void set_main_voltage(double main_voltage) {
1194 if (main_voltage != AltosLib.MISSING) {
1195 this.main_voltage = main_voltage;
1200 public void set_ignitor_voltage(double[] voltage) {
1201 this.ignitor_voltage = voltage;
1204 public void set_pyro_fired(int fired) {
1205 this.pyro_fired = fired;
1208 public double time_since_boost() {
1209 if (tick == AltosLib.MISSING)
1212 if (boost_tick == AltosLib.MISSING)
1213 return tick / 100.0;
1214 return (tick - boost_tick) / 100.0;
1217 public boolean valid() {
1218 return tick != AltosLib.MISSING && serial != AltosLib.MISSING;
1221 public AltosGPS make_temp_gps(boolean sats) {
1222 if (temp_gps == null) {
1223 temp_gps = new AltosGPS(gps);
1227 if (tick != temp_gps_sat_tick)
1228 temp_gps.cc_gps_sat = null;
1229 temp_gps_sat_tick = tick;
1234 public void set_temp_gps() {
1235 set_gps(temp_gps, gps_sequence + 1);
1236 gps_pending = false;
1240 public AltosState clone() {
1241 AltosState s = new AltosState();
1246 public AltosState () {