Operations: links, logs, rules and fleets in service · 6 MIN READ

Post-flight incident analysis: timeline, contributing factors and a verified change

Reconstruct an incident from the autopilot's event timeline and recorded telemetry, separate what the ground station saw from what happened, compute contributing factors such as time without a fix and drift against the planned stand-off, write a blameless summary, change one thing and re-fly the same fault to verify it.

Sooner or later a flight ends in the wrong place: against a wall, in a field, in a tree. What happens next decides whether it happens again. An incident analysis rebuilds the timeline from the logs, measures the factors that combined, and ends with a change that has been tested, not with a name. This lesson works through a GPS outage beside a tower in the simulator, where the ground station showed a drone holding still while it drifted into the wall.

drones · A MAP OF THE IDEA

  1. Preserve logs and events
  2. Rebuild the timeline
  3. Measure contributing factors
  4. Change one thing, re-fly

Useful when

  • Separates what the operator saw from what happened.
  • Every action is verified by re-flying the same fault.

Watch out

  • Telemetry freezes during an outage and looks like a hover.
  • One root cause hides the other factors that combined.

Implementation & operation cost: Event and telemetry logging at known rates, a replayable simulator scenario per incident, and time for a blameless review.

01

Evidence: timeline, telemetry and truth

Three kinds of evidence survive a flight. The autopilot's event messages (STATUSTEXT over MAVLink, sim.Events() here) say what it decided and when. The telemetry the ground station received says what the operator could see, at its own rate and with its own gaps. The onboard log, an ArduPilot DataFlash log or a PX4 ULog, records sensors and estimator state at much higher rates and is the nearest thing to the truth, together with where the aircraft came down. Copy all of it before anyone powers the vehicle up or flies again, and put everything on one clock. Telemetry needs the most care: during a GPS outage the position it reports is the last fix, frozen, and to a ground station a drifting drone looks like one in a perfect hover. In the simulator the true position stands in for the onboard log and the wreck, so the program records both what was sent and what happened, five times a second.

02

Reconstruct the flight, then measure

An inspector drone climbs to 15 m and stops at two photo points 7 m west of a 30 m tower, with a 6 m/s wind blowing from the west towards it. At the second stop the receiver loses its fix for 20 s, as it can beside a tall structure that hides half of the sky. The analysis prints every event with the distance to the wall according to the telemetry and according to the truth, derives the contributing factors from the event times and the log, flies the same flight with the tower removed to see where the drift was heading, prints a summary, and re-flies the same outage after one change.

go
package main

import (
	"fmt"
	"log"
	"math"
	"strings"

	"gopherforge.app/drone"
)

var (
	tower = drone.Obstacle{Name: "tower", Y: 40, Radius: 5, Height: 30}
	wind  = drone.Vec3{X: 6} // from the west
)

// Row is one line of the flight log at 5 Hz: what the ground station
// received, and the true position the simulator knows (on a real aircraft,
// the onboard log and the wreck are the nearest thing to it).
type Row struct {
	T          float64
	GPS, Truth drone.Vec3
}

// surface is the horizontal distance from p to the tower's wall.
func surface(p drone.Vec3) float64 { return math.Hypot(p.X-tower.X, p.Y-tower.Y) - tower.Radius }

// Fly inspects a face of the tower from x = side at 15 m, with photo stops
// at two points. At the second the receiver loses its fix for 20 s, as it
// can next to a tall structure that hides half of the sky.
func Fly(side float64, obstacles []drone.Obstacle) (*drone.Sim, []Row) {
	sim := drone.New(drone.Config{Wind: wind, Gust: 1.5, MaxSpeed: 4, Seed: 5, Obstacles: obstacles})
	sim.Drone().Name = "inspector"
	d, rows := sim.Drone(), []Row{}
	run := func(limit float64, done func() bool) {
		sim.RunUntil(limit, func(float64) bool {
			if tel := d.Telemetry(); len(rows) == 0 || tel.Time > rows[len(rows)-1].T {
				rows = append(rows, Row{tel.Time, tel.GPS, d.State().Pos})
			}
			return done()
		})
	}
	d.Arm()
	d.TakeOff(15)
	run(30, d.Arrived)
	for i, y := range []float64{30, 40} {
		d.GoTo(drone.Vec3{X: side, Y: y, Z: 15})
		run(60, func() bool { return d.State().Mode != drone.GoingTo })
		if i == 1 {
			d.LoseGPS(20)
		}
		run(4, func() bool { return d.State().Mode != drone.Hold }) // photos
	}
	if d.State().Mode == drone.Hold {
		d.Land()
	}
	run(60, func() bool { return d.State().Landed || d.State().Mode == drone.Crashed })
	return sim, rows
}

// at returns the first log row at or after time t.
func at(rows []Row, t float64) Row {
	for _, r := range rows {
		if r.T >= t-1e-9 {
			return r
		}
	}
	return rows[len(rows)-1]
}

// event finds the first note on the timeline that starts with prefix.
func event(sim *drone.Sim, prefix string) (float64, bool) {
	for _, e := range sim.Events() {
		if strings.HasPrefix(e.Text, prefix) {
			return e.T, true
		}
	}
	return 0, false
}

func main() {
	incident, rows := Fly(-12, []drone.Obstacle{tower})
	fmt.Println("timeline                                      to the wall: telemetry / truth, height")
	for _, e := range incident.Events() {
		r := at(rows, e.T)
		fmt.Printf("%6.1f s  %-37s %5.1f / %5.1f m  %4.1f m\n", e.T, e.Text, surface(r.GPS), surface(r.Truth), r.Truth.Z)
	}

	lost, _ := event(incident, "GPS lost")
	landing, _ := event(incident, "no GPS")
	hit, crashed := event(incident, "hit")
	if !crashed {
		fmt.Println("no contact: the drone landed in the open, so there is no incident to analyse")
		if err := incident.Save(); err != nil {
			log.Fatal(err)
		}
		return
	}
	end := incident.Drone().State()
	before, last := at(rows, lost), at(rows, incident.Time())
	standoff := surface(drone.Vec3{X: -12, Y: 40}) // the photo point
	toward := drone.Vec3{X: tower.X + 12, Y: tower.Y - 40}
	// The same flight with the tower removed shows where the drift was going.
	_, free := Fly(-12, nil)
	gone := free[len(free)-1]
	budget := gone.Truth.Sub(before.Truth).Horizontal().Len()

	fmt.Println("contributing factors")
	fmt.Printf("  stand-off planned: %.1f m from the wall, upwind of it; contact at 0.3 m\n", standoff)
	fmt.Printf("  wind towards the tower: %.1f m/s, gusts up to 1.5 m/s\n", (wind.X*toward.X+wind.Y*toward.Y)/toward.Len())
	fmt.Printf("  no fix for %.1f s at contact; the failsafe landing began at +%.1f s and was %.1f m up at contact\n", hit-lost, landing-lost, end.Pos.Z)
	fmt.Printf("  drift from the last fix: %.1f m; telemetry showed %.1f m of movement\n", end.Pos.Sub(before.Truth).Horizontal().Len(), last.GPS.Sub(before.GPS).Horizontal().Len())
	fmt.Printf("  without the tower: drift %.1f m in %.1f s, until touchdown\n", budget, gone.T-lost)

	fmt.Println("summary (blameless)")
	fmt.Printf("  At %.1f s the GPS fix was lost while the drone held a photo point %.1f m upwind of the tower.\n", lost, surface(before.Truth))
	fmt.Printf("  Without a fix the autopilot keeps level, so it drifted with the 6 m/s wind; the no-GPS failsafe\n")
	fmt.Printf("  started a landing after 3 s, which does not stop drift. Contact came %.1f s after the loss at %.1f m up,\n", hit-lost, end.Pos.Z)
	fmt.Printf("  while the ground station still showed the last fix. The plan's %.1f m stand-off was measured\n", standoff)
	fmt.Printf("  around the tower, not along the wind; the drift budget for this outage is %.0f m.\n", budget)
	fmt.Println("change: inspect the lee face (x = 12), so the drift carries the drone away; same outage")
	sim, again := Fly(12, []drone.Obstacle{tower})
	closest := math.Inf(1)
	for _, r := range again {
		closest = min(closest, surface(r.Truth))
	}
	st := sim.Drone().State()
	fmt.Printf("re-flight: %s %.1f m from the wall, never closer than %.1f m to it\n", strings.ToLower(st.Mode.String()), surface(st.Pos), closest)
	if err := incident.SaveAs("incident"); err != nil {
		log.Fatal(err)
	}
	if err := sim.Save(); err != nil {
		log.Fatal(err)
	}
}
Read the code

Until the outage telemetry and truth agree to within about a metre of GPS error: 7.4 m and 7.0 m from the wall at the second photo point. The fix goes at 23.5 s, and from then on the telemetry says 7.4 m on every line. At 26.5 s the failsafe note 'no GPS for 3 s: landing' arrives when the truth is already 3.3 m, and at 27.8 s 'hit tower' comes at 0.3 m, 12.7 m up. The factors: a 7.0 m stand-off on the upwind side; 6.0 m/s of wind towards the tower; contact 4.3 s after the loss, 1.3 s into a landing that descends but does not stop the drift; 7.0 m of drift while the telemetry showed 0.0 m of movement; and, without the tower, 43.6 m of drift in the 14.7 s to touchdown. The same outage on the lee face ends with a landing 50.5 m from the wall, never closer than 6.9 m. incident.gfflight ends at the wall; flight.gfflight is the re-flight.

03

Contributing factors, not a root cause

Incidents rarely have one cause; several ordinary conditions line up. Here a GPS outage is expected near tall structures, a 6 m/s wind is unremarkable, and the failsafe did what it is designed to do. Without a position the autopilot can only hold attitude, so the drone moves with the air. PX4 documents the same choice for multicopters: with no position estimate at all its failsafe falls back to Descend. ArduPilot's EKF failsafe switches to Land by default, which descends while letting a pilot steer. Neither stops the drift by itself. What made the outage dangerous was geometry: the 7 m stand-off was measured around the tower, while the drift went along the wind, and the drift budget of this outage was about 44 m. Each factor gets a measurement, a cause and an owner, because a single root cause invites a single fix and leaves the other holes open.

04

A blameless summary

The summary describes what happened, the timeline, the impact, the contributing factors, what worked and the actions, each with an owner and a way to verify it. Blameless means it records decisions as they looked with the information available at the time and asks why the system allowed the outcome, not who erred; aviation calls the wider principle just culture, and it is what keeps people reporting near misses. The program's summary is written from its own measurements: when the fix was lost, why the drone drifted, why the failsafe did not stop it, what the ground station showed, and which planning assumption failed. Some events must also be reported to an authority. The FAA, for example, requires the remote pilot in command of a small drone to report within 10 days an accident causing serious injury, loss of consciousness, or damage to property other than the drone above 500 dollars to repair or replace. Check what applies where you fly.

05

Change one thing, then re-fly the fault

Change one thing at a time, or you cannot tell which change helped. Here the change is the plan: inspect the lee face, so that any drift carries the drone away from the structure, with the same outage injected at the same point and the same seed. The re-flight drifts about as far and lands in the open. Then ask what the change costs and what it does not cover. A real lee face has turbulence the simulator does not model, the wind can veer during the flight, and the downwind drift footprint must be clear of people and other obstacles. Turn the incident into permanent checks: a planner rule that keeps obstacles out of the downwind drift budget, and a scenario in the property tests that injects GPS outages near obstacles. Only then close the incident.

06

Fly it in GopherForge

In GopherForge choose New project > Robotics and simulation > Drone flight, replace main.go with this program, keep mission.go and tap Run. Output lists two recordings: incident.gfflight shows the grey tower, the photo stops and the drift into the wall, and flight.gfflight shows the lee-face flight drifting away and landing in the open. Change LoseGPS(20) to LoseGPS(2): the fix returns before the failsafe, the drone holds again, and the program reports that there is nothing to analyse.

TAKE THIS WITH YOU

Rebuild the timeline from event messages and logs on one clock, treat telemetry during an outage as stale, measure each contributing factor, and write a blameless summary whose actions are tests. Here the stand-off had to be measured along the wind against the drift budget of an outage; change one thing and re-fly the same fault before closing the incident.

Check your understanding

A drone holding 7 m upwind of a tower loses GPS in a 6 m/s wind and touches the wall 4.3 s later. Why was the 7 m stand-off not enough?

Go to the source

Progress stays in this browser. No account needed.