summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-04-07 18:36:36 -0700
committerKeith Packard <keithp@keithp.com>2012-04-07 18:36:36 -0700
commite56038b65ba1c6413ba9942be3c092644986f126 (patch)
treec1a2e512031bd2bb2f4ba95a7ec87788012c4a88
parent20066268d8d1853055d0afe108584db34b425fcb (diff)
altosui: When computing flight stats, auto-detect boost time
Detect when boost actually starts by looking for the last low acceleration value before the recorded boost time. This improves the computation of the boost state data. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--altosui/AltosFlightStats.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java
index dce5cb3e..ed5a336e 100644
--- a/altosui/AltosFlightStats.java
+++ b/altosui/AltosFlightStats.java
@@ -77,10 +77,30 @@ public class AltosFlightStats {
return landed_time;
}
+ double boost_time(AltosRecordIterable iterable) {
+ double boost_time = -1000;
+
+ AltosState state = null;
+
+ for (AltosRecord record : iterable) {
+ state = new AltosState(record, state);
+
+ if (state.acceleration < 1)
+ boost_time = state.time;
+ if (state.state >= Altos.ao_flight_boost)
+ break;
+ }
+ if (boost_time == -1000)
+ boost_time = state.time;
+ System.out.printf ("boost time %f instead of %f\n", boost_time, state.time);
+ return boost_time;
+ }
+
+
public AltosFlightStats(AltosRecordIterable iterable) throws InterruptedException, IOException {
AltosState state = null;
AltosState new_state = null;
- double boost_time = -1;
+ double boost_time = boost_time(iterable);
double end_time = 0;
double landed_time = landed_time(iterable);
@@ -95,10 +115,12 @@ public class AltosFlightStats {
new_state = new AltosState(record, state);
end_time = new_state.time;
state = new_state;
+ if (state.time >= boost_time && state.state < Altos.ao_flight_boost)
+ state.state = Altos.ao_flight_boost;
+ if (state.time >= landed_time && state.state < Altos.ao_flight_landed)
+ state.state = Altos.ao_flight_landed;
if (0 <= state.state && state.state < Altos.ao_flight_invalid) {
if (state.state >= Altos.ao_flight_boost) {
- if (boost_time == -1)
- boost_time = state.time;
if (state.gps != null && state.gps.locked &&
year < 0) {
year = state.gps.year;
@@ -109,8 +131,6 @@ public class AltosFlightStats {
second = state.gps.second;
}
}
- if (state.time >= landed_time)
- state.state = Altos.ao_flight_landed;
state_accel[state.state] += state.acceleration;
state_speed[state.state] += state.speed;
state_baro_speed[state.state] += state.baro_speed;