Skip to content

01Personal projectSept 2026 – now

Precision landing

A flight stack and simulator that land a multirotor on an AprilTag pad

Simulation

10.1 cm from pad centre in the demo run

0 m1 m2 m3 m4 m0 m1 m2 mDISTANCE FROM PADALTITUDEPLAN VIEW · ±2.4 mAROUND THE DRONERINGS EVERY 5 cm

Camera poses 40 ms late, wind 0.7 m/s with gusts. It starts 4.0 m up and 2.2 m off the pad, and lands 10.1 cm from the pad centre.

Altitude
4.00 m
Est. offset
—
Estimate error
—
  1. SEARCH
  2. TRACK
  3. DESCEND
  4. FINAL

Fig. 00The logged landing. Scrub the run. Amber is where the drone was, blue is where the Kalman filter thought it was, and the dots are the raw tag detections it was fed.

A Raspberry Pi finds an AprilTag pad with its camera and lands a multirotor on it. It flies like a pilot, sending stick commands to the flight controller over the MSP serial protocol (v1 and v2) at 50 Hz.

This is a simulation project. My simulator answers the same protocol with a mock flight controller that has wind, ground effect, battery sag and sensor noise. A test fails the build if the flight code ever imports the sim. I wrote the flight stack and the simulator; a partner wrote the detector.

ID 0ID 10.400 m0.100 m0.35 m0.10 mPAD ORIGINID 2 · 0.025 mTAG36H11 · SIDE BY SIDE, NOT NESTED: A TAG INSIDE ANOTHER CORRUPTS THE OUTER CODE
Fig. 01The pad. Three tag36h11 tags, each sized for a band of altitudes, all registered to one origin.

What the camera sees

The simulator renders every camera frame, so vision runs on real images. Three tags of different sizes share one origin, and the stack hands over from one to the next on the way down.

Three camera frames the landing simulator rendered at 4.0 m, 2.1 m and 0.5 m. The tag pad grows in the frame as the drone descends, and each detected tag is outlined.
  1. 4.00 m
    TRACK
    11.7 s
    tags 0 + 1
  2. 2.09 m
    DESCEND
    17.7 s
    tags 0 + 1
  3. 0.50 m
    DESCEND
    23.7 s
    tags 1 + 2
Fig. 02What the camera sees. Frames the simulator rendered at 4.0 m, 2.1 m and 0.5 m, each 640 × 480 as the camera model gives them. Each detected tag is outlined, and the two ticks mark the pad origin worked out from it. The detector runs on these images, not on ground truth.

How it works

The tag pose goes into a Kalman filter whose noise grows with range squared. PID loops turn position error into stick commands, with the D term taken from the filtered velocity. A mission state machine moves through search, track, descend and final, and can abort or hand control back to the flight controller.

CAMERADETECTORAprilTagKALMAN FILTERnoise ∝ range²PID GUIDANCED from velocityMSP v1/v2sticks, 50 HzMISSION STATE MACHINEsearch to final · abort · handbackRENDERED FRAMESMOCK FLIGHT CONTROLLERwind · ground effect · battery sag · noiseA TEST FAILS THE BUILD IF THE FLIGHT CODE EVER IMPORTS THE SIMULATOR
Fig. 03The loop. Flight code along the top, simulator underneath. They meet only over the serial protocol.

The demo run

The drone starts 4 m up and about 2.2 m off the pad. It centres, descends and touches down 10.1 cm from the pad centre.

TRACKDESCENDFINALTOUCHDOWN0 m2 m4 mALTITUDETRUTHTELEMETRY0 m1 m2 mDISTANCE FROM THE PAD CENTRETRUTHKALMAN ESTIMATEGATES: 0.20 m TO DESCEND · 0.08 m TO COMMIT0 s5 s10 s15 s20 s25 s0 cm5 cm10 cmLOG TIMEDISTANCE FROM THE TRUE POSITIONRAW TAG DETECTIONSKALMAN ESTIMATE
Fig. 04The demo run. Plotted from the logged run (demo_offset_approach, seed 0), the same log the replay flies. The dots are the raw tag detections the filter was fed.

The estimate sits that close to the truth because the simulated camera is clean. At 4 m a raw tag detection is typically 2 cm off, and the filtered estimate about the same. Real flight will be noisier than this: attitude error, motion blur and timing all add to it.

The replay at the top can also fly the suite's 150 ms latency run. With the poses arriving that late, the estimate is typically 9 cm off at 3 m, and the drone still lands 5.1 cm from the pad centre.

IDLESEARCHACQUIRETRACKDESCENDFINALDISARMarmed + overridedetectionspose stablecentred < 0.2 m, 2 slow and centredtouchdownABORTHANDBACKFAILSAFES: ABORT · HANDBACK STOPS TRANSMITTING, AND THE FLIGHT CONTROLLER'S OWN FAILSAFE LANDS IT
Fig. 05Mission state machine. The path through a normal landing, with the transition reasons the simulator logged.

The best bug

Running the flight code as its own process on a Linux pseudo-terminal, with real MSP bytes, showed the 50 Hz stick stream stuck behind the telemetry serial lock.

Other things the sim caught

The Kalman filter's measurement variance was set to a 10 cm sigma, against a real pose noise of about 1 cm. The estimate lagged by hundreds of milliseconds, and no pair of gains settled. Hovering in ground effect looked like a landing until touchdown detection also checked throttle. 16 wrong assumptions in all, each written up.

The suite has 18 scenarios (gusts, tag loss, latency, dropout), each with numeric pass limits. 16 of 18 pass on one seed. There are 131 unit tests.

What still fails

  • A strong gust can push the pad out of view, and search has nothing to steer by, so it never finds it again.
  • An inverted stick sign isn't caught in flight.
  • The 30-seed Monte Carlo hasn't run yet, so results are one seed each.