Interactive course · about 1 hour 30 minutes

Drones

A quadcopter is four propellers bolted to a frame. None of them can tilt and none can point anywhere but down. Between them they have to hold the aircraft level, hold it at a height, and turn it to face wherever you want. Every bit of that is arithmetic running on a small chip, five hundred times a second, from two sensors that both lie. One of them cannot tell you an angle at all. The other cannot tell a tilt from a shove. This course builds the whole loop out of nothing. Then it breaks it in the four ways real aircraft break: too slow a loop, too slow a motor, one sign in the wrong place, and one motor that stops.

How this works

Every line, pill and bar on these pages is worked out from one simulation that reruns whenever you move a control. It is a rigid body: four thrusts, three torques, and angles that come from adding up those torques over time. The physics is stepped two thousand times a second, and the control loop only thinks as often as you let it. Slowing the loop down means deciding less often rather than simulating worse. The motors take time to answer, the gyroscope drifts, the frame shakes and the accelerometer feels every bit of it. None of that is a blemish on the model. All four are the reason the subject exists. Hold the pointer over any chart and it reads out every line at that moment. The small play button in a chart's corner runs a cursor across it, and some marked points can be dragged, with the sliders following.

What you need to know first

Step 1 builds the balancing picture from nothing, so anyone can start there. From Step 7 on, this course leans on Control Systems, and specifically the three terms of a PID controller. A push that grows with the error, a running total, and a rate of change. It does not re-teach them. It is about three things that change. The thing being controlled has no friction to help you. The loop runs five hundred times a second instead of ten. And getting it wrong is a crash rather than a slow drift. Robotics is useful but not required: it is where adding up a sensor reading and watching the answer walk away is met for the first time.

The steps

Step 1

See why a drone is a see-saw that never stops balancing

Strip everything away and a drone is four fans pointing down, bolted to a light frame. Each fan blows air at the ground, and the air pushes back up on the fan. That upward push is thrust. Enough of it and the machine rises. Too little and it sinks.

Now put two fans on the ends of a see-saw. On a playground see-saw, pushing down harder with your right hand brings that end down. The fans do it the other way round: run one fan harder and its extra push lifts its own end, so the plank leans away from it. That lean is a tilt, and a drone chooses every tilt on purpose, by making one side push harder.

A tilt is never free. Carry a tray of drinks and let it lean, and the drinks slide towards the low edge. A tilted drone does the same thing to itself. Its push no longer points straight up, so part of it shoves the machine sideways. That sideways slide is drift. Leaning into a strong wind uses the same fact deliberately: your lean pushes you into the wind exactly as hard as the wind pushes you back.

Why does nothing pull the plank back to level?

Compare it with a swing. Push a swing and gravity pulls it back through the middle, so it wobbles about the bottom and settles there. The bottom is special: every push away from it costs height, and gravity collects the debt.

A balanced plank has no special position. Level, five degrees over, thirty degrees over: gravity has no preference between them, so nothing collects the debt. Whatever lean a gust starts, the plank simply keeps it, and the next gust adds to it. Machines like this are called unstable, and they are why this course exists.

Where is the see-saw on a real drone?

There are two of them, crossing in the middle like a plus sign. One plank runs left to right and its two ends decide whether the drone leans left or right. The other runs front to back and decides whether the nose points up or down. A fan sits at each of the four ends, so each fan serves both planks at once.

Balancing both planks at the same time sounds harder than balancing one, and it is. Step 2 counts exactly what four fans can and cannot do, and a third turning effect appears there that no see-saw picture predicts.

Lab 1 · Two fans on a plank
Try this firstLeave both fans at the same setting and press "Let go for a second". The plank stays level. Now give the left fan two or three notches more, press the same button, and watch both the lean and the arrow along the ground.
Notice that the plank never settles at a small lean. It tips slowly at first, then faster and faster, because the push that started the lean is still there, still pushing. And read the drift arrow: the moment the plank leans, it starts sliding sideways as well. One small imbalance buys you two growing problems.

Here is the difficult part, and the lab just showed it. The plank has no reason to stay level. It has no spring pulling it back, so a wobble does not fade away. It grows. The only thing that keeps a tray, a see-saw or a drone level is a watcher. Eyes see the lean, and hands push back a little, over and over, without ever stopping. Watching the lean and answering it is feedback, and producing it is the whole job of the small chip inside every drone.

So something has to watch and correct, all the time. The lab below hands that job to the simplest watcher there is. The rule: push harder when the machine sits below its target, and ease off when it sits above. That is feedback in one sentence, and it is enough to see what having it, and losing it, actually costs.

Lab 2 · Chase the line
Try this firstPress the small play button in the chart's corner and watch the drone climb to the dashed line. Then drag the "drag the target" point somewhere else, or move the slider, and watch the whole flight redraw. Last, press Corrections off and read what the gust costs.
Notice what "off" actually looks like. With corrections off the thrust is a perfect guess, exactly enough to hover, and the flight looks fine right up to the gust. Then the height drops and never comes back, because nothing on board noticed. Feedback is not there to fly the easy seconds. It is there to notice.
Could a person fly one of these by hand?

Not by pushing the four throttles directly. A human reaction takes about a fifth of a second, and Lab 1 shows what the plank does with a fraction of a second to itself. By the time your hand answered, you would be correcting a lean that has already doubled, and each correction would arrive later than the last.

That is why every drone, including the cheapest toy, carries a chip doing the balancing. The sticks on the pilot's radio do not command the fans. They ask the chip for a lean, and the chip does the thousand small corrections a second that hands cannot.

You balance a broom upright on the palm of your hand. Your hand never stops making small movements, even when the broom looks perfectly still. Why can you not simply find the right spot and hold your hand there?
The corrections are the balancing. Upright is like the level plank in Lab 1: nothing pulls the broom back towards it, so every tiny lean grows, slowly at first and then quickly. Your eyes and hand are a feedback loop, watching the lean and moving the base under it, several times a second. A drone is the same act with fans for hands and a chip for eyes, running hundreds of times faster.
Step 2

Work out what each of four motors can do to the airframe

The fans of Step 1 now get their proper name. A propeller is a fan shaped to move a lot of air, and a quadcopter has four, all pointing straight down, none able to tilt. That is the entire machine, and every move it makes has to come out of choosing four numbers: how hard each motor is working. Which way the aircraft is pointing is its attitude. It takes three angles to describe. Roll is how far it leans left or right. Pitch is how far its nose is up or down. Yaw is which way the nose is facing.

A spinning propeller does two things, and only the first is obvious. It pushes air downwards and the air pushes back, which is the thrust from Step 1, measured in newtons. It also drags the air round in a circle and the air drags back, so a propeller turning clockwise pushes the frame anticlockwise. That twisting push is a torque: a force that turns something rather than moving it along. Both effects arrive at once and neither can be switched off.

So an aircraft needs four things settled at every moment: enough lift to stay up, and the three angles. Four things wanted, four motors to want them with. That number is not a coincidence and the labs below are where it comes from.

How much is a newton, in something I can picture?

A newton is roughly the weight of a small apple. To hold anything up, the lift has to match the weight, and weight in newtons is the mass in kilograms multiplied by 9.81. The quadcopter in these labs has a mass of half a kilogram, so it weighs 4.91 newtons. To hover, its four motors have to produce that much between them.

Each motor can manage 3.68 newtons flat out, so the four together can lift 14.7 newtons, about three times what the aircraft weighs. That ratio is why a quadcopter can climb steeply, and it is also why it can throw itself into the ground so quickly.

Why does a spinning propeller turn the whole aircraft?

Because a push only ever comes in pairs. To make the air spin one way, the motor has to be pushed the other way, and the motor is bolted to the frame. Sit on a swivel chair, spin a heavy wheel in your hands. You turn the other way. Nothing is leaking or slipping: that is what turning something means.

On a quadcopter this twist is the only way the machine can yaw at all, since no propeller points sideways. Two propellers turn clockwise and two anticlockwise, and when the two pairs work equally hard the twists cancel out. Speed one pair up and slow the other down and the aircraft turns, with the total lift unchanged.

Which way counts as positive roll?

Throughout this course, positive roll means the right-hand side going down, positive pitch means the nose going up, and positive yaw means the nose swinging to the right. Right and left are from the point of view of the aircraft looking forward, the way they are on a ship.

Which way round you choose does not matter, as long as everything agrees. Step 3 is about what happens when one part of the software disagrees with the airframe about it, which is a real and expensive mistake rather than a hypothetical one.

Lab 3 · Four throttles, four effects
Try this firstPress "All four the same" and read the four bars. Three of them say nothing is turning. Now press One diagonal up, and watch which single bar comes alive while the other three stay at nothing.
Notice that the yaw bar can be moved without touching the other three. No propeller is pointing sideways and nothing has tilted, yet the aircraft is turning, purely because one pair of propellers is dragging the air round harder than the other pair. That is the effect that has no obvious cause, and it is the one a quadcopter would be helpless without.

The four effects came out independent: moving one of them left the other three alone. That is worth checking rather than assuming, because it is exactly what makes four the right number of motors. Four independent effects need four independent things to set. If two of the four effects were tangled together, some combination of height and angles would simply be out of reach.

Lab 4 · How many of the four you can hold at once
Try this firstPress M1 in the "working" row to stop that motor. The big number drops from 4 to 3. Put it back, then press M2 ACW in the "propeller" row to fit that propeller the other way round. The same number drops with all four motors still running.
Notice that four working motors are not enough on their own. Fit all four propellers turning the same way and every one of them twists the frame in the same direction. The only way left to change yaw is changing the total lift. The count is worked out by elimination on the four rows, the same arithmetic you would use to solve four equations. It does not care how healthy the hardware is. It cares whether the four effects are independent.

This is also the answer to why aircraft with two propellers are rare. Two motors give two independent effects, and an aircraft needs four. The machines that manage with two propellers add the difference back mechanically, with mounts that tilt. A helicopter does the same thing at greater expense: a main rotor whose blades change angle as they go round, plus a tail rotor to hold the yaw. Four fixed propellers replace all of that with four multiplications, which is why quadcopters became common the moment small chips could do the arithmetic quickly enough.

A first-time builder fits all four propellers the same way round, so all four drag the air in the same direction. Everything spins up, all four motors work, and the aircraft lifts off. What will they find?
Yaw and height become the same knob. Lift is unaffected, because a propeller pushes air down whichever way it turns. Roll and pitch are unaffected, because they come from which corners push harder. But the twisting is no longer two against two, so the only way left to change yaw is to change the total. Lab 4 counts three holdable demands out of four, with four working motors, and the missing one is the combination of yaw and height.
Step 3

Turn one wanted move into four motor commands

The rest of the software never mentions motors. It works in the four things that matter: this much lift, this much roll, this much pitch, this much yaw. Something has to turn four wants into four throttles, and that something is the mixer. It is the smallest piece of code in a flight controller and the one that goes wrong most expensively.

The whole of it is one line per motor. Start with the lift wanted. Add or subtract the roll wanted, depending on which side of the aircraft that motor is on. Do the same for pitch, depending on front or back, and then for yaw, depending on which way its propeller turns. Four multiplications by plus one or minus one, and three additions. No physics, no angles, no memory of anything.

The signs are the whole content of it. Get one wrong and the arithmetic is still perfectly valid arithmetic, still runs at full speed, and describes a different aircraft from the one it is bolted to.

Why can the mixer just add the four demands together?

Because of what Lab 3 showed. The four effects are independent, so a roll command adds the same amount to the two motors on one side as it takes off the two on the other. The total is unchanged, and the lift the aircraft gets is whatever the lift demand asked for, whatever is happening in roll.

That is why the four columns of numbers are at right angles to one another in the same sense that north and east are. Travelling east does not change how far north you are. Rolling does not change how much you are lifting.

What does it mean for a motor command to be clipped?

A throttle is a fraction between nothing and everything. If the four demands add up to more than everything, the extra is thrown away. If they add up to less than nothing, the motor simply stops rather than running backwards. Control Systems calls this saturation, and it is the same wall in a different machine.

It matters more here than it did with a heater, because clipping one motor changes what the aircraft gets from all four. Ask for a big roll while already climbing hard. The two motors that should come down are already at zero, so the roll you get is smaller than the roll you asked for. The lab prints both numbers so you can watch them come apart.

Do real flight controllers do anything cleverer than this?

They do one thing more, and it is about clipping. A good mixer does not let a saturated motor quietly change the roll. It notices that the answer does not fit, and scales the demands down until it does, keeping the lift and giving up some of the angle. Step 10 uses exactly that trick to fly on three motors.

Beyond that the mixer stays this simple even on expensive aircraft. It has to run before every single motor write, and there is nothing to gain from making it complicated. The cleverness lives in what decides the four demands, which is Steps 7 to 9.

Lab 5 · Four wants in, four throttles out
Try this firstDrag "roll wanted" up from zero and watch which two of the four lines go up and which two come down. The sum stays the same. Then push thrust wanted up near the top and drag roll again, and read the word clipped when it appears.
Notice that the arithmetic never mentions the aircraft. The four lines are the same four lines whatever the machine is doing, and the caption underneath the frame reports what the airframe actually gets. Those two agree exactly, until a motor hits a limit. Then they do not, and nothing in the mixer notices.

Now the mistake. Four motors are plugged into four sockets on the flight controller, and nothing physically stops them going into the wrong ones. The software will add its roll demand to a motor on the other side of the aircraft from where its own signs put it. Everything spins up, everything sounds right and the arithmetic is flawless.

Lab 6 · One sign in the wrong place
Try this firstPress M1 + so it becomes M1 −, then read the five pills. The aircraft still recovers from the gust. Now press Swap M1 and M2, which is what plugging two motors into each other's sockets does, and read the same pills again.
Notice that one wrong sign is survivable and two are not. One wrong sign halves the roll authority and tangles roll into pitch and height, which shows up as an aircraft that flies badly and nobody can say why. Swapping two motors leaves zero roll authority or an inverted one, and the aircraft is on its back in under a second. The table flies all sixteen possible sign patterns: eleven of them cannot recover from the same gust.

Until Step 6 these labs let the controller see the true angle exactly, because there is no point breaking two things at once. Nothing on a real aircraft knows its angle. The next three steps are about earning that number, and they are the part of this subject that has nothing to do with control at all.

A newly built quadcopter flips onto its back the instant it leaves the ground, every time, in the same direction. The motors all spin, the propellers are all on, and the controller passes its own self-test. What is the first thing to check?
Check the wiring and the propellers. Repeatable, immediate and always the same way round is the signature of an inverted sign rather than of a bad tuning. A controller with the wrong sign sees the aircraft falling to the right, decides to correct, and pushes it further right. Lab 6 flies the same gust both ways, on gains that were never touched. With the signs right it recovers in a quarter of a second. Inverted, it is over in a fraction of that.
Step 4

A gyroscope measures a rate, and adding it up drifts

The loop in Step 3 needed to know the roll angle, and nothing so far has provided one. The instrument everyone reaches for first is a gyroscope. It does not measure an angle. It measures a rate: how fast the aircraft is turning, in degrees per second. Standing perfectly still at forty degrees of tilt, a gyroscope reads zero, exactly as it does standing still and level.

What it is very good at is being fast and honest about that rate. The chip is a MEMS device. That means the sensing part is a piece of silicon a fraction of a millimetre across, etched into a shape that bends when the case turns. It can report a new number thousands of times a second and it does not care how violently the aircraft is moving.

The obvious move is to add it up. If the aircraft turned at 30 degrees a second for two tenths of a second, that is 6 degrees, so add 6 to the angle. Keep doing that on every tick and you have an angle. This is the same trick as adding up wheel rotations to find where a robot has got to, and it fails in the same way.

What is a bias, and why does the chip have one?

A bias is a fixed amount added to every reading. A gyroscope sitting perfectly still should report zero and reports 3 degrees a second instead. Nothing is broken: the silicon was etched a fraction off, and the electronics that turn the bending into a number have their own small offset.

You can measure the bias while the aircraft is on the ground and subtract it. That is what a flight controller is doing during the few seconds it asks you to hold still after power-up. That helps a great deal and it does not solve the problem. The bias changes as the chip warms up, and a flight controller warms up as soon as it starts flying.

Is this the same drift as in the robot odometry course?

It is exactly the same shape of failure and worth lining up side by side. There, wheel counts were added up to find a position, and a wheel two per cent too big put the robot further and further from where its own numbers said. Here, rates are added up to find an angle and a bias of a few degrees a second does the same thing to the angle.

The difference is how much it costs. A robot whose estimated position is half a metre from its true one drives into a wall at walking pace. An aircraft whose estimated attitude reads level while the true one leans thirty degrees is accelerating sideways into something, and it has a few seconds.

Are there gyroscopes that do not drift?

There are gyroscopes that drift far less. A navigation-grade one uses a laser or a coil of optical fibre rather than a bending piece of silicon. It can hold an angle to a fraction of a degree over an hour. Those are what let a submarine or an airliner navigate with nothing outside to look at.

They also cost thousands of pounds and weigh more than the aircraft in this course. Every quadcopter you have seen uses a MEMS chip costing about the price of a coffee. The whole of Steps 5 and 6 exists to make that chip good enough. Buying the problem away is a real engineering option and it is almost never the one taken.

Lab 7 · The rate is right and the total is not
Try this firstLook at the lower chart before anything else. Two lines, and they sit on top of each other during a fast roll: the gyroscope is telling the truth about the rate. Now drag how long it has been flying from 2 seconds out to 40 and watch the upper chart.
Notice that nothing about the upper chart levels off. The estimated angle does not settle at some wrong value and stay there. It keeps going, and it goes at a steady rate, so the error after twenty seconds is twice what it was after ten. There is no length of flight after which it becomes safe. Nothing in the arithmetic could ever notice, because adding up readings cannot tell a real turn from a bias.
Lab 8 · Commit to a number, then measure it
Try this firstMove "your answer" to the number of seconds you think it takes, then press "Commit, then measure it". The chart appears with your answer marked on it next to the measured one. Then change the bias and try again.
Notice how short the time is, and how simple the sum. Ten degrees divided by the bias in degrees per second, and that is the answer to within a fraction of a second. A drone that trusted its gyroscope alone would be ten degrees wrong about which way up it is in the time it takes to walk across a room. Everything in the next two steps is about getting that number back.
An engineer measures the gyroscope bias carefully on the bench, subtracts it in software, and finds the drift has dropped from 30 degrees a minute to 4. What should they expect on a hot day?
The correction goes stale. A bias is not a property of the chip, it is a property of the chip right now, and it moves with temperature. Subtracting yesterday's number leaves whatever the bias has changed by since, and Lab 8 shows what any leftover bias does: it accumulates without limit. This is why no aircraft flies on an integrated gyroscope alone, however carefully calibrated. It needs something that is wrong in a way that does not add up, which is Step 5.
Step 5

An accelerometer finds the ground, and every vibration with it

The second sensor on the board is an accelerometer. Sitting still on a table it reports which way gravity is pulling. That is a direction, not a rate, so it gives an angle directly with no adding up at all. Tilt it thirty degrees and it says thirty degrees. Leave it there for an hour and it still says thirty degrees, because gravity does not drift.

Then it is bolted to a quadcopter. What the chip actually measures is not gravity but every acceleration of its own case, and four propellers spinning at two hundred turns a second are never perfectly balanced. The whole frame buzzes, and the accelerometer feels all of it, because a shake and a tilt are the same kind of thing to it.

The important part is the shape of the error rather than its size. Vibration throws the reading either side of the truth, so it is noisy but it does not walk away. Averaged over a long enough time it is still right, which is precisely the property the gyroscope did not have.

How can it tell which way is down without knowing where it is?

Inside the chip is a tiny weight held by silicon springs. Gravity pulls the weight one way, the springs stretch, and the chip measures how far in each of three directions. The pattern of those three numbers is the direction of the pull, in the case's own axes. The case is bolted to the aircraft, so the direction of gravity in the aircraft's axes is exactly the aircraft's tilt.

Two of the three numbers are enough for roll: how much of the pull is coming out through the floor, and how much out through the side. If it is all through the floor the aircraft is level. Halfway between the two means forty-five degrees.

Why can it not tell a tilt from a shove?

Because the weight and the springs have no way of knowing what moved them. Being tilted pulls the weight sideways relative to the case. Being pushed sideways pulls the weight sideways relative to the case in exactly the same way. There is no third measurement available to separate them.

This is not a shortcoming of cheap chips and no better sensor of the same kind fixes it. It is what measuring acceleration means. The word engineers use for what it really reports is specific force. That is the acceleration of the case minus gravity: the pull the case would have to feel to be doing what it is doing.

Can the vibration be reduced instead of tolerated?

Yes, and it is the first thing anybody does. Balance the propellers, mount the flight controller on soft rubber pads so the frame's buzz does not reach it, and low-pass filter the readings in software. All three help, and all three are standard.

None of them is free. Soft mounting lets the board move relative to the aircraft, which is its own small lie. A filter that removes vibration also delays the reading, and Step 9 is about what delay costs in a loop like this. Reducing the noise and coping with the noise are both required, which is a pattern worth expecting rather than being disappointed by.

Lab 9 · Vibration, and what it does to the angle
Try this firstDrag "frame vibration" down to 0.00 and read the typical error pill. The accelerometer is excellent. Now walk the vibration up to a quarter of a g, which is an ordinary quadcopter with slightly unbalanced propellers, and read the same pill.
Notice where the scribble sits. It is scattered either side of the true angle rather than leaning off in one direction, and that difference is everything. A quantity that is randomly wrong can be averaged. A quantity that is steadily wrong, like Step 4's gyroscope total, gets worse the more of it you collect.

There is a second problem, and unlike the vibration it cannot be filtered, averaged or paid to go away. A quadcopter accelerates sideways by tilting: that is its only way of going anywhere. So the two things an accelerometer cannot tell apart are precisely the two things that always happen together on this aircraft.

Lab 10 · Tilted, or shoved
Try this firstWith "Tilted, and accelerating because of it" selected, drag "how much" from 0 to 30 degrees. Watch the third row of arithmetic. Then press Level, and shoved sideways by wind and drag the same slider again.
Notice that the first answer is exactly zero, at every tilt. Not nearly zero: the tilt and the sideways acceleration it produces cancel in the arithmetic perfectly, because the tilt is what causes the acceleration. An accelerometer in a quadcopter that is accelerating reports level while it is leaning, and one being blown sideways reports a lean it does not have. Two opposite failures, one cause: it measures apparent gravity, and apparent is doing all the work in that phrase.
A passenger aircraft is in a steady, well-flown turn, banked twenty degrees. A cup of coffee on the tray table does not slide. What does that tell you about an accelerometer bolted to the floor?
It reports level, and the coffee agrees with it. That is the whole point of a well-flown turn: apparent gravity stays straight down through the floor, which is why nobody spills anything. An accelerometer is measuring the same thing the coffee is, so it cannot tell you the bank angle in a turn. Lab 10 puts the same fact on a quadcopter, where a thirty-degree lean reads as exactly zero.
Step 6

Fuse a drifting rate with a shaking direction

Two instruments, two different faults. The gyroscope is quick and steady over a second and wanders without limit over a minute. The accelerometer is a mess over a second and correct on average over a minute. Combining two measurements so that neither of their faults survives is sensor fusion, and the cheapest useful version of it is three lines long.

Keep one number, the estimated angle. On every tick, add the gyroscope's rate multiplied by the time since the last tick, exactly as Step 4 did. Then nudge the result a little way towards whatever the accelerometer says. Not all the way: a little way. That is a complementary filter, and the two halves are complementary in the ordinary sense of the word: each one covers what the other cannot.

How far is a little way is the only decision in it. It is usually written as a weight called alpha, close to one. But alpha on its own is meaningless without the loop rate beside it, so the lab asks for the same thing in seconds. The crossover time is how long the filter will trust the gyroscope before the accelerometer wins.

Where does the crossover time come from, if the code uses alpha?

The code multiplies the old estimate by alpha and the accelerometer's answer by one minus alpha. An alpha of 0.99 leaves one hundredth of the gap to the accelerometer closed on every tick, so after a hundred ticks most of it is closed. A hundred ticks at five hundred a second is a fifth of a second, and that is the crossover time.

The lab computes alpha from the seconds you choose and prints it beside the slider. The reason for working in seconds is that the same alpha means different things at different loop rates. An alpha of 0.99 is a fifth of a second at 500 hertz and two whole seconds at 50. A number that changes meaning when you change something unrelated is a good way to lose an afternoon.

Why is nudging towards the accelerometer enough to stop the drift?

Because the nudge is always towards a quantity that is right on average. The gyroscope bias pushes the estimate away at a steady few degrees a second, and the nudge pulls it back in proportion to how far away it has got. Those two balance at a small offset instead of growing for ever.

The offset is easy to predict: the bias multiplied by the crossover time. Three degrees a second and a crossover of half a second leaves about one and a half degrees of lean. That is the price, it is small, and unlike Step 4's error it does not grow with the length of the flight.

Is this what a Kalman filter does?

A Kalman filter answers the same question and works out the weight for itself rather than being handed one. It carries a running estimate of how uncertain it currently is, and updates that every tick. Each new measurement is then weighed by how noisy it is known to be, against how uncertain the estimate has become. When both sensors are behaving steadily, its answer settles to almost exactly the fixed weight a complementary filter uses.

What it buys is the ability to change its mind. During a violent manoeuvre it can decide the accelerometer deserves almost no say, and while gliding along it can lean on it heavily. What it costs is that it needs honest numbers for how noisy each sensor is. A filter told the wrong noise figures is confidently wrong, in a way that is hard to spot. Plenty of shipping aircraft fly on the three lines in this lab.

Lab 11 · The crossover time, and both ways of getting it wrong
Try this firstDrag the crossover down to 0.02 seconds and read the four pills, then drag it out to 4 seconds and read them again. Both ends are bad and they are bad differently. Then find the middle, where the solid line and the dark line lie on top of each other.
Notice that the aircraft is flying on your answer. The loop holds the estimated angle at zero, and it does that well, so every degree the estimate is wrong is a degree the aircraft is really tilted. The second pill is not a measure of the filter. It is a measure of the aircraft, and it comes out nearly the same as the first, which is the most useful sentence in this step.

A slider with a bad answer at each end has a best answer somewhere between. Where it sits is a fact about the two instruments rather than about the filter. A noisier accelerometer deserves less say, so the best crossover gets longer. A worse gyroscope bias deserves less trust, so it gets shorter.

Lab 12 · Sweep it, and watch the best value move
Try this firstRead the marked bottom of the curve, then drag "frame vibration" up. The mark moves to the right. Now put the vibration back and drag gyro bias up instead, and watch the mark move the other way.
Notice that tuning a filter is not really tuning. The best value is decided by which of your two instruments is currently the less bad one, so it belongs to the aircraft you built rather than to the arithmetic. Balance the propellers and the answer changes. That is why a filter setting copied from somebody else's build is a guess wearing a number.
A drone flies well but drifts slowly across the garden even with the sticks centred, always in roughly the same direction, and it takes about a minute to become obvious. Which end of the crossover slider is the suspect?
Too long. Slow, steady and in one direction is the fingerprint of a bias being believed. The estimate leans by the bias multiplied by the crossover time, and the loop holds that leaning estimate at zero. Holding a leaning estimate level means holding the aircraft at a genuine tilt. A genuine tilt is a sideways acceleration, and a sideways acceleration for a minute is the far side of the garden. Lab 12 measures both ends: one gives a shaking aircraft, the other a wandering one.
Step 7

Put a rate loop inside an angle loop

There is now an estimated angle, and an angle wanted, so the difference between them could be handed straight to the mixer. It works, and nobody does it. Instead a flight controller runs two loops, one inside the other and the reason is what each sensor is actually good at.

The outer loop looks at the angle and produces not a motor command but a rate: this far off level, so please turn at this many degrees a second. The inner loop takes that request, compares it with what the gyroscope reports right now, and turns the difference into motor commands. Two loops arranged like this are a cascade. The inner loop is the fast one nearest the hardware, the outer loop the slow one nearest the goal.

What that buys is honesty about information. The gyroscope measures rate directly, quickly and without drifting, so the inner loop is working with the best number on the aircraft. The estimated angle is slower and partly guessed, so the outer loop, which has to use it, is the one that is told to be gentle.

Have I met a cascade before without the name?

Probably, in driving. A driver deciding to be in the next lane does not think about how many degrees to turn the wheel per second. They decide roughly where they want the car and let a faster, more practised sense of steering handle the moment-to-moment work. Two levels, the slower one giving instructions in the units the faster one understands.

Industrial control is full of them. A tank's level loop asks for a flow rate, and a flow loop underneath it works out the valve position. Cascades are worth reaching for whenever there is a fast, well-measured quantity in the middle of a slow, poorly-measured one.

What does the inner loop actually give the outer one?

The illusion of a machine that turns at whatever rate it is asked for. That is the trick, and it is why cascades are worth the extra layer. The outer loop does not have to know about inertia, motor lag, propellers or torque. As far as it is concerned it is steering something whose rate it can set.

That illusion is only as good as the inner loop is quick. When the inner loop starts taking a long time to reach the rate it was asked for, the outer loop's picture of the world is wrong. Lab 14 is where that happens.

What happened to the integral term from Control Systems?

It is there on real aircraft and it is small. The inner loop has one, to deal with a steady offset: an unbalanced payload, or a slightly weak motor. It is kept small and limited, for the reason Control Systems gives. A running total that grew while the motors were flat out keeps demanding long after the demand became wrong.

These labs leave the inner loop's integral at zero so that nothing in a chart is being caused by something with a memory. The derivative term is here and doing real work, as the damping in the inner loop. On a real aircraft it is the term that needs the gyroscope filtered before it can be used at all.

Lab 13 · Inside one decision
Try this firstPress "Walk through the first tenth of a second" and watch the six lines of arithmetic change. Then drag which tick by hand to stop at a moment you want to read slowly.
Notice what the outer loop hands over. It is a rate in degrees per second, not a throttle, and it is in exactly the units the gyroscope reports. That is the join between the two loops. It is why the inner one can check its own work five hundred times a second while the outer one is still waiting for the angle to move.

Because the outer loop is steering something whose rate it can set, it can only push as hard as the inner loop can deliver. Ask for a rate change every few milliseconds and the inner loop will still be working on the last request when the next arrives. Requests that are never finished pile up, and piling up is what an oscillation is.

Lab 14 · How hard the outer loop may push
Try this firstRead the last pill, which is the highest angle gain that still settles, then drag "angle gain" past it. Now drag motor time constant from 20 milliseconds up to 60 and read that pill again.
Notice that the ceiling is not a property of the outer loop. It moves when you change the motors, and the outer loop's gain was not touched. The highest angle gain that works is set by how quickly the inner loop can actually deliver a rate, which is set by the hardware. This is the whole of what "the inner loop must be faster" means, and the next two steps attack that speed from two different directions.
An engineer wants a sharper-handling aircraft and doubles the angle gain, so the outer loop asks for twice the rate at any given tilt. The aircraft now wobbles around level instead of holding it. The gyroscope, motors and mixer are untouched. What is the honest description?
The outer loop has outrun the inner one. A cascade works because the inner loop makes the aircraft look like something that simply turns at whatever rate it is told. That illusion holds only while the inner loop is much quicker than the requests arriving, and doubling the outer gain halves the time between meaningful changes of request. Lab 14 finds the exact gain where it stops holding, and shows that same ceiling dropping when the motors are made slower.
Step 8

Slow the loop to fifty times a second, and change nothing else

Every lab so far has run the loop five hundred times a second. The tank of water in Control Systems managed at ten, and held its temperature to a fraction of a degree. Both numbers are right for their machine, and the difference between them says nothing about which software is better. It is set by how much trouble each machine can get into while nobody is looking.

The loop rate is how many times a second the controller reads its sensors, does its arithmetic and writes to the motors. It is quoted in hertz, which just means times per second. Five hundred hertz means one full decision every two thousandths of a second.

What matters is what the airframe can do in the gap. Two motors flat out and two stopped is all the roll this frame has, and it works out at about ten thousand six hundred degrees per second per second. Multiply that by the gap between decisions and you have how much rate the aircraft can pick up while the controller is not looking.

Why does the angle depend on the square of the time?

Because during the gap the rate is itself growing. Halfway through the gap the aircraft is turning at half the rate it will reach by the end. So the angle picked up is not the final rate multiplied by the whole gap. It comes out as half the acceleration multiplied by the time twice over, which is the same sum as how far a dropped stone falls.

The practical result is that halving the loop rate doubles the rate the loop can be surprised by and quadruples the angle. Loop rate does not buy improvement steadily. It buys it in a hurry at the bottom end and hardly at all at the top.

Is this the same as the lag from Control Systems?

It is one of the several places lag comes from, and it is the one you choose. Deciding every twenty milliseconds means acting on news that is on average ten milliseconds old. Then holding that decision for the rest of the gap. Both halves are delay, and both are paid for by whoever picked the loop rate.

The other sources are not yours to choose. The motors take time, the sensor filtering takes time, and the electronics that hand the number to the motor take time. Step 9 is about the largest of those.

Why not run the loop as fast as the chip allows?

Because past a certain point it stops buying anything and starts costing. A loop faster than the motors can respond is producing decisions nobody can act on, which is what Step 9 measures. And every doubling of the loop rate halves the time available to do the arithmetic in. So a filter has to be cheaper, or the chip has to be bigger, or something has to be left out.

There is a subtler cost too. A derivative term works on the difference between two readings divided by the time between them. At very short times that division is by a very small number, so sensor noise is amplified. Running faster makes the filtering harder rather than easier. That is why real aircraft settle on a few hundred hertz to a few thousand, not on the highest number the chip can manage.

Lab 15 · The same gust at four loop rates
Try this firstNote the settling pill at 500 Hz, then press 250, 100 and 50 in turn. Not one gain changes between those four runs, and the angle is handed to the loop exactly right, so the loop rate is the only thing that moves. Watch the faint motor line as well as the angle: at 50 hertz it stops being a curve.
Notice that nobody mistuned anything. The gains that took the gust out in a quarter of a second at 500 hertz are the same gains that never settle at 50. The correction is now describing a world that has already moved on, so it adds to the swing instead of removing it. What stops the swing growing without limit is not the controller. It is the motors hitting fully on and fully off, and an aircraft held together by saturation is not under control.
Lab 16 · What the airframe does between two decisions
Try this firstDrag the loop rate down from 500 and watch the third line and the table. Halve the rate and see which numbers double and which quadruple.
Notice that neither number is about the software. Both come out of the airframe: its weight, its arm length and how hard its motors push. That is what a loop rate has to be measured against, and it is why the same question has such different answers for a tank of water and for this. A tank cannot surprise you in a tenth of a second. This can surprise you in two thousandths.
The same flight controller software, with the same gains, is moved from a small racing quadcopter onto a large heavy one with long arms and big slow propellers. Which way does the sensible loop rate move?
Down, and by a lot. The requirement is set by how much rate the airframe can gain between decisions, which is its maximum angular acceleration multiplied by the gap. A heavy aircraft with long arms and big propellers has a fraction of the acceleration of a racing quad, so it can be left alone for longer. Large aircraft really do run slower loops than small ones, and the reason is in the airframe rather than in the code. Note the other half of the move, though: the same change makes the motors slower, which is Step 9, and that pushes the other way.
Step 9

A fast loop cannot outrun a slow motor

A motor command is not an event, it is a request. Ask a propeller for more thrust and it has to be spun faster, and a propeller has weight, so it takes time. How long is described by the motor time constant: the time the thrust takes to cover roughly two thirds of the change it was asked for. On a small quadcopter it is about twenty milliseconds.

Put that beside the loop rate. At five hundred hertz the controller makes a decision every two milliseconds, so ten decisions go past while one change in thrust is still arriving. Every one of them is made while looking at an aircraft that has not yet received the last instruction.

That is survivable, and every flying quadcopter survives it. What is not survivable is fitting a heavier propeller onto an aircraft that was flying perfectly the day before, without changing anything else at all.

What exactly is a time constant?

It is the natural way to describe anything that closes a gap in proportion to how big the gap still is. In the first time constant it covers about 63 per cent of the change, in the second about 63 per cent of what was left, and so on. After three time constants it is within a twentieth of where it was going.

Control Systems used the same idea for a thermometer that had to warm up before it could report. The arithmetic is identical. What is different here is which end of the loop it sits at: there it delayed the measurement, and here it delays the action.

Why does a slower motor break a tuning rather than just slow it down?

Because of Step 7. The inner loop's job is to make the aircraft look like something that turns at whatever rate it is asked for. How quickly it can do that is set by how quickly the thrust can change. Slow the motors and the inner loop gets slower, while the outer loop keeps asking at exactly the rate it did before.

So nothing was mistuned and the tuning is now wrong. The ceiling Lab 14 measured has come down under a gain that has not moved. That is a general shape worth carrying: a tuning is never a property of the software on its own, it is a claim about the software and the hardware together.

What decides a motor's time constant in the first place?

Mostly how heavy the propeller is and how far its weight sits from the middle, because that is what has to be spun up or slowed down. A larger, heavier propeller is slower, and so is one made of tough plastic rather than light carbon. The motor's own strength matters too: a motor with more turning force gets there sooner.

The electronics contribute a little. The controller that drives the motor takes a moment to notice a new number. Older ones only accept a new value a few hundred times a second, and that is a delay on top of the lag. Modern digital protocols cut that part down, which is most of what they are for.

Lab 17 · Heavier propellers, on the same tuning
Try this firstRead the pill that says how far the tuning survives, then drag the motor time constant past it. The loop rate is fixed at 500 hertz throughout and you cannot reach it, so the only thing changing is how long the motors take.
Notice that the loop is still deciding five hundred times a second. It has lost nothing in speed and gained nothing in usefulness, because the loop rate sets how often you may push and the motor sets how quickly the push arrives. Past the threshold the corrections are landing after the moment they were needed, and the aircraft never settles. Nobody touched a gain.

Which leaves a practical question with money attached. If you can improve either the loop rate or the motors but not both, which is worth having.

Lab 18 · Two builds, the same gust
Try this firstDecide which of the two builds you would buy, then press "Race the two builds". One of them has eight times the loop rate of the other. Read the "back to level" column.
Notice that the faster loop lost. A thousand decisions a second about a motor that needs sixty milliseconds is a thousand decisions nobody can act on. That does not make loop rate unimportant, and Step 8 showed what happens when it is too low. It means the two have to be chosen against each other. The loop rate worth paying for is the one that stops the loop being the slowest thing in the chain. Past that you are buying arithmetic.
A pilot swaps to tougher propellers because they keep breaking the light ones. The aircraft now wobbles in the air where it used to hold still. They double both rate and angle gains to sharpen it up. What should they expect?
Worse. The wobble is a correction arriving after the moment it was needed, and the fix for a late correction is never a bigger one. Both labs point the same way: the motor time constant a tuning survives is measured, and the highest angle gain that works comes down as the motors get slower. The honest moves are to lower the gains and accept a softer aircraft, or to put the light propellers back and stop breaking them by flying into things.
Step 10

Lose one motor of four, and find out what is left

A motor stops. A wire vibrates loose, or a propeller comes off, or a bearing seizes. Step 2 counted four independent effects from four motors, so three motors means three effects, and an aircraft needs four. Something has to give.

What is worth working out is which. Not by opinion, because the arithmetic settles it: the combination the three survivors can no longer produce is exactly the stopped motor's own column of signs. Any set of demands they can meet has to be at right angles to that column, which is one equation. Choose any three of height, roll, pitch and yaw, and the fourth is whatever that equation says it is.

Before any of that helps, though, the mixer has to know. A mixer that does not know is still writing four numbers, and one of them is going nowhere.

Why is the lost combination the dead motor's own column?

Because the four columns are at right angles to one another, which is what Lab 4 was really about. Being at right angles means no mixture of the other three can add up to the fourth. No amount of walking east and north gets you upwards, and this is the same fact.

So the column belonging to the stopped motor is the one direction that has gone, exactly and not approximately. It is easy to read off: it is the four signs that motor carried. Motor 1 was plus height, plus roll, minus pitch, minus yaw, so that combination is what has been lost.

Why is yaw the demand worth giving up?

Because it is the only one of the four an aircraft can be wrong about and survive. Lose height and it falls. Lose roll or pitch and it is on its side within a second, and then it also falls. A spinning aircraft that is holding its height and staying level is unpleasant, hard to film with and hard to steer. It is still flying.

Lab 20 lets you insist on one of the others instead, and the equation answers honestly each time. Asking to keep yaw at zero is the most instructive: it can be done, on three motors, as long as the total lift is nothing.

Does this really work on a real aircraft?

It does, and it has been flown. Research groups have shown quadcopters that lose one propeller, spin up to several turns a second, and keep station well enough to land safely. It is not standard on hobby aircraft. The failure has to be spotted and switched to within a fraction of a second and a wrong detection turns a healthy aircraft into a spinning one.

The version in this lab is simplified in one way, and it is worth saying which. A real spinning aircraft has to be tilted a little. It does not hold its own axes level, because the spin interacts with the turning of the other two. That effect is real, it is called gyroscopic coupling. It is left out here. What it changes is the detail of the attitude held, not the conclusion about which demand has to go.

Lab 19 · Three runs, one motor apart
Try this firstPress "M1 stops, mixer does not know" and read the height pill. Then press M1 stops, mixer knows and gives up yaw and read every pill again, including the one about turns a second.
Notice which second motor went to nothing. The mixer that knows shuts down the motor diagonally opposite the dead one, because those two are the pair whose propellers turn the same way. So the aircraft ends up flying on two propellers that both twist it the same direction, with nothing left to twist back, and that is the spin. It is not a side effect the software failed to prevent. It is the price the arithmetic charged.
Lab 20 · Pick three to hold, and read the fourth
Try this firstWith M1 stopped, press "give up height" and read the answer on the third line. It is zero lift. Then work round the other three and see which of them a machine could survive.
Notice that nothing here was decided by a designer. One equation with one unknown, and it hands back the same answer however you feel about it. This is the most useful thing linear arithmetic does for engineering: it tells you which of your options were never options.
A hexacopter has six motors, three turning each way. One stops. Using the same reasoning as this step, what should you expect?
All four, with less room to spare. The number that matters is not how many motors there are but whether the survivors still cover the four demands. Five do, with one spare, which is exactly why aircraft carrying expensive cameras or people have six or eight motors rather than four. That spare column is what is being bought. Note the catch, though: on a hexacopter the two propellers next to each other turn opposite ways, so which motor stops changes how much margin is left.
Step 11

Decide what a machine should do when it does not know where it is

Everything so far has assumed the estimated angle is roughly right. Sometimes it is not. A connector works loose, or a propeller strike shakes the accelerometer past anything it can measure. A bird hits the aircraft, or the filter is simply asked to keep up with something it cannot. A planned response to a fault is a failsafe, and writing one means answering a question with no comfortable answer in it.

The default answer, the one that happens when nobody writes any code, is to carry on. The loop goes on holding the estimated angle at zero. If that estimate is thirty-five degrees wrong, the loop rolls the aircraft thirty-five degrees to correct an error that does not exist. Now the aircraft really is tilted, so it accelerates, which corrupts the accelerometer further.

Three replies are available and none of them is good. Carry on. Stop steering, hold still using the gyroscope alone, and descend. Or cut the motors.

Why can it hold still with the gyroscope if the gyroscope drifts?

Because holding still needs a rate and not an angle. The instruction is turn at zero degrees a second, and the gyroscope measures that directly, quickly and without any adding up at all. Step 4's problem was the total. This asks for no total.

What it cannot do is find level. It will hold whatever attitude the aircraft happened to have when the fault arrived. If that was a lean, it will hold the lean and fly sideways the whole way down. Holding still is a much weaker promise than being level, and it is the strongest promise the aircraft can still keep.

How would a machine know that it does not know?

By checking its two sensors against each other. There is one signal available and Lab 22 is it: how far the accelerometer's answer sits from the current estimate. On a healthy aircraft those two disagree by a few degrees, because of vibration. On a broken one they disagree by a great deal and stay that way.

The catch is that a real manoeuvre also makes them disagree, for the reason Step 5 gave: an accelerating aircraft has an accelerometer that is wrong. So a detector has to be deaf to a manoeuvre and awake to a fault, and for the first fraction of a second those look the same.

What do full-size aircraft do about this?

They carry three of everything and vote. With three attitude sources, one going wrong is outvoted by the other two and can be shut out. That is a much stronger position than having two and knowing only that they disagree. Where weight allows, safety-critical systems buy their way out of this problem rather than reasoning their way out.

Even then the answer to a genuine loss of attitude is a procedure rather than a calculation. It is written down in advance, by people who have thought about what is underneath. That is the same conclusion as this step reaches with three buttons: the arithmetic can tell you what each choice costs. It cannot tell you which cost to accept.

Lab 21 · Three replies to the same fault
Try this firstRead all three rows of the table before pressing anything else. The estimate goes wrong at the same moment in all three runs, from the same height. Compare the speed it arrives at against how far from underneath it lands.
Notice that the two sensible options trade against each other. Cutting the motors lands the aircraft almost exactly beneath where the fault happened, hard. Descending under control more than halves the speed it arrives at, and puts it ten metres away, in a direction nothing on board knows. Which of those is better is a question about what is under the aircraft, and no amount of arithmetic on board can answer it.

Which is worth saying plainly, because it is easy to write a failsafe that sounds reassuring and means nothing. Level off and descend is not available: levelling off needs to know where level is, and not knowing that is the fault. Return to launch is not available either, for the same reason.

Lab 22 · Noticing, without crying wolf
Try this firstDrag the threshold down to 3 degrees and read both pills. It catches the fault instantly and it also fires on the healthy flight. Now find a setting where the first pill says no false alarms and the second still catches it.
Notice that the gust in the healthy flight is the hard part. A real manoeuvre throws the accelerometer about, so the two instruments really do disagree during it, and a detector cannot tell that from a fault by looking at one moment. Averaging over a longer window separates them, and every millisecond of averaging is a millisecond the aircraft spends tilting before anybody notices.
A manufacturer advertises that if the attitude estimate is ever lost, the aircraft will level itself and descend gently. What is wrong with that promise?
It cannot level itself. Levelling means driving a known angle to zero, and the fault is that the angle is not known. The strongest honest promise is to hold zero rotation rate on the gyroscope, which freezes whatever attitude the aircraft happened to have, and to descend on a fixed throttle. Lab 21 measures what that gets: less than half the impact speed of cutting the motors, and ten metres of travel in a direction nothing on board can report.
Step 12

Your own aircraft, with nothing marked

Everything is exposed here and nothing is graded. The loop rate, the motor time constant, both gains, the fusion crossover and the frame vibration. Plus a gust, a stopped motor and a switch for whether the mixer has been told.

One suggestion for using it. Set the loop rate and the motor time constant first, and leave them alone, then find gains that cope. That is the order a real build hands them over. The loop rate and the motors belong to the hardware you bought. The vibration belongs to how well you balanced the propellers. Only the gains and the crossover are yours.

Then try to break each thing this course claimed. Find a loop rate slow enough that no tuning is calm. Find out whether a very short crossover can be rescued by lowering the gains. Stop a motor without telling the mixer, and then tell it, and watch the height pill rather than the angle.

What have I actually got in front of me?

The same aircraft as every other lab. Half a kilogram, arms 125 millimetres long, four motors that manage 3.68 newtons each. The angle gain turns degrees off level into a rate request. The rate gain turns degrees per second of rate error into motor commands. The mixer turns those into four throttles, the motors chase them at whatever time constant you chose, and the height loop holds forty metres.

The estimated angle comes from the complementary filter at whatever crossover you set. It is fed by a gyroscope with a three degree per second bias, and an accelerometer feeling whatever vibration you dialled in. The true angle is drawn as well, which no real aircraft has, and comparing the two is the whole reason a simulation is worth having.

Which of these six numbers would I actually change on a real build?

The two gains and the crossover, freely, from a laptop. The loop rate, once, from a menu, and it is usually already set sensibly. The other two are jobs with tools. The motor time constant is a different propeller, and the vibration is balancing the ones you have and softening how the board is mounted.

Which is why the vibration slider is worth spending time on. It is the one number a careful builder can improve for nothing but patience, and it moves the best crossover, which moves how well everything else works.

What is missing from this model?

Several things, and it is worth knowing which so a real aircraft does not surprise you. Thrust here is proportional to the command, while a real propeller pushes roughly as the square of its speed. So a real mixer is less even-handed at low throttle than at high. There is no wind beyond a single gust, and real air is never still. The spin in Step 10 does not interact with the other two axes, as noted there. And the arms are rigid, while a real frame flexes and its buzz can find its way into the gyroscope readings.

The largest omission is that this aircraft has no idea where it is. Holding an angle and holding a position are different problems, and the second needs something looking outside: satellites, a camera pointing down, or a rangefinder. That is where this subject joins the Autonomous Systems course. Localisation must represent uncertainty as well as the best position estimate, because the controller needs to know when the estimate is no longer safe to use.

Lab 23 · Your own aircraft
Try this firstDrag the loop rate down to 100 Hz and leave it there. Now hunt for an angle gain and a rate gain that still settle after the gust. When you have something you like, press Stop motor 1 and see whether your tuning cares.
Notice how much less room there is at a low loop rate. At 500 hertz a wide range of gains all look respectable and it is hard to tell a good tuning from a lucky one. At 100 most are bad and the good ones are narrow. Nothing you do to the gains buys back the information a slow loop is costing you. That is the one idea from this course most worth carrying to the next machine.
You inherit a quadcopter that flies well in still air but leans and wanders on a long flight, and the wander gets worse the longer it is up. Nothing is wrong with the way it responds to the sticks. What is the first thing to look at?
Look at the estimate before the loop. Getting worse the longer it flies is the signature of something being added up, which points at the gyroscope bias and at how much say it is being given. The loop is doing its job perfectly: it is holding the estimated angle at zero while the biased estimate slowly leans. Lab 11 plots estimated and physical angle together. If they track closely while both drift, inspect sensor bias and fusion before changing the control gains.
Where learned flight policies fit

A vision-language or learned control model can interpret a mission, identify a landing area, or propose the next waypoint. The fast attitude and rate loops in this course should remain deterministic. They run more often, enforce physical limits and keep the aircraft stable while a slower model reasons about the mission.

New policies are first tested in simulation and replay, then in shadow mode where their proposals are logged but not executed. A safety monitor checks every accepted command and can return control to a known hover or landing procedure. The Autonomous Systems course covers this layered design.

What you can do now

  • Say what each of four motors does to an airframe, and why four is the number rather than two or three.
  • Write a mixer, and recognise the fault a wrong sign in one causes from how the aircraft behaves in its first second of flight.
  • Explain why a gyroscope cannot give an angle, and predict how long a given bias takes to make an integrated angle useless.
  • Explain why an accelerometer cannot give an angle either, and say what it really measures in a banked turn.
  • Fuse the two with a complementary filter, choose the crossover on purpose, and say what each end of that choice costs.
  • Describe an attitude loop as a cascade, say which sensor each half uses, and say why the inner one has to be quicker.
  • Work out from an airframe's mass and thrust how much trouble it can get into between two decisions, and choose a loop rate from that rather than from habit.
  • Recognise when a loop's problem is its actuator rather than its arithmetic, and say why raising the gains makes that case worse.
  • Work out which demands are still holdable when a motor stops, and which one the arithmetic insists you give up.
  • Say what a failsafe can honestly promise when the attitude estimate is gone, and what it cannot.

Where this goes

  • Autonomous Systems. This aircraft holds an angle and has no idea where it is. Holding a position needs something that looks outside, and it needs the machine to be honest about how much it trusts what it sees.
  • Embedded Systems. Everything here has to run on a real chip on a real clock. Reading a sensor over a serial bus, keeping a five hundred hertz timer honest, and writing to four motor outputs without ever being late.
  • Computer Vision. A camera pointing at the ground can measure how fast the aircraft is moving sideways. That is the missing measurement in Step 5, and the reason a modern drone can hover indoors.
  • Control Systems. Worth a second visit now, particularly the step on lag. The same three terms and the same argument, on a machine slow enough to watch the mistake being made.