A robot that cannot check its own work is guessing. Feedback control is the fix, and it is the same handful of lines whether you are driving a bot to a line, holding a drone at altitude, or keeping a 3D printer nozzle at 210 degrees.
Flip the lab to Open loop and run it. The bot gets one instruction: full power for a fixed number of seconds, then coast. Tuned on a bench, it lands on the line. Beautiful.
Now add mass, or tick Drive uphill, and run it again. It lands somewhere else, and it has no idea. Nothing in that instruction ever looks at where the bot actually is. Open loop is a robot with its eyes shut, and the real world is never exactly the bench.
Close the loop and the bot gets a sensor. Now it can compute one number, over and over, hundreds of times a second:
Everything from here is just different ways of turning that one number into a motor command. That is the whole field.
The classic controller runs three terms at once and adds them up. Each one is watching the error in a different tense.
Far away, push hard. Close, push gently. The workhorse.
Keeps a running total of every error so far. Notices a problem that never goes away.
Watches how fast the error is shrinking and brakes before the bot arrives.
Drag the P slider to 1.5 with I and D at zero. The bot creeps toward the line and the test ends before it gets there. Too little push.
Now drag P to 40. It arrives fast, blows straight past the line, comes back, overshoots the other way, and rings like a struck bell. The reason is momentum: at the exact moment the bot is on target the error is zero, so P is commanding nothing, but the bot is still doing three meters a second. Nothing has told it to slow down.
Leave P at 25 and raise D. The ringing damps out. D is looking at how fast the error is closing and pushing back against it, so the bot starts braking while it is still short of the line.
Here is a detail worth knowing. The target is not moving, so the rate of change of the error is just the bot's speed with a minus sign in front of it. The D term is literally reading the speedometer:
Set P to 25, D to 14, and tick Drive uphill. Smooth as anything, and it stops about half a meter short. Forever. It is not still creeping. It has settled there.
P is proportional, so it needs error to produce push. Uphill, the bot needs a constant force just to hold station. The only way P can supply that force is to sit at exactly the error that generates it:
Now raise I. The running total of that small stubborn error keeps growing, so the I term keeps growing, and it quietly takes over supplying the hill force. When the bot finally reaches the line the error stops adding up and the total freezes at exactly the value that holds it there. That leftover total is the controller remembering the hill.
Engineers have done this in the same order for about a century, and you can do it in the lab right now:
| Machine | Target | Sensor | Motor |
|---|---|---|---|
| Your thermostat | 21 degrees | Thermometer | Furnace |
| Cruise control | 65 mph | Wheel speed | Throttle |
| A drone hovering | 2 m altitude | Barometer | Four rotors |
| 3D printer hot end | 210 degrees | Thermistor | Heater cartridge |
| A bot driving to a spot | An arena coordinate | Position | Drive wheels |
Six questions on the loop. Answers explain themselves as you go.