PID (proportional-integral-derivative) control is a feedback control law that computes an actuator command from the error between a setpoint and a measured value, using three terms: one proportional to the present error, one to its accumulated past and one to its rate of change. In robotics control systems, PID controllers regulate joint positions, wheel speeds, motor currents, drone attitude and gripper force, and they remain the most widely deployed controller in practice.
Its popularity comes from a rare combination: PID needs no detailed model of the plant, has only three parameters to tune and behaves predictably on most actuators found in robots. Its limits appear with strong nonlinearity, long dead time or tightly coupled axes, where model-based methods take over.
How the three PID terms act on the error
A PID controller adds three corrective actions computed from the error e(t), in the parallel form u(t) = Kp·e(t) + Ki·∫e(t)dt + Kd·de(t)/dt. Each gain controls one action, and the art of tuning is balancing speed, overshoot and noise sensitivity among them.
| Term | Responds to | Main effect | Side effect if too large |
|---|---|---|---|
| Proportional (P) | Present error | Faster response, stiffer hold | Overshoot and oscillation |
| Integral (I) | Accumulated past error | Removes steady-state error | Slow oscillation, windup |
| Derivative (D) | Rate of change of error | Damping, less overshoot | Amplifies sensor noise |
Proportional action alone usually leaves a steady-state error whenever a constant load, such as gravity on an arm joint, must be resisted, because some error is needed to produce the holding torque. The integral term keeps growing until that error disappears. The derivative term anticipates the error trend and brakes the motion before overshoot occurs.
Controller variants and implementation forms
Not every loop needs all three terms, and in practice PI control is more common than full PID, because derivative action is sensitive to noise and many plants are adequately damped. The choice depends on what the loop must achieve.
| Variant | Typical robotic loop | Why this variant |
|---|---|---|
| P | Position loop around a fast velocity loop | Inner loop already provides damping |
| PI | Motor current and wheel velocity loops | Zero steady-state error, noise-tolerant |
| PD | Legged robot joints, impedance-like control | Stiffness and damping without windup |
| PID | Stand-alone position or attitude loops | Needs both zero offset and damping |
Real controllers are discrete-time: they sample the error at a fixed rate, typically 10 to 30 times faster than the desired closed-loop bandwidth. Good implementations add a low-pass filter on the derivative, compute the derivative on the measurement rather than on the error to avoid a spike when the setpoint jumps, and include anti-windup logic. The ideal form, with gain, integral time Ti and derivative time Td, is mathematically equivalent to the parallel form but often easier to tune by intuition.
Tuning methods for PID gains
PID tuning means choosing gains that give fast, well-damped response with adequate robustness margins, and methods range from trial and error to model-based design. The table compares the approaches used most often on robots.
| Method | What it requires | Strength | Limitation |
|---|---|---|---|
| Manual tuning | Experience and a safe test setup | Works on any plant | Slow, depends on the operator |
| Ziegler-Nichols ultimate gain | Driving the loop to sustained oscillation | Simple formulas | Aggressive, about 25% overshoot or more |
| Relay autotuning | Relay test that induces a limit cycle | Automated, controlled amplitude | Assumes a fairly simple plant |
| Model-based (IMC, lambda) | Identified plant model | Explicit robustness trade-off | Model quality limits results |
| Optimization-based | Simulation and a cost function | Handles multiple objectives | Requires accurate simulation |
With the classic Ziegler-Nichols rule, a loop that oscillates steadily at an ultimate gain Ku = 2.0 with a period Tu = 0.5 s gives Kp = 0.6·Ku = 1.2, Ti = Tu/2 = 0.25 s and Td = Tu/8 = 0.0625 s. In parallel form, that is Ki = 4.8 per second and Kd = 0.075 s. These values are a starting point; most robotic loops are then softened for less overshoot.
Practical problems in PID loops
Most PID problems on real robots come from saturation, noise, friction and changing dynamics, effects that the textbook linear formula does not include. The table links typical symptoms to their causes.
| Symptom | Cause | Fix |
|---|---|---|
| Large overshoot after saturation | Integral windup while the actuator is at its limit | Clamping or back-calculation anti-windup |
| Jittery, hot motor | Derivative gain amplifying sensor noise | Filter the derivative, reduce Kd |
| Slow creep near the target | Static friction and deadband | Friction feedforward, small integral boost |
| Good at one pose, poor at another | Inertia or load varies with configuration | Gain scheduling or model-based feedforward |
| Limit cycle around the setpoint | Gear backlash or quantized sensor | Deadband on error, better feedback resolution |
PID compared with other control approaches
PID is one specific form of feedback control, and it is often paired with or replaced by more advanced methods. Model predictive control optimizes future moves under constraints, while state feedback designs handle multiple coupled variables at once.
| Approach | Model needed | Handles constraints | Typical use in robots |
|---|---|---|---|
| PID | No | Only through saturation logic | Single-axis loops in drives and flight controllers |
| PID with feedforward | Approximate dynamics | No | Fast trajectory tracking of manipulator joints |
| State feedback (LQR) | Linear state-space model | No | Balancing robots, coupled axes |
| Model predictive control | Predictive model | Yes, explicitly | Legged locomotion, vehicle motion |
In robot software stacks, PID typically runs at the lowest control level. Frameworks built on ROS 2 include standard PID-based controllers for joints and wheels, while higher layers plan trajectories and pass setpoints down to these loops.
The short version
PID is a simple recipe a machine uses to reach a target and stay there. It checks three things. How far is it from the goal? How long has it been off? How fast is the gap changing? It then adjusts its effort based on all three.
Think of setting a shower to the right temperature. When the water is far too cold, you turn the knob far. If it stays slightly cold, you keep nudging it. As it warms quickly, you ease off so you do not overshoot into scalding water.
Where it makes a difference
A quadcopter used for bridge inspection stabilizes itself with cascaded PID loops. An inner PID loop runs at about 1 kHz on the angular rates measured by the gyroscope, and an outer loop converts angle errors into rate setpoints. The derivative term is low-pass filtered because propeller vibration would otherwise reach the motors as noise.
One subtle detail decides whether takeoff is clean: while the drone sits on uneven ground, any small attitude error makes the integral term accumulate. The flight controller therefore holds the integral term at zero until throttle passes a threshold. With that guard and filtered derivative action, the drone holds its attitude within about one degree in gusty wind near the bridge piers, steady enough for sharp close-up inspection images.