diff options
author | Keith Packard <keithp@keithp.com> | 2012-06-01 19:51:25 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-06-01 19:51:25 -0700 |
commit | 1824761f5b98e92485e2dd347b1c4d043ec207e2 (patch) | |
tree | 9c84ad0d7b4007ce668b901091695fc4ddbebd5e /altosui/AltosCSV.java | |
parent | ab85337aa942cb73a08bd3b783771179773b9a67 (diff) |
altosui: Quick hacks to download megametrum data and convert to CSV
Very little useful data crunching is done, but at least we can save
and convert files
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosCSV.java')
-rw-r--r-- | altosui/AltosCSV.java | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index 9ec21bef..b88bedba 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -31,7 +31,7 @@ public class AltosCSV implements AltosWriter { LinkedList<AltosRecord> pad_records; AltosState state; - static final int ALTOS_CSV_VERSION = 4; + static final int ALTOS_CSV_VERSION = 5; /* Version 4 format: * @@ -61,6 +61,17 @@ public class AltosCSV implements AltosWriter { * drogue (V) * main (V) * + * Advanced sensors (if available) + * accel_x (m/s²) + * accel_y (m/s²) + * accel_z (m/s²) + * gyro_x (d/s) + * gyro_y (d/s) + * gyro_z (d/s) + * mag_x (g) + * mag_y (g) + * mag_z (g) + * * GPS data (if available) * connected (1/0) * locked (1/0) @@ -129,6 +140,24 @@ public class AltosCSV implements AltosWriter { record.main_voltage()); } + void write_advanced_header() { + out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z"); + } + + void write_advanced(AltosRecord record) { + AltosIMU imu = record.imu; + AltosMag mag = record.mag; + + if (imu == null) + imu = new AltosIMU(); + if (mag == null) + mag = new AltosMag(); + out.printf("%d,%d,%d,%d,%d,%d,%d,%d,%d", + imu.accel_x, imu.accel_y, imu.accel_z, + imu.gyro_x, imu.gyro_y, imu.gyro_z, + mag.x, mag.y, mag.z); + } + void write_gps_header() { out.printf("connected,locked,nsat,latitude,longitude,altitude,year,month,day,hour,minute,second,pad_dist,pad_range,pad_az,pad_el,hdop"); } @@ -212,10 +241,12 @@ public class AltosCSV implements AltosWriter { out.printf(",0"); } - void write_header(boolean gps, boolean companion) { + void write_header(boolean advanced, boolean gps, boolean companion) { out.printf("#"); write_general_header(); out.printf(","); write_flight_header(); out.printf(","); write_basic_header(); + if (advanced) + out.printf(","); write_advanced_header(); if (gps) { out.printf(","); write_gps_header(); out.printf(","); write_gps_sat_header(); @@ -230,7 +261,9 @@ public class AltosCSV implements AltosWriter { state = new AltosState(record, state); write_general(record); out.printf(","); write_flight(record); out.printf(","); - write_basic(record); + write_basic(record); out.printf(","); + if (record.imu != null || record.mag != null) + write_advanced(record); if (record.gps != null) { out.printf(","); write_gps(record); out.printf(","); @@ -253,7 +286,8 @@ public class AltosCSV implements AltosWriter { if (record.state == Altos.ao_flight_startup) return; if (!header_written) { - write_header(record.gps != null, record.companion != null); + write_header(record.imu != null || record.mag != null, + record.gps != null, record.companion != null); header_written = true; } if (!seen_boost) { |