Skip to content

Compare sets of flights

SITL flights are not bit-for-bit repeatable. An arm retry lands on a pump step that depends on the wall clock, and two runs part from there. A smooth phase replays within a fraction of a percent. A flight that crosses a hard gate, such as an EKF innovation check or a land detector, can come out one way or the other about half the time each, in every configuration. One pair of flights can’t tell you which kind of difference you’re looking at. A set can.

batch_compare(
a=["...-baseline-1.BIN", "...-baseline-2.BIN", "...-baseline-3.BIN"],
b=["...-tuned-1.BIN", "...-tuned-2.BIN", "...-tuned-3.BIN"],
measures=[
{"name": "far_wind", "msg": "XKF2", "field": "VWN", "reduce": "abs_max", "t0": 60, "t1": 75},
{"name": "far_wind_high", "msg": "XKF2", "field": "VWN", "reduce": "abs_max",
"t0": 60, "t1": 75, "op": ">", "value": 4.0},
],
)

The logs can be any dataflash logs: kept ones by name, or a test harness’s by path. Every phase log_summary finds is matched across the logs by mode, armed, flying, mission item and occurrence, so the second hover pairs with the second. For each metric of each phase, and the totals, the result has:

  • a and b: n, mean, standard deviation, min and max;
  • gap and pct: the difference of the means;
  • d: the gap in pooled standard deviations;
  • p: Welch’s t-test;
  • q: that p adjusted for the number of tests this comparison ran;
  • shown: true when q < 0.05.

By default, a summary:

  • shown;
  • each flying phase’s headline numbers (duration, energy, current, lift, throttle, airspeed, peak height) as [mean, sd, n] a side, with the gap, p and q;
  • the totals, your measures and outcomes;
  • full, the path of the whole comparison as JSON.

batch_status(batch_id, detail=true) returns the whole comparison inline. On a hover hop the summary is under 4 KB, against about 25 KB for everything.

Measures add numbers of your own. Each comes from one of three places:

  • A log field reduced over a window: msg, field, reduce (max, min, mean, first, last, abs_max), and optionally t0, t1 and instance.
  • A phase metric: phase ({"mode": "QLOITER", "flying": true, "nth": 0}) and metric.
  • An autopilot text: text.

Add op and value and a number becomes a yes/no outcome: the result gives each side’s rate and Fisher’s exact p. per_log shows every log’s value, so you can see which flight went which way.

Fly a recipe on two builds, or two settings

Section titled “Fly a recipe on two builds, or two settings”
batch_fly(log="...-gusty-hop.BIN", n=5, tree_b="~/ardupilot-dev")
batch_fly(log="...-gusty-hop.BIN", n=5, set_a={"Q_A_RAT_RLL_P": 0.25}, set_b={"Q_A_RAT_RLL_P": 0.4})

A side differs by binary (binary_* or tree_*), by parameters (set_a, set_b, laid over the recipe’s own), or both.

batch_fly flies a kept log’s recipe n times on side A (its own binary unless you give binary_a or tree_a) and n times on side B, interleaved, A B then B A, so drift in machine load falls on both sides alike. Each flight is a repro. One that fails is recorded with its error and log, and counts toward the flight_failed outcome instead of ending the batch.

Leave out B, and batch_fly flies A’s binary on both sides. The gaps it finds are run-to-run noise, the floor any real comparison has to clear. On real ArduPilot, three gusty hovers a side on the identical binary:

Hover Side A Side B p
Current 42.41 ± 0.23 A 42.26 ± 0.25 A 0.50
Lift 73.29 ± 0.36 % 73.07 ± 0.38 % 0.51
Energy 2.807 ± 0.001 Wh 2.807 ± 0.001 Wh 0.62

Nothing was shown across 87 tests. Run the same control with two builds that ought to behave identically, such as a compiler-only change or an in-tree binary against its container build. If the control shows a gap, so will your real comparison, and the gap isn’t your change.

Six identical gusty hovers on the same binary don’t scatter around one value. They fall into two clusters about 0.8% apart in hover current, for example 43.69, 43.71 and 43.72 A against 44.06, 44.13 and 44.15 A. Setting the wind after arming, so the gusts start with the flight, doesn’t remove the split. It comes from when the arm lands, not from the air. A single pair can land in different clusters and look like a 0.8% change. At three or more a side, the null control shows nothing.

Those clusters come from when MAVLink inputs land, and a flight flown with fly_exact has none. Give batch_fly an exact recipe and it ignores n and flies three flights: A twice and B once. The job’s note says so, and its n is null. A kept log can be named with or without .BIN.

batch_fly(log="20261007T175900Z-exact-hop", set_b={"Q_A_RAT_RLL_P": 0.4})
"note": "exact recipe: n is ignored (5 given); flew A, A, B",
"result": { "exact": true, "a_repeats": true, "imu_samples_checked": 16057,
"reading": "A flew twice the same, record for record (16057 IMU samples), so there is no noise to see past: every difference below is the change. B first departs from A at 39.324 s, in SIM2 (PN, PE, As). First visibly at 40.544 s (SIM2 PD off by 0.0010264 m). Largest change: roll_rate_abs_max_dps +2589% in AUTO. A matched the original log record for record",
"a_matches_original": true, "a_original_difference": null,
"b_departs": { "type": "SIM2", "t_s": 39.324264, "fields": { "PN": [-0.009467312691613132, -0.009467312691611208], ... } },
"b_visible": { "t_s": 40.543776, "type": "SIM2", "field": "PD", "a": -0.10306, "b": -0.10203, "delta": 0.0010264 },
"largest_change": { "mode": "AUTO", "metric": "roll_rate_abs_max_dps", "a": 7.71, "b": 207.32, "pct": 2588.98 },
"differences": { "totals": { ... }, "flying_phases": [ ... ],
"close_timing": { "phases_only_in": { "a": ["AUTO 0.204s"], "b": ["AUTO 0.1s"] }, "duration_s": null, ... } } }

The two A flights must match record for record, which proves that this machine and binary repeat the flight with no noise. With that proven, the comparison needs no statistics: each difference between A and B is the change, reported as a plain difference.

b_departs is the first record where B parts from A, so it marks the moment and the field where the change first acts. On the stock quadplane above, a roll gain first showed 39.3 s into the hop, in SITL’s own position record, by about 2×10⁻¹⁵ m. That is the controller’s first outputs as the motors spin up, true but far too small to see. b_visible is the first record where SITL’s truth is visibly apart: position (SIM2 PN, PE, PD) more than 1 mm off, or attitude (SIM roll, pitch, yaw) more than 0.1°. Here that came 1.2 s later, 10 cm into the climb, with B a millimetre lower than A. When B never gets that far from A, b_visible is null and the reading says B never departs visibly. largest_change is the metric that moved most, as a percentage, in a flying phase both flights have (duration left out): the gain of 0.4 made the roll rate peak at 207°/s against 7.7°/s.

Two more checks come with it. a_matches_original compares the first A flight with the log you named, from the anchor on. When it is false, a_original_difference names the first record that differs: either side A was given another binary or parameters, which the reading says is expected, or the binary or something else the recipe relies on changed since the original was flown. And a null control (nothing given for B) that matches reads null control: B flew A's setup and matched it record for record, since there was no change to make a difference.

To see the split rather than read it, film A with B as a ghost. Both logs share the sim clock, so B flies inside A until the change acts, then comes out of it, and the HUD marks the moment it parts and gives the separation as it grows:

render_film(log="20261007T190147Z-batch-dfcd9e-a1", ghost="20261007T190216Z-batch-dfcd9e-b1",
t0_s=37, t1_s=56)

On the roll-gain batch above, B is out of A within two seconds of lifting off. It hangs about a metre below A through the climb, trails it by 5 m as the transition starts and by 16 m at its end. Watch a flight has the details.

Or have the batch film its own answer: batch_fly(log=..., set_b=..., film="chase") flies A, A and B, compares them, then renders A’s first flight with B’s as a ghost. The batch’s film carries the video_id for video_status. The camera can be chase, ground or fpv. If the film can’t start, for example because there’s no Blender, film says why and the comparison stands.

Each log ends wherever its close caught it, so even identical flights differ in their last fraction of a second. The exact summary leaves out phases only one flight has that last under 0.5 s, and a whole-log duration difference under 0.1 s, and lists them under differences.close_timing. The full comparison (full, or batch_status(detail=True)) keeps them. Measures come back as a, a_again, b and the delta. If A does not repeat, the result says so and points back to an ordinary batch.

When repro sees a flying phase differ far more than the flight’s other flying phases, it lists it under unstable and points here. That’s the mark of a flight near a threshold, and its answer is a rate, not a pair.