Skip to main content
Robotics & Embodied AI

⏱ About 15 min15 XP

Feedback Control

You learned in Lesson 4 that closed-loop control measures error and sends a corrective command. But how exactly should the controller compute that command? If you always apply the same correction for any nonzero error, you will overshoot. If you apply a tiny correction no matter how large the error, convergence will be painfully slow. The science of computing good corrections from measured error is called control theory, and its most widely used recipe is the PID controller.

The PID Controller: Three Sources of Correction

PID stands for Proportional, Integral, Derivative. These are three separate ways of looking at the error signal, each capturing a different aspect of what the system is doing and what correction is appropriate. The final command sent to the actuator is the sum of all three contributions. A PID controller is by far the most common feedback controller in engineering. It runs in virtually every industrial robot joint, in the autopilot of commercial aircraft, in the cruise control of your car, and in the stabilizer of a smartphone gimbal. Understanding what each term does is the gateway to understanding how controlled machines behave.

PID at a Glance

P responds to how big the error is right now. I responds to how long the error has been building up. D responds to how fast the error is changing. Together, they produce a command that reaches the target quickly, holds it accurately, and dampens oscillation.

Proportional: React to Current Error

The proportional term multiplies the current error by a constant called the proportional gain (often written Kp). A large error produces a large correction; a small error produces a small correction. The relationship is direct: double the error, double the response. Imagine a robot arm that should be at 45 degrees but is currently at 30 degrees — error is 15 degrees. With Kp = 2, the proportional command is 2 times 15 = 30 units of drive signal. As the arm approaches 45 degrees, the error shrinks, so the drive signal shrinks too, slowing the arm as it approaches target. This natural deceleration helps prevent overshoot. If Kp is set too high, the correction at even a small error is enormous, causing the arm to fly past the target. If Kp is too low, the arm crawls toward the target and may never quite reach it because even with a small remaining error the drive signal is too weak to overcome friction.

Integral: Correct Accumulated Error

Sometimes a robot joint settles at a position that is persistently a little off — not zero error but a stable small error called steady-state error. The proportional term is too weak to overcome friction at this small error, so the arm just sits slightly wrong forever. The integral term fixes this by adding up (integrating) all the error over time. Even if the current error is tiny, if it has been sitting at that small value for many cycles, the integral grows until it is large enough to push through the friction and drive the error to zero. Think of the integral term as patience. It is not alarmed by a large sudden error — it cares about persistent, nagging error that the proportional term alone cannot eliminate. The integral gain constant is called Ki.

Integral Windup

If the robot is blocked from moving — say, the joint is mechanically stuck — the integral term keeps accumulating even though no correction is happening. When the blockage is released, the giant accumulated integral causes a massive overshoot. This is called integral windup and must be handled by limiting how large the integral is allowed to grow.

Derivative: Predict and Dampen

The derivative term looks at the rate of change of error — how fast is the error shrinking or growing? If the error is shrinking rapidly, the joint is moving fast toward the target and is likely to overshoot unless the drive signal is reduced. The derivative term detects this rapid change and applies a braking force, damping the motion before the overshoot happens. This is why derivative control is sometimes called anticipatory control — it reacts not to what the error is, but to what the error is doing, and brakes the system before problems occur. The derivative gain constant is Kd. Derivative control is sensitive to sensor noise. If the position sensor is noisy — outputting slightly different readings from moment to moment — the derivative term will see rapid apparent changes in error and produce erratic, jittery commands. Engineers often filter the sensor signal before feeding it to the derivative term.

Flashcards — click each card to reveal the answer

Tuning: Finding the Right Gains

Setting Kp, Ki, and Kd to values that produce good behavior is called tuning. Too much Kp causes oscillation. Too much Ki causes slow, winding overshoot. Too much Kd causes jitter from noise. Finding the right balance for a specific robot in a specific environment is partly science and partly craft — robotics engineers tune controllers by running experiments, watching how the system responds, and adjusting gains systematically. A common starting approach is to set Ki and Kd to zero and increase Kp until the system just starts to oscillate. Then back Kp off slightly, add a small amount of Kd to damp the oscillation, and finally add a small Ki to eliminate any steady-state error. More systematic methods exist — like the Ziegler-Nichols rules and model-based design — but the manual approach builds intuition that no algorithm can replace.

Match each PID term to the type of error it primarily addresses.

Terms

Proportional term
Integral term
Derivative term
High Kp (too high)
Low Kp (too low)

Definitions

Causes the system to approach the target sluggishly and leave steady-state error
Responds to the size of the current error at this instant
Causes the output to oscillate past the target repeatedly
Responds to how rapidly the error is currently changing
Responds to how long and how much error has accumulated over time

Drag terms onto their definitions, or click a term then click a definition to match.

A robot arm settles at 43 degrees when commanded to 45 degrees and stays there even after many seconds. The proportional controller is not driving it further. Which PID term is best suited to eliminate this persistent 2-degree error?

The derivative term of a PID controller is most sensitive to which condition?

Simulate a P Controller by Hand

  1. Step 1: Choose a target of 100 (imagine this is a desired joint angle in tenths of a degree). Set starting actual position to 0. Set Kp = 0.4.
  2. Step 2: Each round, compute: error = target - actual. command = Kp times error. new actual = actual + command.
  3. Step 3: Fill in a table with columns: Round | Actual | Error | Command. Run for 8 rounds.
  4. Step 4: Observe: does the actual position converge to 100? How many rounds does it take to get within 5 of the target?
  5. Step 5: Repeat with Kp = 1.5. Does it converge faster? Does it overshoot (go past 100)?
  6. Step 6: Write one sentence describing the trade-off between a high and a low Kp.