X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosState.java;h=caa1cb4adeb30d8347ca2368a4c4d69f5ae978a4;hb=2a05849c3bf8c1617409237be48802dd6fc6255b;hp=d3929b8f7e047480ddcd02cef4eed0953863f26c;hpb=0f32d1a2e2fb5989d124189a7eb1156a00b0ad8f;p=fw%2Faltos diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index d3929b8f..caa1cb4a 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -22,8 +22,6 @@ package org.altusmetrum.altoslib_11; -import java.io.*; - public class AltosState extends AltosDataListener { public static final int set_position = 1; @@ -43,8 +41,6 @@ public class AltosState extends AltosDataListener { public int rssi; public int status; - public double time; - class AltosValue { double value; double prev_value; @@ -288,7 +284,6 @@ public class AltosState extends AltosDataListener { } } - private int state; public boolean landed; public boolean ascent; /* going up? */ public boolean boost; /* under power */ @@ -506,23 +501,7 @@ public class AltosState extends AltosDataListener { pressure.set(p, time); } - class AltosForce extends AltosValue { - void set(double p, double time) { - super.set(p, time); - } - - AltosForce() { - super(); - } - } - private AltosForce thrust; - - public double thrust() { - return thrust.value(); - } - public void set_thrust(double N) { - thrust.set(N, time); } public double baro_height() { @@ -720,15 +699,8 @@ public class AltosState extends AltosDataListener { public int speak_tick; public double speak_altitude; - public String callsign; - public String firmware_version; - public double ground_accel; - public int log_format; - public int log_space; - public String product; - public AltosCompanion companion; public int pyro_fired; @@ -756,7 +728,6 @@ public class AltosState extends AltosDataListener { ground_pressure = new AltosGroundPressure(); altitude = new AltosAltitude(); pressure = new AltosPressure(); - thrust = new AltosForce(); speed = new AltosSpeed(); acceleration = new AltosAccel(); orient = new AltosCValue(); @@ -786,8 +757,6 @@ public class AltosState extends AltosDataListener { accel_ground_across = AltosLib.MISSING; accel_ground_through = AltosLib.MISSING; - pad_orientation = AltosLib.MISSING; - set_npad(0); ngps = 0; @@ -810,15 +779,8 @@ public class AltosState extends AltosDataListener { speak_tick = AltosLib.MISSING; speak_altitude = AltosLib.MISSING; - callsign = null; - firmware_version = null; - ground_accel = AltosLib.MISSING; - log_format = AltosLib.MISSING; - log_space = AltosLib.MISSING; - product = null; - companion = null; pyro_fired = 0; @@ -937,16 +899,14 @@ public class AltosState extends AltosDataListener { public AltosRotation rotation; public AltosRotation ground_rotation; - public int pad_orientation; - public double accel_ground_along, accel_ground_across, accel_ground_through; void update_pad_rotation() { - if (pad_orientation != AltosLib.MISSING && accel_ground_along != AltosLib.MISSING) { + if (cal_data.pad_orientation != AltosLib.MISSING && accel_ground_along != AltosLib.MISSING) { rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - cal_data.accel_zero_across), AltosIMU.convert_accel(accel_ground_through - cal_data.accel_zero_through), AltosIMU.convert_accel(accel_ground_along - cal_data.accel_zero_along), - pad_orientation); + cal_data.pad_orientation); ground_rotation = rotation; orient.set_computed(rotation.tilt(), time); } @@ -959,28 +919,17 @@ public class AltosState extends AltosDataListener { update_pad_rotation(); } - public void set_pad_orientation(int pad_orientation) { - this.pad_orientation = pad_orientation; - update_pad_rotation(); - } - public double last_imu_time; - private double radians(double degrees) { - if (degrees == AltosLib.MISSING) - return AltosLib.MISSING; - return degrees * Math.PI / 180.0; - } - private void update_orient() { if (last_imu_time != AltosLib.MISSING) { double t = time - last_imu_time; - double pitch = radians(gyro_pitch()); - double yaw = radians(gyro_yaw()); - double roll = radians(gyro_roll()); + double pitch = AltosConvert.degrees_to_radians(gyro_pitch()); + double yaw = AltosConvert.degrees_to_radians(gyro_yaw()); + double roll = AltosConvert.degrees_to_radians(gyro_roll()); - if (t > 0 & pitch != AltosLib.MISSING && rotation != null) { + if (t > 0 && pitch != AltosLib.MISSING && rotation != null) { rotation.rotate(t, pitch, yaw, roll); orient.set_computed(rotation.tilt(), time); } @@ -992,8 +941,8 @@ public class AltosState extends AltosDataListener { public void set_gyro(double roll, double pitch, double yaw) { gyro_roll = roll; - gyro_pitch = roll; - gyro_roll = roll; + gyro_pitch = pitch; + gyro_roll = yaw; update_orient(); } @@ -1108,8 +1057,15 @@ public class AltosState extends AltosDataListener { this.pyro_fired = fired; } + public AltosState() { + Thread.dumpStack(); + init(); + } + public AltosState (AltosCalData cal_data) { super(cal_data); + if (cal_data == null) + Thread.dumpStack(); init(); } }