Fly a flight exactly
A replay with repro is usually a second flight: close to the first, within half a percent on a gusty hover, but not the same. That spread is the noise every comparison has to see past. An exact flight has none. Fly it twice, and the two logs agree on every IMU sample, every estimator state and every motor output, at any speedup and however busy the machine is.
The price is that nothing steers it once it starts. An exact flight is a mission: the server uploads it, the autopilot flies it, and nothing from outside steers it until it lands.
Open an exact session
Section titled “Open an exact session”open_sitl(label="exact-hop", exact=True, set={"Q_A_RAT_RLL_P": 0.25}, # parameters: here, at boot wind={"speed_mps": 6, "from_deg": 270, "gusts": "sitl"})exact=True pins SITL’s clock, logs from boot rather than from arming, and sends no RC overrides. An exact session is set up entirely by open_sitl. Parameters go in set and the wind in wind, and both are written to SITL’s boot parameters, not sent afterwards. Wind gusts are SITL’s own (gusts: "sitl") or none. Dryden gusts are refused, because this server drives them tick by tick over MAVLink.
A preset with rc (often there to pick its boot mode) still opens an exact session: its rc is left out with a warning, and the recipe records none, so a replay does not bring it back. The flight’s own mode comes from fly_exact instead, AUTO for a mission and arm_mode for a step program.
The wind is uniform by default, so it blows on the pad too, which is fine: fly_exact flies the mission in a second boot (below), where nothing on the pad happens at a wall-clock moment.
Fly the mission
Section titled “Fly the mission”fly_exact(session_id="9c41d2", items=[ {"cmd": "NAV_VTOL_TAKEOFF", "alt_m": 6}, {"cmd": "NAV_LOITER_TIME", "params": [8], "alt_m": 6}, {"cmd": "NAV_VTOL_LAND"},]){ "anchor_s": 45, "anchor_utc": "2026-09-21T14:14:05+00:00", "anchor_clock": "SITL's pinned clock (exact flights fix it), not today's date", "armed": true, "refused": null, "rebooted": true, "snapshot": { ... } }anchor_utc is on SITL’s own clock, which an exact session pins to 2026-09-21 14:13:20 UTC at boot so that a time of day is a function of sim time. Every exact flight therefore reads as that September day, whenever it was flown, and anchor_clock says so.
fly_exact stores your items behind three of its own, then boots SITL again on them, in place: the same instance, run directory and parameters, with the stored mission and the vehicle in AUTO from its first tick (INITIAL_MODE 10, the mode switch off). The first item holds 20 s, long enough for GPS to set the clock. The second waits, disarmed, for the anchor, a whole sim second counted from that second boot, 45 unless you pass at_s (30 at the earliest). The third arms the vehicle from inside the mission. The call returns once the vehicle has armed at the anchor, about 10 s of wall time later than without the reboot. If the autopilot refuses to arm, it returns armed: false with the PreArm text instead.
The second boot starts on what the first one saved, so fly_exact compares the parameters both boots started with (from the PARM records each one logs at boot). Anything the first boot saved at a wall-clock moment, a Lua script’s set_and_save for instance, makes it refuse by name before the anchor and switch the vehicle out of AUTO. Counters, the airspeed offset (recalibrated by every boot), the sim’s speed and the mission’s length are expected to differ and pass. A parameter a Lua script registers at runtime is logged only when it changes, so the first boot may never log it. It passes when the second boot starts it at its default.
reboot=False flies the mission in the running SITL instead: it waits for the vehicle to be quiescent for 3 sim seconds, uploads, and switches to AUTO, with at_s 15 s from now by default. That repeats only while the pad is calm (SITL’s own wind profile, SIM_WIND_T 0, gives that), and it is what recipes from before the reboot replay with.
Then watch it fly and close the session as usual:
wait_until(session_id="9c41d2", condition="disarmed", timeout_s=180)close_sitl(session_id="9c41d2")From open_sitl to close_sitl, the steering tools refuse, each saying why: rc_override, set_mode, arm, set_param, set_wind, upload_mission, fly_steps and wait_until with actions. snapshot, wait_until, video_feed, set_speedup, disarm and close_sitl all still work. Speed is free because the speedup changes how fast the sim runs, never what it computes.
Fly a step program exactly
Section titled “Fly a step program exactly”A mission can’t move a stick, change a gain, or switch a mode partway through. A step program can, and fly_exact runs it inside SITL, on the physics step, so it repeats too. This needs a SITL built with sitl-patches/sitl-program.patch. A SITL without it is refused by name.
fly_exact(session_id="9c41d2", arm_mode="QLOITER", steps=[ {"label": "climb", "rc": {3: 1750}, "until": "altitude", "value": 6}, {"label": "hold", "rc": {3: 1500}, "until": "time", "value": 5}, {"label": "gain", "params": {"Q_A_RAT_RLL_P": 0.2}, "until": "time", "value": 3}, {"label": "land", "mode": "QLAND", "until": "disarmed", "timeout_s": 120},])The steps are fly_steps’ steps. At the anchor, SITL sets arm_mode and arms. Each step’s sticks, parameters (a wind becomes its SIM_WIND_*) and mode then apply on a physics step, and its condition is checked on every step after. The conditions are altitude (above where it armed), airspeed, mode, armed, disarmed, time and sim_time. Texts, mission items and the landed state aren’t the simulation’s, so a landing ends with disarmed. steps_status follows the program from the texts SITL sends (“Prog step 2 met 59.628”). Each step’s start and end come to the millisecond, while its snapshot is taken a few ticks later, when the text arrives. repro follows a program to its end before closing, just as fly_steps is followed.
That hop, in 3 m/s of wind on the pad, flew twice at once and again through repro. Every record matched from the anchor, including the gain change at 56.628 s.
Fly it again, and check it
Section titled “Fly it again, and check it”repro(log="20261006T201255Z-exact-hop.BIN")The recipe holds the anchor, so the replay waits for the same sim second. Alongside the usual compare, a repro of an exact flight returns identical. It is the two logs checked record by record from the anchor: SITL’s truth (SIM, SIM2), the sensors (IMU, GPS, BARO), the estimator (XKF1), attitude, motor outputs and battery.
"identical": { "identical": true, "from_s": 26, "records_checked": { "SIM2": 30443, "IMU": 60888, "XKF1": 2030, ... }, "first_difference": null }If anything differs, first_difference names the record, its time and the fields. Two fields are left out of the check: SIM2.ASpdU and SIM2.UFC are SITL’s achieved speedup and frame count, which describe the host rather than the flight.
What it cannot do
Section titled “What it cannot do”The plan is fixed when it starts. A flight that reacts, such as “climb until the battery reads 22 V, then land”, needs the steering tools, so it belongs in an ordinary session with fly_steps. Mission items that wait on conditions inside the autopilot are fine, though, because the autopilot evaluates them on its own clock. The explanation covers why the line falls exactly there.