explainer
Feedback control: measure speed and correct the error
Explore feedback control with a robot joint speed model. Compare proportional correction with feedforward alone, calculate steady error, and test disturbances, sensor bias, and torque limits.
What you will learn
- Trace how a speed measurement changes a joint torque command.
- Calculate the response and steady error of a proportional speed controller.
- Separate true tracking error from error in a biased sensor reading.
- Check whether a torque limit makes a target speed physically feasible.
- Compare a simulated response with a piecewise analytical solution.
Before you start
A robot joint slows when an unexpected load pushes against it. A controller can measure that slower speed and ask the motor for more torque. The changed motion then produces a new measurement.
That repeated use of measured behavior is feedback control. This lesson follows one proportional speed controller and makes each part of the correction visible.
Build a feedback control loop around a measurement
Start with a target speed, called the reference r. A sensor reports a measured speed y. The controller compares them through the measured error e = r − y.
- Measure the joint speed.
- Compare the measurement with the reference.
- Change the torque according to the error.
- Use the next measurement to update the correction.
Lynch and Park's control overview describes this flow from sensors through controllers and actuators back to robot motion. Their overview also distinguishes physical disturbances from sensor errors. Both enter this experiment through separate controls.
Here the controller acts continuously in time. The numerical solver approximates that continuous response; its integration step is not a digital controller's sampling interval.
Open-loop and closed-loop control compares a scheduled position move with a controller that uses position measurements. It shows when a calibrated command works by itself and how initial error, disturbances, and sensor bias change the result.
Describe the joint that receives the torque
The physical system under control is often called the plant. Use a horizontal joint with constant inertia J, viscous resistance Bω, and applied actuator torque τ. A separate signed torque d represents an external disturbance.
J dω/dt = τ − Bω + d
Positive torque increases the chosen positive joint angle. Positive d assists positive rotation; negative d opposes it. The disturbance keeps its specified sign even if the joint reverses.
| Quantity | Value or meaning |
|---|---|
| J | 0.5 kg·m² |
| B | Actual viscous coefficient, default 0.5 N·m·s/rad |
| B̂ | Controller's damping estimate, fixed at 0.5 N·m·s/rad |
| r | Target speed, +2 rad/s from time zero |
| Initial ω | 0 rad/s |
| d | Zero before 2 s, then the selected signed disturbance |
This model controls speed. A joint holding +2 rad/s keeps changing its angle. Gravity, friction at rest, motor current dynamics, and elastic motion do not enter this single-state model.
Add a correction to the predicted torque
At a constant target speed with no disturbance, the model predicts a holding torque τff = B̂r. That feedforward term is 1 N·m here. It uses the controller's estimate of B.
Let a constant sensor bias b add to the true speed: y = ω + b. The proportional controller adds K times the measured error, then clips the total request to the actuator's torque range.
y = ω + b
τ request = B̂r + K(r − y)
τ = clamp(τ request, −τ limit, +τ limit)
K has units N·m·s/rad. With K positive, a lower measured speed creates a larger torque request. A higher measured speed reduces the request. This sign makes the correction negative feedback around speed.
The comparison joint uses the same feedforward term and torque limit, with K = 0. Its torque never changes in response to the speed measurement. With zero gain, the two experiment trajectories agree exactly.
The block diagrams lesson follows reference, disturbance, and sensor signals through separate paths. Its loop algebra shows why changing a summing sign changes the closed-loop dynamics.
Feedforward does not include an impulse to achieve the speed step instantly. Finite inertia and bounded torque mean the actual speed starts at zero and changes continuously.
Solve the speed response between input changes
Assume the torque request stays within the limit. Substitute the controller into the physical equation while r, d, and b remain constant:
J dω/dt = B̂r + K(r − b) + d − (B + K)ω
ω∞ = [B̂r + K(r − b) + d] / (B + K)
T = J / (B + K)
ω(t) = ω∞ + [ω(t₀) − ω∞] exp[−(t − t₀) / T]
The symbol ω∞ means the speed approached if these inputs stay fixed. T is the time constant. With J positive, B positive, and K nonnegative, T is positive and the distance from that equilibrium decays exponentially.
Modern Robotics' first-order error lesson explains this exponential behavior and the roughly four-time-constant settling rule. Here that rule measures settling near the current equilibrium, which can differ from the target.
Step response characteristics defines rise time, overshoot, and settling time for a model that can oscillate. Its experiment separates settling near the final value from eliminating error relative to the reference.
Increasing K shortens the unsaturated time constant in this model. This scalar system cannot produce a sustained oscillation under fixed inputs. Torque clipping changes the response formula, but each constant-input segment still approaches its unique equilibrium monotonically because its acceleration decreases with speed.
Real controllers can excite delays, flexible joints, or actuator dynamics. Those effects require additional states or timing models. This experiment cannot establish a safe gain for a physical robot.
Calculate the error that remains
Subtract the unsaturated steady speed from the reference. The true steady error is:
r − ω∞ = [(B − B̂)r − d + Kb] / (B + K)
This expression separates three causes of error: damping mismatch, external torque, and sensor bias. With a matched model, no disturbance, and no bias, the steady error is zero. During acceleration, a temporary error still supplies the extra torque needed to speed up.
With a persistent opposing disturbance and zero bias, proportional control needs a positive error to maintain its extra torque. A finite K generally leaves a residual. Increasing K reduces that disturbance error while the actuator remains unsaturated.
PID control adds integral action to maintain a correction after the measured error reaches zero. Compare P, PI, PD, and PID responses to see how error memory and damping change the motion.
For open loop within its torque limit, the steady speed is (B̂r + d)/B. The model uncertainty lesson explores why the controller's prediction can differ from the plant. Feedback reacts to the resulting measurement error without first identifying which physical parameter changed.
Follow a disturbance through the loop
Use the defaults: J = 0.5, B = B̂ = 0.5, K = 1.5, r = 2, and b = 0, with a 5 N·m limit. At rest, the controller requests 1 + 1.5 × 2 = 4 N·m. The initial acceleration is 4/0.5 = 8 rad/s².
Before 2 s, the equilibrium is 2 rad/s and the time constant is 0.5/(0.5 + 1.5) = 0.25 s. The exact speed just before the disturbance is 2(1 − exp(−8)) = 1.999329 rad/s.
At 2 s, d changes from zero to −0.5 N·m. Speed stays continuous. The new equilibrium becomes:
ω∞ = (1 + 3 − 0.5) / 2 = 1.75 rad/s
τ∞ = 1 + 1.5(2 − 1.75) = 1.375 N·m
τ∞ − Bω∞ + d = 1.375 − 0.875 − 0.5 = 0
The 0.25 rad/s error maintains a 0.375 N·m correction. The joint also loses less torque to viscous resistance at its slower speed. Together those changes balance the new load.
At 4 s, the exact piecewise response gives 1.750084 rad/s with feedback and 1.098704 rad/s with feedforward alone. The open-loop speed eventually approaches 1 rad/s. These finite-time numbers provide a direct check on the replay.
Separate measured error from true error
Choose the sensor-bias preset, which removes the disturbance and adds b = +0.25 rad/s. The sensor reads 0.25 rad/s above the true speed. The controller uses that reading without knowing the bias.
The steady true speed is (1 + 1.5 × 1.75)/2 = 1.8125 rad/s. The measured speed is 2.0625 rad/s. That gives a true error of +0.1875 rad/s and a measured error of −0.0625 rad/s.
The small negative measured error reduces the torque below the nominal 1 N·m. The plant needs only 0.5 × 1.8125 = 0.90625 N·m to sustain that slower motion, so the torque balance agrees.
A larger gain gives the measurement more influence. With finite bias and no saturation, true speed approaches r − b as K grows. An accurate-looking measurement alone cannot establish accurate physical motion; calibration or an independent reference must check the sensor.
Check whether the actuator can hold the target
Set the actual speed to r and acceleration to zero in the plant equation. The required target-holding torque is τ required = Br − d. Holding the target is physically feasible in this model only when its magnitude is at most the torque limit.
The default final load requires 0.5 × 2 − (−0.5) = 1.5 N·m. The 5 N·m actuator can supply it, although the proportional controller settles with an error. Physical feasibility does not guarantee that a particular controller reaches the target.
Now choose the insufficient-torque preset, with a 0.75 N·m limit. At the final load, even the maximum positive torque supports only (0.75 − 0.5)/0.5 = 0.5 rad/s. Raising K increases the request but cannot raise the applied torque above 0.75 N·m.
Clipping can also be temporary. With K = 4, no disturbance, and the 5 N·m limit, the initial request is 9 N·m. The applied torque stays at 5 until speed reaches 1 rad/s, after about 0.105361 s, then the request reenters the available range.
Here the actuator realizes the clipped torque instantly. Read actuator dynamics to add current rise and gearing, and joint flexibility to add elastic motion. The simple torque clamp does not model a motor's full operating envelope.
Compare the controllers in the experiment
The experiment runs two copies of the same physical joint. Both receive the same reference, damping, disturbance, and actuator limit. Only one adds the proportional correction from its measured speed.
- Start with the opposing disturbance and compare the two speed curves after 2 s.
- Choose higher actual damping to test an incorrect feedforward prediction.
- Add sensor bias and compare measured speed with true speed.
- Lower the torque limit and inspect the requested and applied torques separately.
- Set K to zero and check that both trajectories coincide.
The replay uses fourth-order Runge–Kutta with a 0.01 s integration step. It holds the old disturbance throughout every stage of the interval ending at 2 s. The next interval uses the new disturbance, so the solver never averages the two sides of that input jump.
At exactly 2 s, the readouts show the new disturbance and the continuous speed. The steady-speed and feasibility readouts always use the final load, including when the cursor is before the step. The analytical solution above checks the smooth intervals; a smaller integration step also checks numerical sensitivity near torque-clipping transitions.
Reproduce the speed response in Python
This standard-library example repeats the four-second replay. It uses the same constant disturbance within each RK4 step, including the last stage. The first 200 steps have zero disturbance; the next 200 use d.
def response(K, B, d, bias, limit):
J, target, feedforward, h = 0.5, 2.0, 1.0, 0.01
speed, open_speed = 0.0, 0.0
def applied(w, gain):
request = feedforward + gain * (target - w - bias)
return max(-limit, min(limit, request))
def advance(w, gain, load):
def rate(value):
return (applied(value, gain) - B * value + load) / J
a = rate(w)
b = rate(w + h * a / 2)
c = rate(w + h * b / 2)
e = rate(w + h * c)
return w + h * (a + 2*b + 2*c + e) / 6
for index in range(400):
load = 0.0 if index < 200 else d
speed = advance(speed, K, load)
open_speed = advance(open_speed, 0.0, load)
return speed, open_speed, speed + bias, applied(speed, K)
cases = [
("disturbance", 1.5, 0.5, -0.5, 0.0, 5.0),
("matched", 1.5, 0.5, 0.0, 0.0, 5.0),
("mismatch", 1.5, 1.0, 0.0, 0.0, 5.0),
("bias", 1.5, 0.5, 0.0, 0.25, 5.0),
("limited", 1.5, 0.5, -0.5, 0.0, 0.75),
("zero gain", 0.0, 0.5, -0.5, 0.0, 5.0),
]
for label, *parameters in cases:
w, open_w, measured, torque = response(*parameters)
print(f"{label}: speed={w:.6f}; open={open_w:.6f}; measured={measured:.6f}; torque={torque:.6f}")
Expected output:
disturbance: speed=1.750084; open=1.098704; measured=1.750084; torque=1.374875
matched: speed=2.000000; open=1.963369; measured=2.000000; torque=1.000000
mismatch: speed=1.600000; open=0.999665; measured=1.600000; torque=1.600000
bias: speed=1.812500; open=1.963369; measured=2.062500; torque=0.906250
limited: speed=0.607862; open=0.607862; measured=0.607862; torque=0.750000
zero gain: speed=1.098704; open=1.098704; measured=1.098704; torque=1.000000
Values round to six decimal places. A printed 2.000000 rad/s can still have a small finite-time error; the matched feedback response at 4 s remains about 0.000000225 rad/s below the target.
Try it yourself
Exercise 1: increase the gain under the same final load
Keep the default final disturbance of −0.5 N·m and zero sensor bias. Set K to 3.5, with the same J, B, B̂, reference, and 5 N·m limit. Find the final steady speed, true error, applied torque, and unsaturated time constant. Does the initial torque request stay within the limit?
Check your answer: The steady speed is (1 + 3.5 × 2 − 0.5)/(0.5 + 3.5) = 1.875 rad/s. The true error is 0.125 rad/s. The steady torque is 1 + 3.5 × 0.125 = 1.4375 N·m, within the limit.
The unsaturated time constant is 0.5/4 = 0.125 s. At rest the initial request is 1 + 3.5 × 2 = 8 N·m, so the actuator clips it to 5 N·m. The unsaturated exponential formula does not describe that initial clipped interval.
Exercise 2: compare a sensor offset with a torque shortage
Use the sensor-bias preset: K = 1.5, B = B̂ = 0.5, b = +0.25 rad/s, and no disturbance. Calculate the steady true and measured speeds. Then remove the bias, restore d = −0.5 N·m, and lower the torque limit to 0.75 N·m. Can the actuator hold +2 rad/s in that second case?
Check your answer: The first case gives a true speed of 1.8125 rad/s and a measured speed of 2.0625 rad/s. True error is +0.1875 rad/s, while measured error is −0.0625 rad/s. The sensor reading and physical tracking tell different stories.
The second case needs 1.5 N·m to hold the target, exceeding the 0.75 N·m limit. Maximum applied torque gives a final speed of 0.5 rad/s under that load. More proportional gain cannot supply the missing torque.
Sources and further study
- Modern Robotics: Control System Overview explains the sensor-controller-actuator loop and the simplifying assumptions behind continuous robot control models.
- Modern Robotics: First-Order Error Dynamics derives exponential convergence, time constants, and settling behavior for a stable first-order equation.
- Modern Robotics: Motion Control with Velocity Inputs, Part 1 introduces proportional correction and finite-gain tracking error. Its example commands velocity to control position; this lesson commands torque to control speed.
Continue with model uncertainty and check which physical errors your feedback signal can reveal. A correction can improve motion while leaving the cause of the error unresolved.