DeftechSenior

Drone software

Drone software is the flight code on an uncrewed aircraft and the ground software commanding it, built to stay safe when the link, position or battery fails. An uncrewed aircraft is a distributed system in which one node falls out of the sky if it misses a deadline, and that one fact decides which code runs where, what may block and what may crash. The page opens with the twenty-five-line flight-readiness checklist, then covers the stack as a hierarchy of deadlines, the failsafe ladder as the real specification, the return decision as an energy calculation, autonomy as a list of decisions, simulation as the test environment, and seven documented accidents.

Stack is ordered by
Deadlines, not layers
The specification is
The failsafe ladder
Return is triggered by
Energy to home, not %

The flight-readiness checklist

Here is the whole checklist first, because it is what a flight-readiness review asks and because every line on it has already cost somebody an aircraft — seven of those accidents are at the bottom of this page. It is numbered so a line can be cited: "we have never run 2.4" is a work item, where "the failsafes need a look" is a mood. It is written for the team that builds or integrates the software, on , or an autopilot of its own. It is not the operator’s pre-flight card, though half of group 5 ends up printed on one.

Do groups 2 and 6 first. The failsafe configuration is what the aircraft actually does when something goes wrong, and until a fault has been injected in simulation, nobody has seen that configuration run.

  1. 1.The stack and its boundaries

    1. The flight controller runs control and state estimation and nothing else. A feature does not go there because it is "closer to the hardware".
    2. The companion computer reaches the autopilot through one message interface, as an untrusted client: every setpoint it sends is range-checked and may be refused.
    3. The autopilot watches a heartbeat from the companion computer and has a configured action for when it stops.
    4. No control decision on board waits for the ground link to complete.
  2. 2.The failsafe ladder

    1. Every condition has a configured action: control link lost, position lost, energy low, boundary reached, companion computer silent, estimator unhealthy.
    2. Each action is enforced at the lowest tier that can enforce it — the boundary and the energy reserve in the autopilot, never only in the ground station.
    3. Combinations are tested, not only single conditions: link lost with low energy and a headwind is its own case.
    4. The last rung — land in place, parachute, flight termination — has actually been exercised, and what it does over people, water and roads is written down.
  3. 3.Energy and the way home

    1. Return is triggered by the energy needed to get home plus a landing reserve, computed from distance and wind — not by a fixed battery percentage.
    2. Remaining capacity is estimated from the charge consumed as well as the voltage, and the estimate is known to read high in the cold.
    3. The lost-link route avoids people and ends somewhere a forced landing is acceptable — not in a loop flown until the fuel runs out.
    4. A link-loss grace timer lets routine drops pass without ending the mission, and its value is a reviewed decision rather than a default.
  4. 4.Position and state

    1. Estimator health is monitored, and an estimate that stops being trustworthy is a failsafe condition of its own, not a warning on a screen.
    2. Losing satellite positioning leads to a defined behaviour: hold on inertial and visual estimation for a stated number of seconds, then descend or return.
    3. Every sensor that can end a flight is cross-checked against another: a satellite fix or an altitude reading that disagrees with the rest is distrusted, not obeyed.
    4. Every measurement carries a timestamp that is checked, because a stale reading presented as fresh does more damage than a missing one.
  5. 5.Ground station and configuration

    1. Parameters live in version control per airframe, and a change to them is reviewed like a change to code.
    2. Before flight, the parameters on the aircraft are compared with the reviewed set, and any difference blocks launch.
    3. A setting loosened for a test or a demonstration has an owner and an expiry date.
    4. Firmware, parameters and mission files are confirmed on each aircraft: a fleet is N confirmations, not one upload.
    5. Control cannot pass between consoles or operators while the two disagree on a control position, and a safety-critical fault has an alarm of its own.
  6. 6.Tests and evidence

    1. simulation runs on every merge, and each simulated mission asserts on the recorded log.
    2. runs on a schedule, because timing faults and driver bugs are invisible to pure simulation.
    3. Faults are scripted cases in the suite: cut the link, freeze a sensor, shift a timestamp, drop the battery reading, stop a motor.
    4. Every flight log is kept and can be replayed, and a fault seen once in the air becomes a test case that runs forever.

The stack is a hierarchy of deadlines

It is tempting to read onboard software as layers of abstraction, the way a web application is read. It is more useful to read it as layers of how long each part may take. The innermost control loop runs hundreds of times a second and has a hard deadline: miss it and the aircraft becomes unstable within a fraction of a second. Everything above it has progressively more slack, and the amount of slack decides what may live there.

A flight stack is best read as a hierarchy of deadlines rather than of abstractions. The flight controller keeps the aircraft in the air on a hard real-time loop measured in milliseconds; it may wait for nothing, which is why it is small, deterministic and almost never where new features go. The autopilot above it turns a mission into setpoints at a slower rate. The companion computer runs everything that can afford to be late — perception, planning, video handling — and its failure must not reach the tier below. The ground station is drawn deliberately as an input rather than a dependency, because the link will drop and the aircraft still has to behave. That is why the failsafe ladder, not the mission logic, is the real specification: what happens when the link goes, when position is lost, when the energy to get home runs low, when the boundary is reached. Those four answers are the difference between a demonstration and something that can be flown.

One detail the diagram simplifies, and it matters when you read PX4 or ArduPilot code. The first two tiers are usually the same board running the same firmware. The rate controller, the state estimator, the navigation code and the mode logic are tasks on one microcontroller, separated by priority and loop rate rather than by a cable. So the boundary between them is a scheduling decision, and adding work to a fast task is exactly how a feature steals time from stabilisation. The companion computer is the first tier that is genuinely a separate machine, which is why it can be allowed to fail.

TierWhere it runsDeadlineOpen-source examplesNever allowed to
Flight controllerA microcontroller on the flight boardHard: a missed cycle is instabilityPX4, ArduPilot; Betaflight and INAV on FPV craftAllocate memory in flight, touch the network, wait on a tier above
AutopilotThe same board, lower-priority tasksFirm: tens of hertzPX4 navigator and commander; ArduCopter and ArduPlane; the EKF2 and EKF3 estimatorsDepend on the ground link for anything that keeps the aircraft safe
Companion computerA Linux single-board computerSoft: best effortROS 2 through PX4’s uXRCE-DDS bridge, MAVROS, MAVSDKHold authority; its crash has to stop at the interface
Ground control stationA laptop or tablet on the groundHuman time: seconds to minutesQGroundControl, Mission PlannerBe the only place a safety rule lives
The linkOne radio, sometimes severalNone — it is an inputMAVLink over a telemetry radioBe assumed present

MAVLink deserves one sentence of its own, because almost every open-source ground station and companion library speaks it. It is a compact message protocol between the vehicle and everything outside it: a heartbeat once a second so each side knows the other is alive, telemetry streams, commands with acknowledgements, and a mission protocol in which the vehicle requests the waypoints one at a time and acknowledges the upload as a whole. The acknowledgements are the part to respect. A command that was sent is not a command that was accepted, and ground software that treats the two as the same is how an aircraft ends up flying a mission nobody finished uploading.

The failsafe ladder is the specification

A mission plan describes what should happen. The failsafe configuration describes what will happen, and it is the part that decides whether a vehicle can be flown at all. A failsafe is a behaviour configured in advance for one specific failure: the condition that triggers it, and the action the vehicle then takes on its own, with nobody asked. Each entry answers one question — this has happened, what now — and every answer is a trade with no free option.

ConditionReasonable behaviourThe trade it makes
The control link is lostContinue the mission for a set time, then returnReturning at once wastes most flights, since links drop routinely. Never returning loses the aircraft.
The position fix is lostHold on inertial and visual estimation, then descend or return on a dead-reckoned courseDead reckoning drifts. The longer you trust it, the further you are from where you think you are.
Energy is running lowReturn now, with the trigger computed from distance and wind — the next sectionA fixed percentage is wrong at both ends of the flight.
A geographic boundary is reachedRefuse to cross it, whatever the mission or the operator asksIt has to be enforced in the autopilot, or it is advice rather than a boundary.
The companion computer goes silentFall back to the last valid autopilot mode and carry on without itThe aircraft loses its clever behaviour and keeps flying, which is the right order of priorities.
The state estimate is unhealthySwitch to a mode that needs no position — hold altitude, or landLanding blind can be worse than holding; which is right depends on what is underneath.

Two properties of that table are worth extracting, and they are lines 2.2 and 2.3. First, every behaviour has to be enforced at the lowest tier that can enforce it. A boundary implemented in the ground station is a suggestion, because the ground station is exactly what disappears. Second, failsafes interact, and the interactions are where the surprises live. Link lost plus low energy plus a headwind is a different situation from any of the three alone, and a configuration that handles each one individually can still produce an aircraft that flies confidently away from home.

This is also why availability is the wrong target for anything that flies. A percentage of uptime describes a service that is either up or down. An aircraft spends its interesting minutes in the partial states — flying without the link, without satellite position, without the companion computer — and the useful specification names what still works at each level of loss. The failsafe table is that specification, written down.

Return is an energy calculation, not a percentage

The most common battery setting in the field is some version of "return at 30%". It reads as caution, and it is wrong at both ends of the flight. The energy an aircraft needs to get home grows with the distance to home and with the wind it will fly into on the way. A fixed percentage knows neither.

Take an illustrative multirotor that uses about 4% of its battery per kilometre in still air and wants 10% in reserve to land. One kilometre out, it needs 14% to get home, so a 30% trigger sends it back with 16% of the battery never used. Five kilometres out, it needs 30% — the threshold is exactly right at one distance and nowhere else. Now add a headwind that halves its ground speed. Every kilometre takes twice as long and costs roughly twice the energy, so five kilometres out the same aircraft needs about 50%, and the 30% trigger fires when it can no longer make it.

A fixed battery trigger is right at exactly one distance in exactly one wind. The chart uses an illustrative multirotor that spends about 4% of its battery per kilometre in still air and keeps 10% in reserve to land, so the battery needed to get home is 10% plus 4% for every kilometre out. A headwind that halves the ground speed doubles the time spent on each kilometre and so roughly doubles the energy: 10% plus 8% a kilometre. A 30% trigger matches the still-air line at 5 km and the headwind line at 2.5 km. Closer than that, it sends the aircraft home with battery it never used. Further out in wind, it fires when the aircraft can no longer make it home. The trigger worth configuring is computed from the distance and the wind with the landing reserve included — and a cold battery, which delivers less than it reports, is treated as a smaller one.

Both major open-source autopilots give you more than one number to work with. ArduPilot has a two-stage battery failsafe, low and critical, each triggered by voltage or by capacity consumed, and each with its own action. PX4 has low, critical and emergency levels and, separately, a failsafe for exactly this problem: it estimates whether the remaining battery is only just enough for a return, and engages Return mode when it is. Whichever you use, the reviewed decision is line 3.1 — what the trigger is computed from — not which percentage to type in.

The same reasoning applies to the route home, which is line 3.3. A lost-link route is a flight plan that runs with nobody watching, so it gets the review a mission gets and more: where it crosses people, what altitude it holds over the terrain it actually crosses, and where it ends if the link never returns. "It flies a loop until contact comes back" is not an ending. It is a decision about where the aircraft comes down when the energy runs out, left unmade.

Autonomy is a set of decisions, not a level

Autonomy is usually discussed as a scale from remote control to full independence, which is a useful summary and a poor engineering tool. The question a design actually has to answer is narrower, and it repeats for every capability: which decisions does this vehicle make alone, on what evidence, within what limits, and which does it hold and ask about. Answering that list is the design. The level is a label you can apply afterwards.

Two questions sort every decision: is its deadline shorter than a round trip to a person, and can a wrong call be undone. Three of the four answers are familiar. Short and reversible — stabilising, avoiding an obstacle — is decided on board, because nobody could answer in time and a mistake costs little. Long and reversible — adjusting a route, pointing a camera — can also be decided on board, as long as it is reported afterwards. Long and irreversible is where the vehicle holds and asks.

Autonomy is easier to design as a sorting of decisions than as a level. Two properties place every decision a vehicle might make: whether its deadline is shorter than a round trip to a person, and whether a wrong call can be undone. Short and reversible decisions, such as stabilising or avoiding an obstacle, are made on board because nobody could answer in time and a mistake costs little. Long and reversible ones, such as adjusting a route, can also be made on board provided they are reported afterwards. Long and irreversible ones are held until a person answers, which only works if the vehicle can wait safely. The fourth cell is the one designs miss: no time to ask and no way to undo — a motor failing low over a road, a position estimate collapsing near the ground, a flight termination condition firing. The answer there is neither autonomy nor a human in the loop, but a person deciding in advance, on the ground, which way the vehicle errs, and writing that decision into configuration where it can be reviewed.

The fourth quadrant is the one designs miss: no time to ask and no way to undo. A motor fails low over a road; the position estimate collapses a few metres above the ground; the flight termination condition fires. Nobody can be consulted, and whatever happens next is final. The answer there is neither autonomy nor a human in the loop. It is a person deciding in advance, on the ground, which way the vehicle errs, and writing that decision into the configuration where it can be reviewed. The Zurich parachute is exactly this quadrant: the decision to terminate had been made long before, and it was the right one. What failed was the mechanism that carried it out.

Decide on board

  • Anything with a deadline shorter than the round trip to a person — obstacle avoidance, stabilisation, landing abort.
  • Anything that keeps the vehicle safe: boundaries, altitude limits, energy reserve, return decisions.
  • Anything reversible and cheap to get wrong — a route adjustment, where to point a camera.
  • Navigation that must continue while the link is down, which in practice is most of the flight.

Hold and ask

  • Anything consequential and irreversible, where being wrong cannot be undone by trying again.
  • Anything resting on a classification the vehicle cannot verify — identity, intent, whether a person is present.
  • Anything outside the envelope the operator authorised, including a mission extension that looks harmless.
  • Anything the vehicle has no way to report afterwards, because an unrecorded autonomous action cannot be reviewed.

The right-hand column has a consequence people miss: holding a decision requires the vehicle to be able to wait safely. A system that must ask a person but cannot loiter, cannot store the request and cannot behave sensibly if no answer comes has not implemented the requirement — it has written it down. Waiting is a capability with its own energy budget, its own timeout and its own failsafe. The operator’s side of a held decision — what they are shown, how long they have, how a refusal is recorded — belongs to the page. The vehicle’s side is this one.

Simulation is the test environment, not a convenience

Every failure case that matters here is one you cannot reasonably produce on a real aircraft: losing the position fix at two hundred metres, a motor stopping in a turn, the link going at the far end of the route, a battery reporting a wrong value. Flying those tests is expensive, dangerous and slow, and the ones you survive you cannot repeat identically. There is no production traffic to learn from either. The feedback a web team gets from live telemetry arrives here as a log file after landing — if the aircraft lands. So the primary test environment is a simulator, and the maturity of a team’s simulation setup is a good proxy for the maturity of the team.

A mature flight-software team flies most of its hours in simulation. Software in the loop runs the real autopilot firmware on a workstation against a simulated airframe, sensors and world, fast enough to fly hundreds of missions on every merge; it finds logic errors, failsafe behaviour and mission sequencing faults. Hardware in the loop runs the real flight board and firmware against simulated physics, nightly and in dozens, and finds what depends on the real processor: timing, CPU load and driver bugs. Flight tests are kept to a handful per release, for what no model reproduces — vibration, radio propagation and weather. None of the three replaces another, because each finds a class of fault the tier before it cannot. The arrow back to the top is the part that makes the ladder improve: every flight log is a test input, so a fault seen once in the air is replayed in simulation and runs on every merge from then on.
TierWhat is realWhat is simulatedWhat only it finds
Software in the loopThe autopilot firmware, compiled to run on a workstationThe airframe, sensors, world and link — in Gazebo or ArduPilot’s own physics modelLogic errors, failsafe behaviour, mission sequencing — fast enough to fly hundreds of missions per merge
Hardware in the loopThe flight board and its firmwarePhysics and the sensor inputs fed to the boardTiming, CPU load, driver bugs — anything that depends on the real processor
Flight testEverythingNothingVibration, radio propagation, weather — what no model reproduces

Two practices turn that ladder into a regression suite rather than three places where people sometimes test. Faults are scripted cases, not experiments — line 6.3 — so cutting the link at the far waypoint is a test that runs on every merge and fails on a specific line. And every flight log is a test input — line 6.4. A fault seen once in the air is replayed in simulation and stays in the suite forever, which is the same rule as any regression suite and the one that makes the suite better every time something goes wrong. The Ingenuity timestamp fault below is the kind a scripted case catches cheaply: offset one input’s timestamps and assert that the estimator notices.

The release cadence follows from all of this, and it is the part of web practice that transfers worst. Deploying several times a day and fixing forward assumes the next fix can reach the running system in minutes. An aircraft in the field may be out of reach for weeks, so the version it carries has to be safe on its own for weeks. Releases here are fewer, staged across a fleet, confirmed per aircraft — line 5.4 — and reversible on the vehicle itself.

Seven accidents, and the line that covers each

Every one of these has a public investigation or a documented account. In most of them the aircraft did exactly what its software and its configuration told it to, and the investigation put the cause in a design decision rather than in bad luck. None of them is about the mission logic — the part every team demonstrates.

CaseWhat happenedThe line that covers it
Predator B, Nogales, Arizona, April 2006A ground-station console locked up and the pilot moved control to the second, identical console without matching its levers. On that console the condition lever sat in the position that closes the fuel valve, and the engine stopped. On battery the aircraft shed its satellite link and its transponder, so air traffic control lost it, and its lost-link route was a loop that could only end in a crash along it. Nine console lockups in the three months before had gone unresolved.5.5 and 3.3. The NTSB’s recommendations point at both: a handover the system refuses while the levers disagree, distinct alarms for safety-critical faults, and a lost-link route that ends somewhere safe.
Light show, Hong Kong, October 2018During a harbour show, 46 of 100 drones lost satellite positioning to interference and fell into Victoria Harbour, with damage put at HK$1 million or more. They had a return-to-launch function, and the organiser said the interference stopped it working — it needed the position they had just lost.4.2. A return that depends on the signal that failed is not a behaviour for losing that signal.
Matternet M2, Zurich, May 2019A medical delivery drone detected a fault about two minutes after take-off and fired its flight termination system, as designed. The parachute opened, but its single line caught on a sharp part of the drone and broke, and the drone fell into a wooded area. Investigators also found that the warning sound was not heard by people nearby.2.4. The decision to terminate was right; the mechanism that carried it out failed at its weakest part. Swiss Post moved to two reinforced lines and a louder signal.
Ingenuity, flight 6, Mars, May 2021One image from the navigation camera was lost, and every image after it arrived with the wrong timestamp. The estimator kept correcting for errors that did not exist, and the helicopter swung by more than 20 degrees in roll and pitch. It landed within about 5 m of its target because the design tolerated timing errors and stopped using camera images for the final descent.4.4 — and a success for 2.1: the fallback for the final descent had been designed before anything went wrong.
Ingenuity, flight 72, Mars, January 2024Over featureless sand ripples, about 20 seconds after take-off, the navigation system could not find enough surface features to track. Its velocity estimate went wrong, the helicopter touched down hard with high horizontal speed, and all four rotor blades snapped. It was the last flight.4.1. An estimate with too little to work with has to be able to say so, and saying so has to change what the vehicle does.
Amazon MK30, Oregon, December 2024Two delivery drones in testing shut their propellers down in flight about four minutes apart, in light rain. According to Bloomberg’s review of the NTSB material, a software update had made the lidar more susceptible to rain, and the software acted on the altitude it misread. Amazon paused deliveries in January 2025.4.3 and 6.3. One sensor was allowed to end the flight on its own word, and a changed sensor behaviour is exactly what a scripted fault case should exercise before an update flies.
Drone show, Orlando, December 2024Configuration errors — the show’s centre position, its heading, inconsistent updates across aircraft and non-standard geofence settings — put the show closer to the audience than the operator’s own standard allowed. Drones collided and fell on spectators, and a seven-year-old boy was seriously injured. The NTSB’s final report found that the absence of a robust cross-check let every one of those errors go undetected.5.2 and 5.4. A fleet of five hundred is five hundred configurations, and nothing compared them with what had been reviewed.

Where it degrades

The honest limit of everything on this page is that a failsafe answers only the failures somebody imagined. Every one of the seven cases was, in hindsight, a condition nobody had written a row for: a lever with two meanings, rain on a lidar, sand with nothing to see. Simulation reproduces the faults you script, and the dangerous one is the fault nobody thought to script. That is not an argument against the ladder. It is the argument for keeping every flight log, replaying it, and treating each surprise as a new row rather than as bad luck.

  • A failsafe table that exists as a document and has never been executed, in simulation or anywhere else.
  • A boundary enforced in the ground station, the component guaranteed to be absent when it matters.
  • "Return at 30%" copied from a forum into every airframe, whatever its range and whatever the wind.
  • Parameters edited on the field laptop and never brought back into version control.
  • A simulation suite that flies the happy mission hundreds of times and injects nothing.
  • A flight log kept only for incident review, never replayed as a test.
  • A "human in the loop" requirement for a decision the vehicle cannot wait for.
  • A demonstration flown in good weather, on a full battery, with a strong link and the author standing next to it, presented as evidence of anything.
  • A release process copied from web engineering — deploy often, fix forward — for a unit that may be out of reach for weeks.

When to use it

Use it when

  • As a flight-readiness review: the twenty-five lines at the top, cited by number.
  • When deciding what belongs on the flight controller, the autopilot and the companion computer — the deadline decides, not the language.
  • When writing or reviewing a failsafe configuration or a return trigger, which is the part of the specification that decides flyability.
  • When building the test environment: simulation first, hardware in the loop second, air last and rarely.

Avoid it when

  • As a source of perception or model detail — that belongs to computer vision, which this page deliberately stops short of.
  • As guidance on the shared operational picture or the operator’s interface, which is the C2 page — this one ends at the airframe and its link.
  • As a substitute for the autopilot’s own documentation, which is where parameter names and exact behaviour per version live.
  • For a system where a person is genuinely always present and responsive — the constraints here would be overhead.

Sources and method

What this page stands on

  • 9 sources
  • 5 documented failures
  • Checked October 13, 2026

Researched with Claude. Finding and cross-checking the primary sources was done with Claude (Anthropic). Selection, writing and fact-checking: the Anatomy of IT Product editors.

Found this useful?

Share it with someone who is working on the same problem.