Controller and throw recovery: first hover and first throws, in an ideal simulator

4 December 2026 · Scott Friedman · Build log, controller, throw, sim

In an ideal simulator, the first thing my controller did was take off too hard: 18.6% overshoot, from an integrator that kept charging while the drone sat on the floor. A rule with a guessed 0.3 m threshold took it to 3.1%. Then I threw it, 300 times per arm delay, and after fixing a mixer panic that only the Monte Carlo found, it recovered from 97.7% of throws at a 150 ms arm delay and 67.0% at 300 ms. Ideal-state sim, placeholder airframe.

Update (2026-12-04). Added two figures; no number or claim changed.

The question

Two questions, one after the other. First: does the cascaded controller fly a 45 g quad cleanly in a perfect world? The cascade is position PID, then quaternion attitude P, then body-rate PI, then an X-quad mixer that gives attitude priority when the motors saturate. If it can't hover in an ideal simulator, nothing after this matters.

Second: can the same controller catch a drone that leaves my hand tumbling? I want to throw a small drone in any orientation and have it recover into stable flight before it reaches the floor. In the sim that's a release at 2.0 m, spinning at up to 8 rad/s and moving at up to 3 m/s. How much does the delay before the motors start cost? That delay is throw detection plus arming plus spin-up, and it's the number the hardware has to hit.

Everything in this post, and in the four after it, is simulation. Position is perfect throughout, and nothing has touched hardware. I'll say what else each one leaves out as it comes up.

What the physics suggests

An integral term accumulates position error over time. A drone sitting on the floor with a 1 m setpoint has 1 m of error and can't reduce it until the motors make more than its weight. So the integrator keeps charging in those first moments, and when the drone finally lifts off it carries that stored correction past the target.

For the throw, nothing pushes back until the motors spin. In free fall a drone drops ½ g t²: 0.012 m in the first 50 ms, 0.049 m by 100 ms, 0.11 m by 150 ms, 0.20 m by 200 ms and 0.44 m by 300 ms, before any downward throw speed or the time spent righting itself. So the cost should grow faster than linearly with the delay. The pass line for E9-sim is at least 95% success at every arm delay up to 150 ms.

I didn't write a scored prediction down before either run. The project's rule about registering predictions first came later, partly because of runs like these.

The setup

Implementation

The hover fix is conditional integration: accumulate only when the drone is already near the setpoint (control.rs at 7f7d041). i_zone is 0.3 m:

// Conditional integration: only accumulate when close to the setpoint, so a takeoff from
// the ground or a large step does not wind the integrator up (found in sim: 18.6% z
// overshoot on takeoff before this change).
if ep.norm() < self.g.i_zone {
    self.integ = self.integ + ep * dt;
}

Throws needed two more changes. The normal failsafe kills the motors when the drone is flipped past 2 rad, which would kill every inverted throw, so in throw mode the kill threshold is out of reach for 2 s after arming (sim lib.rs at 7f7d041):

let limits = if throw_mode && t < arm_delay + 2.0 { Limits { kill_tilt: 4.0, ..Limits::default() } } else { Limits::default() };

And the mixer fix described below (mixer.rs at 7f7d041):

// When the differential span equals max_thrust, float rounding can leave lo a hair above hi;
// `clamp` would panic (found by the throw-recovery Monte Carlo), so order the bounds first.
let (lo, hi) = (-dmin, g.max_thrust - dmax);
let c = if lo > hi { 0.5 * (lo + hi) } else { c_req.clamp(lo, hi) };

What didn't work

The plain integrator, obviously. The less obvious part is that the fix is a heuristic with a guessed threshold. I picked 0.3 m rather than derived it, and it has never seen a real airframe. A drone pushed more than 0.3 m off its setpoint and held there, by a gust that doesn't let up, gets no integral help at all.

The first throw batch didn't crash any drones. It crashed the program. When the requested torque used up exactly all the motor thrust, float rounding left the mixer's lower bound a hair above its upper bound, and Rust's clamp(min, max) panics on that. The hover tests never went near that corner; 300 tumbling drones found it in the first batch. There's now a regression test that sweeps the full-span case.

The failsafe was wrong for this job too: "flipped over, kill the motors" is the right rule in flight and the wrong one in a throw.

The arm delay here is a timer, not a throw detector. It stays a timer in every experiment in the next four posts, so the hard part of knowing that a throw has happened is still unbuilt at the end of this arc. And with no prediction written down for either run, there was nothing to score, so the runs taught me less than they could have.

Numbers

Hover from the ground to 1 m, then the x step with the gust. Ideal-state sim, placeholder airframe, cargo run --release -p murmur-sim at 7f7d041, rustc 1.99.1. The "before" row is the same commit with i_zone set to 1e9, so the integrator never switches off.

z peakovershootsettled within 2 cmx peak after step + gustRMS, last 5 s
before (no conditional integration)1.186 m18.6%6.67 s1.288 m2.3 cm
after (i_zone 0.3 m)1.031 m3.1%3.73 s1.154 m1.6 cm
Ideal-state sim: takeoff from the ground to 1 m, before and after conditional integration E1-sim takeoff (session 00, BUILDLOG 2026-12-03). Generated by `cargo run --release -p murmur-sim --bin fig -- hover-integrator` at murmur f45fdb803b2f041dd2a0eed38e9b55c3d566e630 (tree clean). Data: murmur_sim::simulate_with_gains, the `hover` scenario of src/main.rs, Attitude::Truth; 'before' is i_zone 1e9 (the integrator never switches off), 'after' the default i_zone 0.3 m. Seeds: gyro noise seed 1, with the noise off. Domain: ideal-state sim, PLACEHOLDER airframe. 0.00 0.25 0.50 0.75 1.00 1.25 0 1 2 3 4 5 6 7 8 time (s) altitude (m) setpoint: 1 m before: peak 1.186 m at 1.99 s (18.6% overshoot) after: peak 1.031 m at 2.46 s (3.1% overshoot) before: peak 1.186 m after: peak 1.031 m before (integrator always on) after (i_zone 0.3 m)
Ideal-state sim. With the integrator always on, the takeoff peaks at 1.186 m, 18.6% over the 1 m setpoint. With conditional integration (i_zone 0.3 m) it peaks at 1.031 m, 3.1% over. The peaks are the table's.Source: murmur@f45fdb8, cargo run --release -p murmur-sim --bin fig -- hover-integrator, gyro noise seed 1 (noise off)

E1-sim (hover RMS under 10 cm with gyro noise 0.05 rad/s) passes at 0.2 mm.

E9-sim, ideal-state sim, cargo run --release -p murmur-sim --bin throw at 7f7d041, 300 throws per row:

arm delaysuccessmedian altitude lostp95 altitude lostcrashes
50 ms99.7%0.57 m1.08 m1
100 ms99.3%0.67 m1.26 m2
150 ms97.7%0.83 m1.64 m7
200 ms94.3%1.05 m2.00 m17
300 ms67.0%1.65 m2.00 m99
E9-sim, ideal-state sim: throws recovered against arm delay E9-sim. Generated by `cargo run --release -p murmur-sim --bin fig -- e9-arm-delay` at murmur f45fdb803b2f041dd2a0eed38e9b55c3d566e630 (tree clean). Data: docs/EXPERIMENTS.md, 'E9-sim-est result', row 'truth (E9-sim)' (bin/throw's numbers, rerun as the control). Seeds: initial conditions 42, gyro noise 11. Domain: ideal-state sim, PLACEHOLDER airframe. 50 60 70 80 90 100 50 100 150 200 250 300 arm delay after release (ms) throws recovered, % of 300 pass line: 95% up to 150 ms true attitude: 99.7% at 50 ms true attitude: 99.3% at 100 ms true attitude: 97.7% at 150 ms true attitude: 94.3% at 200 ms true attitude: 67.0% at 300 ms 67.0% at 300 ms
Ideal-state sim, 300 throws per arm delay. Recovery stays above the 95% pass line through 150 ms (97.7%), then falls to 94.3% at 200 ms and 67.0% at 300 ms.Source: murmur@f45fdb8, cargo run --release -p murmur-sim --bin fig -- e9-arm-delay, seeds 42 (initial conditions) and 11 (gyro noise)

Pass line (at least 95% at every delay up to 150 ms): pass, in ideal-state sim. Re-running both binaries reproduces the build-log numbers exactly. Both rows are on the experiments page.

This table matters for everything after it. 99.7 / 99.3 / 97.7% at 50 / 100 / 150 ms is the ceiling: it's what the controller does when it's handed the true attitude. Every later estimator experiment reruns it as a control in the same binary and voids itself if the numbers don't come back exactly, and every later result is measured against it.

What this does not show

Anything about flight. True state goes into the controller, so there's no estimator lag and no sensor noise beyond a little gyro jitter. A real drone has to estimate its attitude in the middle of the tumble, and its position fixes may drop out. The airframe numbers are guesses. Motor spin-up is a 20 ms first-order lag I haven't measured, with no ESC behavior at all. The arm delay is an input, not a detector. What this does show is that the controller structure and the mixer behave in an ideal world.

What's next

Feed the controller an estimated attitude instead of the true one. In free fall the accelerometer reads about zero, so the first question is what that costs (the next post). Then a frame on a scale and a motor on a thrust stand for real spin-up numbers. The IMU placeholders are tracked in #5.

Takeaway

The integrator didn't know the drone was sitting on the floor, so it kept trying harder; telling it to wait until the drone is close cut takeoff overshoot from 18.6% to 3.1%. Throw recovery is a race against the floor. Each extra 50 ms of delay costs 0.10 to 0.30 m of median altitude, more the longer the delay, and by 300 ms a third of throws crash, so the design target is detect, arm and spin up in under 150 ms. A Monte Carlo is worth running for its own sake: it found a panic no hover test would have reached. All of it is only as real as the ideal simulator it came from.