X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosCalData.java;h=c90534a924e4159ea62cc0a1db5575e8493a67d0;hp=fdea5e214948da1bdad80f60ad43cc8c9fde0475;hb=db950e97caefdd3257c1a2de3547ab88a2bd2344;hpb=749400fd244eba38806c623d2a35722642230698 diff --git a/altoslib/AltosCalData.java b/altoslib/AltosCalData.java index fdea5e21..c90534a9 100644 --- a/altoslib/AltosCalData.java +++ b/altoslib/AltosCalData.java @@ -12,7 +12,7 @@ * General Public License for more details. */ -package org.altusmetrum.altoslib_12; +package org.altusmetrum.altoslib_14; /* * Calibration and other data needed to construct 'real' values from various data @@ -120,6 +120,13 @@ public class AltosCalData { this.ground_accel = ground_accel; } + public double ground_motor_pressure = AltosLib.MISSING; + + public void set_ground_motor_pressure(double ground_motor_pressure) { + if (ground_motor_pressure != AltosLib.MISSING) + this.ground_motor_pressure = ground_motor_pressure; + } + /* Raw acceleration value */ public double accel = AltosLib.MISSING; @@ -133,6 +140,18 @@ public class AltosCalData { mma655x_inverted = inverted; } + public boolean adxl375_inverted = false; + + public void set_adxl375_inverted(boolean inverted) { + adxl375_inverted = inverted; + } + + public int adxl375_axis = AltosLib.MISSING; + + public void set_adxl375_axis(int axis) { + adxl375_axis = axis; + } + public int pad_orientation = AltosLib.MISSING; public void set_pad_orientation(int orientation) { @@ -142,7 +161,9 @@ public class AltosCalData { /* Compute acceleration */ public double acceleration(double sensor) { - return AltosConvert.acceleration_from_sensor(sensor, accel_plus_g, accel_minus_g, ground_accel); + double accel; + accel = AltosConvert.acceleration_from_sensor(sensor, accel_plus_g, accel_minus_g, ground_accel); + return accel; } public AltosMs5607 ms5607 = null; @@ -233,6 +254,10 @@ public class AltosCalData { public int state = AltosLib.MISSING; + public String state_name() { + return AltosLib.state_name(state); + } + public void set_state(int state) { if (state >= AltosLib.ao_flight_boost && boost_tick == AltosLib.MISSING) set_boost_tick(); @@ -241,6 +266,8 @@ public class AltosCalData { public AltosGPS gps_pad = null; + public AltosGPS prev_gps = null; + public double gps_pad_altitude = AltosLib.MISSING; public void set_cal_gps(AltosGPS gps) { @@ -251,6 +278,7 @@ public class AltosCalData { gps_pad_altitude = gps.alt; } temp_gps = null; + prev_gps = gps; } /* @@ -275,7 +303,7 @@ public class AltosCalData { public AltosGPS make_temp_cal_gps(int tick, boolean sats) { if (temp_gps == null) - temp_gps = new AltosGPS(); + temp_gps = new AltosGPS(prev_gps); if (sats) { if (tick != temp_gps_sat_tick) temp_gps.cc_gps_sat = null; @@ -284,6 +312,24 @@ public class AltosCalData { return temp_gps; } + public int imu_type = AltosLib.MISSING; + + public int imu_model = AltosLib.MISSING; + + public int mag_model = AltosLib.MISSING; + + public void set_imu_type(int imu_type) { + this.imu_type = imu_type; + } + + public void set_imu_model(int imu_model) { + this.imu_model = imu_model; + } + + public void set_mag_model(int mag_model) { + this.mag_model = mag_model; + } + public double accel_zero_along, accel_zero_across, accel_zero_through; public void set_accel_zero(double zero_along, double zero_across, double zero_through) { @@ -295,18 +341,20 @@ public class AltosCalData { } public double accel_along(double counts) { - return AltosIMU.convert_accel(counts - accel_zero_along); + return AltosIMU.convert_accel(counts - accel_zero_along, imu_type, imu_model); } public double accel_across(double counts) { - return AltosIMU.convert_accel(counts - accel_zero_across); + return AltosIMU.convert_accel(counts - accel_zero_across, imu_type, imu_model); } public double accel_through(double counts) { - return AltosIMU.convert_accel(counts - accel_zero_through); + return AltosIMU.convert_accel(counts - accel_zero_through, imu_type, imu_model); } - public double gyro_zero_roll, gyro_zero_pitch, gyro_zero_yaw; + public double gyro_zero_roll = AltosLib.MISSING; + public double gyro_zero_pitch = AltosLib.MISSING; + public double gyro_zero_yaw = AltosLib.MISSING; public void set_gyro_zero(double roll, double pitch, double yaw) { if (roll != AltosLib.MISSING) { @@ -321,19 +369,19 @@ public class AltosCalData { if (gyro_zero_roll == AltosLib.MISSING || counts == AltosLib.MISSING) return AltosLib.MISSING; - return AltosIMU.gyro_degrees_per_second(counts, gyro_zero_roll); + return AltosIMU.gyro_degrees_per_second(counts - gyro_zero_roll, imu_type, imu_model); } public double gyro_pitch(double counts) { if (gyro_zero_pitch == AltosLib.MISSING || counts == AltosLib.MISSING) return AltosLib.MISSING; - return AltosIMU.gyro_degrees_per_second(counts, gyro_zero_pitch); + return AltosIMU.gyro_degrees_per_second(counts - gyro_zero_pitch, imu_type, imu_model); } public double gyro_yaw(double counts) { if (gyro_zero_yaw == AltosLib.MISSING || counts == AltosLib.MISSING) return AltosLib.MISSING; - return AltosIMU.gyro_degrees_per_second(counts, gyro_zero_yaw); + return AltosIMU.gyro_degrees_per_second(counts - gyro_zero_yaw, imu_type, imu_model); } private double gyro_zero_overflow(double first) { @@ -366,19 +414,19 @@ public class AltosCalData { public double mag_along(double along) { if (along == AltosLib.MISSING) return AltosLib.MISSING; - return AltosMag.convert_gauss(along); + return AltosMag.convert_gauss(along, imu_type, mag_model); } public double mag_across(double across) { if (across == AltosLib.MISSING) return AltosLib.MISSING; - return AltosMag.convert_gauss(across); + return AltosMag.convert_gauss(across, imu_type, mag_model); } public double mag_through(double through) { if (through == AltosLib.MISSING) return AltosLib.MISSING; - return AltosMag.convert_gauss(through); + return AltosMag.convert_gauss(through, imu_type, mag_model); } public AltosCalData() { @@ -394,13 +442,21 @@ public class AltosCalData { set_flight_params(config_data.apogee_delay / ticks_per_sec, config_data.apogee_lockout / ticks_per_sec); set_pad_orientation(config_data.pad_orientation); set_product(config_data.product); - set_accel_plus_minus(config_data.accel_cal_plus, config_data.accel_cal_minus); + set_accel_plus_minus(config_data.accel_cal_plus(config_data.pad_orientation), config_data.accel_cal_minus(config_data.pad_orientation)); set_accel_zero(config_data.accel_zero_along, config_data.accel_zero_across, config_data.accel_zero_through); set_ms5607(config_data.ms5607); try { set_mma655x_inverted(config_data.mma655x_inverted()); } catch (AltosUnknownProduct up) { } + try { + set_adxl375_inverted(config_data.adxl375_inverted()); + } catch (AltosUnknownProduct up) { + } + try { + set_adxl375_axis(config_data.adxl375_axis()); + } catch (AltosUnknownProduct up) { + } set_pad_orientation(config_data.pad_orientation); } }