One error, three reactions
Almost every robot motion starts with a gap. You tell a joint where you want it (the set-point), you measure where it actually is, and the difference between them is the error. A controller's whole job is to drive that error to zero by deciding how hard to push the motor. The challenge is that a single number — the error right now — is not enough information to push wisely.
PID control is the elegant answer. It builds three separate corrections out of that one error signal and adds them together. P looks at the error in the present, I sums up the error from the past, and D anticipates the future by watching how fast the error is changing. Each term answers a different question, and their sum is the command the controller sends. This is feedback control at its most practical.
Present, past, and future of the error
The proportional term reacts to the present. It multiplies the current error by a gain: the farther you are from the target, the harder it pushes; as you close in, it eases off. On its own, P feels like a spring pulling the robot toward the set-point. But a pure spring has a flaw — it often stops a hair short. When the leftover error is tiny, the proportional push becomes too weak to overcome friction or gravity, leaving a small permanent gap called steady-state error.
The integral term cures that. It accumulates the error over the past — adding up every leftover bit, moment after moment. As long as any error remains, the integral keeps growing, and its contribution keeps rising until even a tiny gap is finally squeezed out. Integral is patient memory: it refuses to let a small, stubborn offset live forever. The price is that an over-eager integral can build up too much and cause the robot to swing past the target before correcting.
The derivative term looks toward the future. It watches not the error itself but how fast the error is changing, and it pushes back against rapid change. If the robot is rushing toward the target, derivative sees the error shrinking quickly and applies the brakes early, smoothing the approach. This damping reduces overshoot — the tendency to fly past the target and then bounce back — and helps the motion settle calmly instead of oscillating.
The formula, on one motor axis
Written out, the controller is just a weighted sum of those three readings of the same error e(t). Each weight is a gain you tune — Kp, Ki, Kd — that sets how loud each term speaks.
error: e(t) = target - measured
u(t) = Kp * e(t) # present: how far off
+ Ki * integral(e dt) # past: total leftover
+ Kd * d/dt e(t) # future: how fast e changes
# u(t) is the command sent to the motorPicture a single servomotor turning a robot-arm joint to a commanded angle. Turn up Kp and the arm snaps toward the target faster, but too much makes it overshoot and shudder. Add Ki and any small residual angle — say, from gravity loading the arm — is slowly erased. Add Kd and the arm stops shaking on arrival, gliding into place. The three gains are a balance: aggressiveness from P and I, calm from D.
Why robots reach for PID first
PID is everywhere in robotics because it asks almost nothing of you. Unlike fancier controllers, it needs no precise mathematical model of the machine — just an error to read and a knob to turn. The same three-term recipe controls a drone's altitude, a wheeled robot's speed, a 3D-printer head's temperature, and a quadruped's joint torques. When you only need to hold or track one quantity, PID is usually the first and last tool you reach for.
In practice, many real robots do not even use all three terms. A velocity loop often runs as PI — proportional plus integral — because there is little need to anticipate. A position loop on a clean, low-friction joint may run as PD, since there is little steady offset to erase but plenty of overshoot to damp. Dropping a term you do not need is normal and keeps tuning simpler. PID is a menu, not a fixed meal.