altoslib: Compute 'vertical acceleration' for eeprom files
authorKeith Packard <keithp@keithp.com>
Fri, 9 Jun 2017 03:39:06 +0000 (20:39 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 9 Jun 2017 03:39:06 +0000 (20:39 -0700)
This uses the computed orientation to find the portion of the measured
acceleration which is vertical and then shows that in the post-flight
analysis graph.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosFlightSeries.java
altosuilib/AltosGraphNew.java

index dad066d..315e0a4 100644 (file)
@@ -159,6 +159,10 @@ public class AltosFlightSeries extends AltosDataListener {
 
        public static final String accel_name = "Accel";
 
+       public AltosTimeSeries  vert_accel_series;
+
+       public static final String vert_accel_name = "Vertical Accel";
+
        public void set_acceleration(double acceleration) {
                if (acceleration == AltosLib.MISSING)
                        return;
@@ -264,8 +268,25 @@ public class AltosFlightSeries extends AltosDataListener {
                        temp_series.differentiate(alt_speed_series);
                }
                if (accel_series != null) {
+
+                       if (orient_series != null) {
+                               vert_accel_series = add_series(vert_accel_name, AltosConvert.accel);
+
+                               for (AltosTimeValue a : accel_series) {
+                                       double  orient = orient_series.value(a.time);
+                                       double  a_abs = a.value + AltosConvert.gravity;
+                                       double  v_a = a_abs * Math.cos(AltosConvert.degrees_to_radians(orient)) - AltosConvert.gravity;
+
+                                       vert_accel_series.add(a.time, v_a);
+                               }
+                       }
+
                        AltosTimeSeries temp_series = make_series(speed_name, AltosConvert.speed);
-                       accel_series.integrate(temp_series);
+
+                       if (vert_accel_series != null)
+                               vert_accel_series.integrate(temp_series);
+                       else
+                               accel_series.integrate(temp_series);
 
                        accel_speed_series = make_series(speed_name, AltosConvert.speed);
                        temp_series.filter(accel_speed_series, 0.1);
index 08a3373..2505a02 100644 (file)
@@ -47,6 +47,7 @@ public class AltosGraphNew extends AltosUIGraphNew {
        static final private Color kalman_speed_color = new Color(0,255,0);
        static final private Color thrust_color = new Color(31,194,31);
        static final private Color accel_color = new Color(31,31,194);
+       static final private Color vert_accel_color = new Color(64,164,164);
        static final private Color kalman_accel_color = new Color(0,0,255);
        static final private Color voltage_color = new Color(194, 194, 31);
        static final private Color battery_voltage_color = new Color(194, 194, 31);
@@ -133,6 +134,11 @@ public class AltosGraphNew extends AltosUIGraphNew {
                                            true,
                                            accel_axis);
 
+               flight_series.register_axis(AltosUIFlightSeries.vert_accel_name,
+                                           vert_accel_color,
+                                           true,
+                                           accel_axis);
+
                flight_series.register_axis(AltosUIFlightSeries.kalman_accel_name,
                                            kalman_accel_color,
                                            false,