Flight controllers and flight modes — study guide

The concept's fragments, read in order.

For your capstone Fly a site and deliver a survey-grade map

The roughly 250 photos of the grading site have to land on evenly spaced lines at a steady height and speed, and only the automatic mission mode flies that evenly, standing on a calibrated compass, low vibration and a good satellite fix. Planning the mapping flight assumes the aircraft can be trusted to fly it.

In mission mode the aircraft flies eleven parallel lines over the 400 m square at 8 meters a second, a photo roughly every three seconds, and the pilot turns supervisor, watching battery, position quality and link strength. When a crane that was not there at the site walk turns up beside a line, stepping in is a mode change: position hold stops the aircraft where it is and hands the sticks back, and switching back to the mission usually resumes it where it left off.

The pilot asks, the autopilot flies

A multirotor is unstable by nature. Tip it a few degrees and nothing in its shape pulls it back; it keeps tipping until something corrects it. No person could keep one level by setting four motor speeds by hand, so a small computer on board does it instead. The flight controller, usually called the autopilot, is a microcontroller wired to a cluster of sensors and to the motor controllers. Hundreds of times a second it reads the sensors, works out how the aircraft is sitting and moving, and nudges each motor's speed to fix whatever is wrong, much as a person balancing a broom upright on one palm keeps it standing only by making small, constant corrections faster than they could ever plan them one by one.

The pilot never commands a motor. The sticks and the screen ask for something, a lean, a speed over the ground, a place to be, and the autopilot turns that request into motor speeds. What a given stick movement means depends on the flight mode. In one mode pushing a stick forward tilts the aircraft; in another it asks for a speed over the ground and the autopilot works out the tilt; in a third the stick is ignored while the autopilot flies a stored mission. Picking a mode is picking how much of the flying you hand over.

This concept covers the loop the autopilot runs, what each of its sensors tells it, the flight modes and what each one leaves to the pilot, and two setup jobs that are the pilot's to get right in the field: calibrating the compass and setting a geofence. The rules quoted here are those of the United States, where small drones flown for work fall under the FAA's Part 107; other countries have their own rules and regulators. Under those rules, handing the flying to the autopilot never hands over the responsibility for it.

Sense, estimate, correct, hundreds of times a second

target position, from the mission or the sticks position loop slowest of the four estimated position new fix 5 times a second asks for a velocity velocity loop speed over the ground estimated velocity asks for a lean and a thrust attitude loop how far it leans, which way estimated lean asks for a rotation rate rate loop fastest: hundreds of times a second gyroscope rates corrections mixer one speed for each motor
The autopilot's control loops are nested: the slowest, outermost position loop asks for a velocity, working on an estimate that gets a fresh satellite fix only about 5 times a second; the velocity loop asks for a lean and thrust, the attitude loop asks for a rotation rate, and the fastest, innermost rate loop sets the motor speeds, each loop comparing its target with an estimate from the sensors.

The autopilot's loop is really several loops nested inside one another, each handing a target to the one inside it. The outermost compares where the aircraft is with where it should be and asks for a velocity toward the target. The next compares that velocity request with the measured velocity and asks for an acceleration, which the autopilot turns into a lean angle and a total thrust, because a multirotor moves sideways by tilting. The attitude loop compares the lean it has with the lean it wants and asks for a rotation rate. The innermost loop compares the rotation rate the gyroscopes measure with the rate requested, and a mixer turns its correction into a speed for each motor.

The inner loops run fastest, because a tilt left alone grows quickly and has to be caught early. One widely used open-source autopilot runs its main loop at up to 400 times a second, while its position receiver delivers a fresh fix only 5 times a second by default. So the outer loop works on a slow drip of absolute information, and the estimator fills in between fixes from the faster sensors. Each loop only has to be good at one job, and each inner loop makes the one outside it easier.

The flight mode decides where the pilot's request enters this stack. In an attitude mode the sticks set the lean directly and the position and velocity loops sit idle. In position hold the sticks set a movement over the ground, and centering them hands the outermost loop a spot to hold. In an automatic mission the movement and throttle sticks are set aside and the stored mission feeds the outermost loop. The motors are always driven by the innermost loop, whatever the mode.

Each loop has gains that set how hard it corrects. Set too high, a loop overshoots and the aircraft buzzes or bobs; set too low, it wallows and is slow to recover from a gust. A pilot does not need the arithmetic, but should know the symptoms: an aircraft that used to fly smoothly and now oscillates or recovers lazily is telling you something about it has changed, and that is a reason to land and look rather than to fly the mission anyway.

Gyroscopes and accelerometers, which way is up

The sensors that keep the aircraft upright sit together in an inertial measurement unit (IMU): three gyroscopes and three accelerometers, one of each per axis, packed into a chip on the flight controller. They are the autopilot's sense of balance, and the fastest-running loops depend on them.

A gyroscope measures rate of rotation: how fast the aircraft is rolling, pitching and yawing at this instant. It answers quickly and smoothly, which is why the innermost loop runs on it. Its weakness shows when the autopilot uses it for angle. To know how far the aircraft has tilted, the autopilot adds up the rates over time, and any small steady error in the reading, called bias, gets added up too. The angle worked out from gyroscopes alone creeps away from the truth, slowly but without limit, and heading creeps the same way. The autopilot estimates that bias and subtracts it, but to do so it needs something that does not drift.

An accelerometer supplies that for tilt. It feels gravity as well as acceleration, so when the aircraft is not speeding up or slowing down the accelerometers' reading lines up with the vertical and shows which way is down, an absolute sense of level that never drifts. It has two weaknesses. During a maneuver it cannot tell gravity from the aircraft's own acceleration, and vibration from propellers and motors shakes its reading. Vibration matters beyond tilt, because the accelerometers also feed the height and position estimate, so a vibrating aircraft holds height and position badly even with a perfect satellite fix.

Accelerometers also carry small built-in offsets, which a calibration routine in the aircraft's setup software measures and removes as part of setting the aircraft up. The level the aircraft holds in a hover is only as good as that calibration and the mounting under the board.

Compass, barometer and GNSS, where and which way

sensor: what it gives and how it goes wrong gyroscopes: rotation rate, fast wrong: small bias adds up into drift rate accelerometers: which way is down wrong: vibration, hard maneuvering level compass: which way it faces wrong: wiring currents, nearby steel heading barometer: height above takeoff wrong: weather, propeller airflow height GNSS: position, 5 times a second wrong: off by meters, worse near trees position estimator one best guess of lean, heading, velocity, position and height
Five sensors feed the estimator, each supplying one quantity and each with its own known weakness: gyroscopes drift, accelerometers are shaken by vibration, the compass is pulled by nearby currents and steel, the barometer moves with the weather, and the satellite fix is off by meters.

Three more sensors tell the autopilot where it is, how high, and which way it faces. The first is the satellite receiver. A GNSS receiver (Global Navigation Satellite System, the family that includes GPS) times signals from many satellites, turns those times into distances, and works out a position and a velocity from them. Without corrections it is good to a few meters: GPS.gov gives a typical figure of 4.9 m (16 ft) under open sky for a phone-class receiver, and worse near buildings, bridges and trees. One open-source autopilot asks for a fresh fix 5 times a second by default. Getting from meters to centimeters takes corrections, which is a separate subject; an autopilot holds a hover on an uncorrected fix, give or take that few-meter envelope.

The compass, properly a magnetometer, measures the Earth's magnetic field and so gives the aircraft its heading. Something has to: the gyroscopes' idea of heading drifts, and while the aircraft hovers the satellite fix says where it is but not which way it is pointing. The compass's weakness is that it reads every magnetic field nearby, not only the Earth's. The aircraft's own power wiring carries currents whose field grows with the current, and steel at the takeoff spot, rebar in a slab or a parked truck, adds fields of its own.

The barometer measures air pressure. Near the ground, pressure falls by about one inch of mercury for every 1,000 feet (305 m) of climb, the FAA's rule of thumb, so a tiny pressure change reads as a height change. The barometer is zeroed at takeoff and reports height above the takeoff point, not above the ground underneath. Weather moves it: a fall of a tenth of an inch of mercury reads as a climb of about 100 feet even if the aircraft has not moved, and the airflow from the propellers and the wind disturbs it too. The autopilot uses satellite height, slower and noisier but free of drift, to keep the barometer honest.

Every quantity the autopilot holds rests on at least one of these sensors, and every sensor has a known way of being wrong. That is the reason the estimator exists, and it is what most of a pilot's setup work is for: calibrating, keeping vibration down and choosing a clean takeoff spot all keep one sensor's weakness from reaching the others.

One best guess from five imperfect witnesses

time heading error drifts away true heading gyroscopes alone compass readings blended estimate smooth but drifting, plus noisy but anchored, gives smooth and anchored
Over time a heading worked out from gyroscopes alone drifts steadily away from the truth, compass readings scatter around the truth without drifting, and the estimator's blend of the two stays smooth and close to the true heading.

No single sensor is good enough to fly on, so the autopilot runs an estimator: software that combines all of them into one best guess of the aircraft's attitude, velocity, position and heading, refreshed many times a second. The control loops never see a raw sensor reading. They see the estimate.

The estimator's trick is to let each sensor do what it is good at. The gyroscopes and accelerometers are fast and smooth but drift when their readings are added up over time, so they carry the estimate forward from moment to moment. The accelerometers' sense of gravity, the compass, the satellite fix and the barometer are slow or noisy but do not drift, so they pull the estimate back toward the truth whenever they report, like a navigator who keeps a running tally of speed and heading between landmarks, a tally that slowly wanders off, and snaps it back to the truth each time a known landmark comes into view. Along the way the estimator works out the gyroscopes' bias and the barometer's drift and subtracts them.

It also cross-examines its witnesses. Each new satellite fix is compared with where the inertial sensors predicted the aircraft would be, and a fix that disagrees by too much is set aside as a glitch instead of yanking the aircraft sideways. An aircraft with two sets of sensors can run two estimates side by side and fly on whichever is more self-consistent, so one failing sensor need not bring it down.

The pilot meets the estimator through its complaints. When an aircraft refuses to arm, refuses to enter position hold, or warns about inconsistent compasses or poor position accuracy, that is the estimator saying its witnesses disagree or one of them is not yet trustworthy. Those messages are information about the aircraft's own picture of the world, and taking off over one means flying on a picture the aircraft itself does not believe.

What each mode hands the pilot

mode who sets the lean who holds the height who holds the position attitude pilot pilot pilot altitude hold pilot autopilot pilot position hold autopilot autopilot autopilot mission autopilot autopilot autopilot return to home autopilot autopilot autopilot fix lost Position hold, mission and return to home need a satellite fix. Lose it in position hold and, on a common setup, the aircraft drops to altitude hold: the wind is the pilot's problem again.
Each flight mode hands one more job to the autopilot: in attitude mode the pilot sets the lean, height and position; altitude hold takes over height; position hold takes over position; mission and return to home fly everything; and losing the satellite fix drops position hold back to altitude hold, handing position back to the pilot.

Every autopilot names its modes differently, but most offer the same handful, each taking one more job off the pilot. Each mode is a bargain like the one cruise control strikes in a car, where the pedal stops setting the speed and the car holds the speed for you: it decides what your inputs mean and what the machine holds on its own.

In an attitude mode, called stabilize or manual on some aircraft, the sticks set how far the aircraft leans, and letting go brings it back to level. That is all the help it gives. The throttle sets motor power directly, so the pilot holds the height, and nothing holds the position: the wind pushes the aircraft and the pilot has to lean against it continuously. Altitude hold adds one job. The autopilot holds height from the barometer, a centered throttle stick means stay at this height, and the aircraft still drifts with the wind.

Position hold adds the satellite fix and the compass. The sticks now ask for movement over the ground, and letting go makes the aircraft brake, level and stay over one spot against the wind. In an automatic mission the autopilot flies a stored route and the movement and throttle sticks are set aside. Return to home climbs to a set height, flies back to where the aircraft was armed and lands; the height it climbs to and the events that trigger it on its own are part of handling emergencies. These last three need a position, and an autopilot will refuse to enter them without a usable fix.

The modes that need a position are the ones that vanish when the position does. If the satellite fix is lost or turns bad in flight, the autopilot falls back to whatever its setup says: on one open-source autopilot, from position mode to an altitude-hold mode; on another, to landing or to altitude hold, as configured. After a fallback to altitude hold the aircraft keeps its height but goes wherever the wind takes it, and on the example survey day the wind at 300 feet is estimated at about 12 knots with gusts near 23, roughly 6 to 12 meters a second. Knowing which mode the aircraft is really in, and being able to fly it home in an attitude-style mode, is what separates a nuisance from a lost aircraft.

Automatic missions, where the pilot becomes the supervisor

A mission is a list stored on the aircraft: waypoints, each a position and a height, plus actions such as triggering the camera. In the mission mode the autopilot flies straight from one waypoint to the next, holds its speed and height, and fires the camera where the list says. On the example survey job that means eleven parallel lines over a 400 m square at 8 meters a second (about 18 mph), a photo roughly every three seconds, about eleven minutes on the lines. Building that list is mission planning; this mode is what flies it.

With the sticks set aside, the pilot's job changes from flying to supervising: watching the aircraft and the sky around it, watching the telemetry for battery, position quality and link strength, and staying ready to step in. The rules do not relax because the autopilot is flying. Under Part 107 in the United States the remote pilot in command is directly responsible for, and the final authority on, the operation, and must be able to direct the aircraft. The FAA's advisory circular on Part 107 (AC 107-2A) spells out what that means for automated flight: the remote pilot must be able to change the route or height or command the aircraft to land immediately, by the sticks or by a command, and automation does not allow one person to fly more than one aircraft at a time. The aircraft also stays within visual line of sight of the pilot or a visual observer, a limit with its own rules.

In practice, stepping in is a mode change. Switching to position hold stops the aircraft where it is and hands the sticks back; switching to return to home sends it back to its takeoff point; switching back to the mission usually resumes it where it left off. Before the aircraft leaves the ground, the pilot should know which switch or button does each of those things on this aircraft, and what the aircraft will do on its own if the control link drops, a setting that belongs with the link itself.

The autopilot flies the lines more evenly than any person could, which is the whole reason a survey uses it. It will fly them just as evenly toward a crane that was not there at the site walk.

Calibrating the compass

before calibration after calibration readings as the aircraft turns same turn, corrected zero + offset from the aircraft's own magnetized parts subtract the offset, undo the squash zero A clean compass traces a circle around zero as the aircraft turns. Magnetized parts shift it (hard iron); iron on the aircraft squashes it (soft iron).
As the aircraft is turned, a clean compass's readings trace a circle centered on zero, but the aircraft's own magnetized parts shift that circle off center and its iron squashes it; calibration measures the shift and the squash and removes them so the readings center on zero again.

A compass on an aircraft reads the Earth's field plus the aircraft's own. Permanently magnetized parts add a fixed offset that turns with the aircraft, called hard-iron distortion. Ordinary iron, magnetized by the Earth's field, bends the readings by different amounts depending on which way the aircraft points, called soft-iron distortion. Current in the power wiring adds a third field that rises and falls with the throttle. Crewed aviation has long known the same effect as compass deviation: unlike the difference between magnetic and true north, it depends on the aircraft's heading and comes from the aircraft itself.

Calibration measures and removes the aircraft's share. The software asks you to turn the aircraft through every orientation, each side pointing at the ground in turn. A perfect sensor's readings, plotted in three dimensions, would trace a sphere centered on zero. Real readings trace a shape that is shifted off center and slightly squashed, and from that shape the autopilot works out the offset and the distortion and subtracts them from every reading after. Do it away from metal: a truck, a steel deck or the phone in your pocket gets calibrated into the result and then carried to wherever you fly.

Calibration does not deal with the difference between magnetic north and true north, called declination or variation. That difference changes from place to place and slowly from year to year. The FAA's handbook uses about 10 degrees west around Washington, D.C., and 14 degrees east around Los Angeles as examples; in late 2026 the current model puts Los Angeles nearer 11 degrees east and Washington nearer 11 degrees west, because the field keeps moving. Autopilots handle it from a built-in model of the Earth's field such as NOAA's World Magnetic Model, reissued every five years; the current WMM2025 is valid until late 2029. The model covers only the planet's main field, so a local disturbance at your site, buried steel or a nearby structure, is still yours to avoid.

A bad heading has a signature. In position hold the aircraft circles around the spot it is meant to hold, sometimes called toilet-bowling, because it keeps correcting in the wrong direction; if the error is large it may set off confidently the wrong way the moment the mode engages. Aircraft differ on when they want a calibration, and one open-source autopilot's documentation says a new location alone does not need one because its magnetic model handles declination. Calibrate when the aircraft asks, after anything metal or electrical near the compass is added or moved, and whenever the heading on the screen disagrees with what you can see.

Geofences, limits the aircraft enforces on itself

A geofence is a boundary the aircraft polices on its own: a height ceiling, a maximum distance from the takeoff point, or a polygon drawn on the map that it must stay inside or keep out of. It applies in every mode, manual flying and missions alike. When the aircraft crosses it, the autopilot does whatever the fence is set to do: warn, stop and hold, return home, or land. It acts only once the line is crossed, so a fence that must not be broken needs a margin inside it, and because the fence knows where the aircraft is only from the autopilot's own estimate, it is only as good as that estimate: the satellite fix for the horizontal limits, and the barometer-led height for the ceiling.

The ceiling has a reference height, and on common open-source autopilots the default is the takeoff point, not the ground underneath. The example survey site rises about 14 m (46 ft) from its low southwest corner to its high northeast corner, the aircraft takes off from open ground near the high corner, and the mission flies at 300 feet above the ground, following the terrain. Its height above home therefore runs from about 300 feet near the takeoff point down to about 254 feet over the low corner. A ceiling of 300 feet above home never trips on that plan, but it does not guard the authorization everywhere: over the low corner it would let the aircraft reach 346 feet above the ground before acting. Had the aircraft taken off from the low corner instead, the same ceiling would trip on a perfectly planned flight, because over the high corner the aircraft would be about 346 feet above home while still 300 feet above the ground. No single ceiling above home does both jobs on sloping ground. Some autopilots offer a ceiling measured above the terrain, using a stored terrain database; otherwise the fence has to be set knowing where you took off.

A fence is not a permission. On the example survey job the pilot holds a LAANC authorization to fly up to 300 feet above the ground in the controlled airspace over the site; that authorization comes from the FAA, and what it allows is set by the airspace, not by the aircraft. The fence is a guard rail that keeps a slip of the thumb or a planning error from turning into a breach of that authorization. It knows only the numbers someone typed into it.

Why a mapper needs to know what the autopilot is doing

A map built from photos is only as good as the pattern the photos were taken in. On the example survey job about 250 photos have to land on evenly spaced lines, at a steady height and speed, with the camera firing on schedule. Only the automatic mission mode flies that evenly, and it can only do it if the sensors under it are healthy: a calibrated compass so the aircraft tracks its lines instead of circling off them, low vibration so the height holds, and a good satellite fix so the aircraft goes where the list says.

The autopilot does the flying; the pilot does the knowing. On the day, the person at the controls is the one who can say which mode the aircraft is in, what each switch on the controller will do, what the aircraft does on its own if the satellite fix or the compass fails, and how to bring it home in an attitude-style mode if it comes to that. In the United States the rules put the responsibility on that person whatever the autopilot happens to be doing, and an aircraft that has quietly fallen back to a mode its pilot did not expect is one of the ways a routine survey ends with a damaged aircraft.

The concepts that come next lean on this one. The radio link between controller and aircraft, and what the aircraft does when that link drops, assume you know what a mode and a return to home are. Planning the mission itself, its lines, height and photo spacing, assumes the aircraft can be trusted to fly it.

Sources

The published studies, standards and guidance this page cites. Links open on other sites.

  1. 14 CFR Part 107, Small Unmanned Aircraft Systems (Electronic Code of Federal Regulations) www.ecfr.gov
  2. Complete Parameter List (ArduPilot Copter documentation) ardupilot.org
  3. Measuring Vibration (ArduPilot Copter documentation) ardupilot.org
  4. GPS Accuracy (GPS.gov) www.gps.gov
  5. Pilot's Handbook of Aeronautical Knowledge, Chapter 8: Flight Instruments (FAA) www.faa.gov
  6. Using PX4's Navigation Filter (EKF2) (PX4 Guide) docs.px4.io
  7. Extended Kalman Filter (EKF) (ArduPilot Copter documentation) ardupilot.org
  8. Position Mode (Multicopter) (PX4 Guide) docs.px4.io
  9. Advisory Circular 107-2A, Small Unmanned Aircraft System (Small UAS) (FAA, 2021) www.faa.gov
  10. World Magnetic Model (NOAA National Centers for Environmental Information) www.ncei.noaa.gov
  11. Compass Calibration (ArduPilot Copter documentation) ardupilot.org
  12. Geofence (PX4 Guide) docs.px4.io

Next on your path to Fly a site and deliver a survey-grade map: