The problem
This servo, G(s) = 1/(s(s+1)(s+2)), was tuned in the lesson "Choosing the gain for a target damping ratio". K = 1.037 puts the closed-loop pair at −0.333 ± 0.577j, damping ratio 0.5. The transient is good.
Now ask the arm to follow a ramp: the camera pans at a steady 1 rad/s. The arm matches the speed but trails behind. The error settles at 1.93 rad, almost two radians late. Far too much.
For this loop the ramp error is 1/Kv. The velocity constant Kv = lim s→0 of s·K·G(s) = K/2 = 0.519. It is the low-frequency gain on the Bode plot. Ten times less error needs Kv ten times bigger, about 5.
The obvious fix is ten times the gain, K = 10.37. Watch the poles: the pair slides across the imaginary axis to +0.167 ± 1.756j. The loop is unstable, as it is for any K above 6. Gain alone cannot do both jobs.
Add a lag
Instead, add a lag compensator: Gc(s) = (s + 0.05)/(s + 0.005). It is one zero and one pole, the pole ten times closer to the origin. At s = 0 its gain is 0.05/0.005 = 10; at high frequency it is 1.
Both sit very close to the origin, far from the pair we care about. Seen from the old design point, they look almost the same distance and direction: together they scale the loop by 0.968 and turn it just −3.5°. The locus barely moves.
Find where the ζ = 0.5 ray crosses the new locus: s = −0.314 ± 0.544j, with K = 1.008. Now Kv = K × 10 / 2 = 5.04, 9.7 times bigger. The damping ratio is still 0.5; the far pole sits at −2.32.
Check it
On the Bode plot the lag lifts the low-frequency gain by 20 dB: the factor of 10 in Kv. Its zero sits about a decade below crossover, so crossover barely moves (0.459 to 0.451 rad/s) and phase margin drops only from 52° to 47°.
Run the ramp again. At first the error follows the old curve, because the lag acts only at low frequency. Then it drains away and settles at 0.198 rad, about ten times smaller than before.
The price is a slow tail. The lag leaves a closed-loop pole at −0.055, right beside its zero, so part of the error fades like e^(−0.055t): an 18 s time constant. Lag buys accuracy; lead buys speed.
The working
# step 1/10 · start # about: Command: ramp, Compare (error), Gain dial K, Plant G(s), Arm angle y, locus without lag, closed-loop poles plant G(s) = 1 / (s(s + 1)(s + 2)) gain K = 28/27 = 1.037 closed-loop poles -0.333 ± 0.577j, -2.333 damping ratio ζ = 0.5 The step response is fine. This lesson asks a different question: how well does the arm follow a command that keeps moving?
The plant 1/(s(s+1)(s+2)) is a standard textbook servo model with round numbers. The loci are the exact roots of the closed-loop polynomial for many values of K, the Bode curves are |K·Gc(jω)·G(jω)| point by point, and the ramp errors are integrated from the closed loop (RK4, 0.01 s steps). The Python uses only the standard library. With python-control installed, ct.bode_plot and ct.root_locus_plot on ct.tf([1, 0.05], [1, 3.005, 2.015, 0.01, 0]) draw the compensated loop.