PID

On this page 7

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.

TermResponds toMain effectSide effect if too large
Proportional (P)Present errorFaster response, stiffer holdOvershoot and oscillation
Integral (I)Accumulated past errorRemoves steady-state errorSlow oscillation, windup
Derivative (D)Rate of change of errorDamping, less overshootAmplifies sensor noise
Role of each PID term

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.

VariantTypical robotic loopWhy this variant
PPosition loop around a fast velocity loopInner loop already provides damping
PIMotor current and wheel velocity loopsZero steady-state error, noise-tolerant
PDLegged robot joints, impedance-like controlStiffness and damping without windup
PIDStand-alone position or attitude loopsNeeds both zero offset and damping
PID family members in robotic loops

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.

MethodWhat it requiresStrengthLimitation
Manual tuningExperience and a safe test setupWorks on any plantSlow, depends on the operator
Ziegler-Nichols ultimate gainDriving the loop to sustained oscillationSimple formulasAggressive, about 25% overshoot or more
Relay autotuningRelay test that induces a limit cycleAutomated, controlled amplitudeAssumes a fairly simple plant
Model-based (IMC, lambda)Identified plant modelExplicit robustness trade-offModel quality limits results
Optimization-basedSimulation and a cost functionHandles multiple objectivesRequires accurate simulation
PID tuning approaches

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.

SymptomCauseFix
Large overshoot after saturationIntegral windup while the actuator is at its limitClamping or back-calculation anti-windup
Jittery, hot motorDerivative gain amplifying sensor noiseFilter the derivative, reduce Kd
Slow creep near the targetStatic friction and deadbandFriction feedforward, small integral boost
Good at one pose, poor at anotherInertia or load varies with configurationGain scheduling or model-based feedforward
Limit cycle around the setpointGear backlash or quantized sensorDeadband on error, better feedback resolution
Symptoms, causes and fixes

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.

ApproachModel neededHandles constraintsTypical use in robots
PIDNoOnly through saturation logicSingle-axis loops in drives and flight controllers
PID with feedforwardApproximate dynamicsNoFast trajectory tracking of manipulator joints
State feedback (LQR)Linear state-space modelNoBalancing robots, coupled axes
Model predictive controlPredictive modelYes, explicitlyLegged locomotion, vehicle motion
PID and related controllers

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.