A Proportional-Integral-Derivative (PID) Controller is the most widely used closed-loop control algorithm in robotics. It continuously measures an error \(e(t)\)βthe difference between the desired setpoint \(r(t)\) and the actual measured value \(y(t)\text{:}\)
Proportional Term (\(K_p \cdot e(t)\)) β Present Error: Pushes the brake or gas proportional to how far away you are. If you are far away, press hard on the gas; as you get closer, ease off.
Integral Term (\(K_i \int e(\tau) \, d\tau\)) β Past Accumulation: Accounts for persistent past error. If a slight uphill slope prevents the car from reaching the stop line despite \(K_p\text{,}\) error accumulates over time, gently building up extra throttle to nudge the car to the exact setpoint.
Derivative Term (\(K_d \cdot \frac{de(t)}{dt}\)) β Future Trend: Looks at how fast the error is changing (your approach speed). If you are closing in fast, \(\frac{de(t)}{dt}\) is strongly negative, applying resistance (braking) early to prevent overshooting the stop line.
Real-Life Example: You are driving toward a stop line 100 meters away. When you are far away (100 m error), you press the gas pedal down hard. As you get closer (10 m error), you ease off the pedal proportional to the remaining distance.
Robotic Limitation: If your robot encounters physical resistance (e.g., floor friction or gravity on an incline), the motor force generated by \(K_p \cdot e(t)\) eventually drops below the friction threshold. The robot stops before reaching the goal, leaving a persistent steady-state error.
Concept: Sums up past errors over time. If an error persistsβno matter how smallβthe integral accumulator steadily grows to push the system harder.
Real-Life Example: Imagine trying to hold a car steady on a steep hill using just the throttle. If you stop slightly short of your target mark because gravity is holding you back, the integral term notices: βWeβve been 0.5 meters short for 5 seconds now!β It ramps up extra engine torque to climb those last few centimeters and eliminate the gap completely.
Robotic Limitation: If \(K_i\) is tuned too high, it can accumulate too much momentum (called integral windup), causing the system to shoot past the goal before catching itself.
Real-Life Example: Even if you are 20 meters away from the stop line, if your speedometer says you are moving at 90 km/h, common sense tells you to slam on the brakes now to avoid crashing through the intersection. The derivative term measures this rapid closure rate (\(\frac{de}{dt}\)) and exerts an opposing counter-force to smooth out your arrival.
Subsubsection1.4.7.1Exercise 1.4.1: Tuning Proportional Gain (\(K_p\)) & Integral Gain (\(K_i\)) Simulation
Below is a 1D simulation of a robot attempting to reach \(x_{\text{goal}} = 10.0\) meters using proportional control (\(K_p\)) subject to steady friction.
Run the code with KP_VAL = 0.5 and KI_VAL = 0.0. Notice how physical friction halts the robot around \(x \approx 7.0\) m, leaving a persistent steady-state error.