From cc4f13a118bdd432e1fc57712f4d805a353a1e92 Mon Sep 17 00:00:00 2001 From: j-w9 <295470691+j-w9@users.noreply.github.com> Date: Sat, 17 Oct 2026 12:35:07 -0400 Subject: [PATCH 1/2] FilterReview: only use armed raw IMU data if disarmed logging is rate limited --- FilterReview/FilterReview.js | 42 ++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/FilterReview/FilterReview.js b/FilterReview/FilterReview.js index 9f0bdea5..e392d566 100644 --- a/FilterReview/FilterReview.js +++ b/FilterReview/FilterReview.js @@ -2228,6 +2228,21 @@ function load_from_batch(log, num_gyro, gyro_rate, get_param) { } } +// Return true for each time at which the vehicle was armed, from ARM log messages +function armed_mask(time, ARM) { + const mask = new Array(time.length) + let armed = false + let k = 0 + for (let j = 0; j < time.length; j++) { + while ((k < ARM.TimeUS.length) && (ARM.TimeUS[k] <= time[j])) { + armed = ARM.ArmState[k] != 0 + k++ + } + mask[j] = armed + } + return mask +} + // Log from raw sensor logging function load_from_raw_log(log, num_gyro, gyro_rate, get_param) { Gyro_batch = [] @@ -2248,6 +2263,14 @@ function load_from_raw_log(log, num_gyro, gyro_rate, get_param) { post_filter = false } + // Logging may be rate limited while disarmed, the change in sample rate breaks the FFT. + // If so only use samples logged while armed, the gap where disarmed data is removed then splits the batches. + let ARM = null + const LOG_DARM_RATEMAX = get_param("LOG_DARM_RATEMAX", false) + if ((LOG_DARM_RATEMAX != null) && (LOG_DARM_RATEMAX > 0) && ("ARM" in log.messageTypes)) { + ARM = log.get("ARM") + } + // Load in a one massive batch, split for large gaps in log for (const inst of Object.keys(log.messageTypes.GYR.instances)) { const i = parseFloat(inst) @@ -2268,10 +2291,21 @@ function load_from_raw_log(log, num_gyro, gyro_rate, get_param) { continue } - const time = log.get_instance("GYR", inst, "SampleUS") - const GyrX = log.get_instance("GYR", inst, "GyrX") - const GyrY = log.get_instance("GYR", inst, "GyrY") - const GyrZ = log.get_instance("GYR", inst, "GyrZ") + let time = log.get_instance("GYR", inst, "SampleUS") + let GyrX = log.get_instance("GYR", inst, "GyrX") + let GyrY = log.get_instance("GYR", inst, "GyrY") + let GyrZ = log.get_instance("GYR", inst, "GyrZ") + + if (ARM != null) { + const armed = armed_mask(time, ARM) + if (armed.includes(true)) { + const keep = (_, k) => armed[k] + time = time.filter(keep) + GyrX = GyrX.filter(keep) + GyrY = GyrY.filter(keep) + GyrZ = GyrZ.filter(keep) + } + } let sample_rate_sum = 0 let sample_rate_count = 0 From 76381adefc1da15d75dd67d23299c74b10a27118 Mon Sep 17 00:00:00 2001 From: j-w9 <295470691+j-w9@users.noreply.github.com> Date: Sun, 8 Nov 2026 22:59:30 -0500 Subject: [PATCH 2/2] FilterReview: start the armed mask from the first logged arm state With disarmed logging off the first arm is not logged, so starting disarmed dropped the whole first flight of a multi-flight log. --- FilterReview/FilterReview.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FilterReview/FilterReview.js b/FilterReview/FilterReview.js index e392d566..ece8017a 100644 --- a/FilterReview/FilterReview.js +++ b/FilterReview/FilterReview.js @@ -2231,7 +2231,8 @@ function load_from_batch(log, num_gyro, gyro_rate, get_param) { // Return true for each time at which the vehicle was armed, from ARM log messages function armed_mask(time, ARM) { const mask = new Array(time.length) - let armed = false + // The first arm is not logged if disarmed logging is off, so start from the opposite of the first logged state + let armed = (ARM.ArmState.length > 0) && (ARM.ArmState[0] == 0) let k = 0 for (let j = 0; j < time.length; j++) { while ((k < ARM.TimeUS.length) && (ARM.TimeUS[k] <= time[j])) {