State Feedback, Observers & LQR
Modern control in state space. Learn controllability and observability, pole placement by state feedback (and Ackermann's formula), reference tracking with N̄ or integral action, state observers (Luenberger) and the separation principle, and optimal LQR design with the Q/R trade-off — with a DC-motor servo designed and simulated in Python.
Classical PID uses only the output error. State-space methods use every internal state (position and velocity, temperature and heat flow…) and can place all closed-loop poles exactly where you want — for multiple inputs and outputs too.
When states cannot be measured, an observer estimates them from the model and measurements. Robotics, aerospace, power electronics and automotive systems use these methods daily.
An analogy
State feedback is like a pilot who watches not only altitude but also climb rate and pitch, correcting all of them together. An observer is the co-pilot who estimates the ones without a gauge from what the others show.
States and state feedback
The state is the minimum set of variables that, with future inputs, determines the future (for a motor: angle and speed). Feeding back u = −Kx with a gain for every state lets you move every closed-loop pole — if the system is controllable.
Controllability and observability
Controllable: the input can drive the state anywhere (rank test on [B AB …]). Observable: the state can be reconstructed from the outputs (rank test on [C; CA; …]). An uncontrollable unstable mode can never be stabilised; an unobservable one cannot be estimated.
Tracking and integral action
State feedback regulates to zero. For reference tracking, scale the reference with N̄ (exact only if the model is exact) or, more robustly, augment the state with the integral of the tracking error so the design includes integral action — the state-space version of PI.
Observers, separation and LQR
A Luenberger observer runs a copy of the model corrected by the output error; choose observer poles 2–6× faster than the controller poles. The separation principle says controller and observer can be designed independently. LQR picks K by minimising a quadratic cost instead of choosing poles: large Q makes states converge fast, large R saves actuator effort. LQR guarantees ≥ 60° phase margin and infinite gain margin (with full state). Combining LQR with a Kalman filter gives LQG.
Formulas
- Controllability:
rank [B AB … Aⁿ⁻¹B] = n - Observability:
rank [C; CA; …; CAⁿ⁻¹] = n - Closed loop:
ẋ = (A − BK)x + BN̄r; poles = eig(A − BK) - Ackermann:
K = [0 … 0 1]·𝒞⁻¹·φ(A) - Observer:
x̂̇ = Ax̂ + Bu + L(y − Cx̂); error poles = eig(A − LC) - LQR cost:
J = ∫(xᵀQx + uᵀRu)dt; K = R⁻¹BᵀP, AᵀP + PA − PBR⁻¹BᵀP + Q = 0
Worked example: Gain by coefficient matching
Given: Motor a = 10, b = 50; desired s² + 28s + 400
Find: K.
- b·k₁ = 400 → k₁ = 8
- a + b·k₂ = 28 → k₂ = 0.36
Answer: K = [8, 0.36]
Worked example: Controllability check
Given: A = [[0,1],[0,−10]], B = [0; 50]
Find: Controllable?
- AB = [50; −500]
- det [B AB] = 0·(−500) − 50·50 = −2500 ≠ 0
Answer: Yes (rank 2)
Worked example: Observer pole choice
Given: Controller poles at −14 ± j14.3
Find: Observer poles.
- 2–6× faster real part
Answer: e.g. −60 and −70
Pole placement for a DC-motor position servo
# Pole placement for a DC motor position servo x = [angle, speed]
# x' = [[0,1],[0,-a]] x + [[0],[b]] u, a = 10, b = 50
a, b = 10.0, 50.0
# Desired poles from zeta = 0.7, wn = 20 -> s^2 + 28 s + 400
z, wn = 0.7, 20.0
c1, c0 = 2 * z * wn, wn * wn
# closed-loop char. poly with u = -[k1 k2] x : s^2 + (a + b k2) s + b k1
k1 = c0 / b
k2 = (c1 - a) / b
print(f"K = [{k1:.3f}, {k2:.3f}] (char poly s^2 + {c1:.0f}s + {c0:.0f})")
# simulate step reference with Nbar = k1
dt, x1, x2, peak = 1e-4, 0.0, 0.0, 0.0
for n in range(int(1.0 / dt)):
u = k1 * 1.0 - (k1 * x1 + k2 * x2)
x1, x2 = x1 + dt * x2, x2 + dt * (-a * x2 + b * u)
peak = max(peak, x1)
print(f"step: final {x1:.4f} rad, overshoot {(peak-1)*100:.1f}% (theory 4.6%)")
# K = [8.000, 0.360] (char poly s^2 + 28s + 400)
# step: final 1.0000 rad, overshoot 4.6% (theory 4.6%)Matching coefficients of the closed-loop characteristic polynomial gives K directly for a 2-state system; Ackermann's formula or numerical tools (place, lqr in MATLAB/python-control) do the same for larger ones. The simulation confirms the designed 4.6% overshoot.
Common mistakes
- Wrong: Placing poles extremely far left. — Right: Fast poles need huge inputs and amplify noise.
- Wrong: Relying on N̄ for zero error. — Right: Add integral action for robustness.
- Wrong: Observer slower than the controller. — Right: Make observer poles faster.
Applications
- Robotics: State feedback of joint position and velocity.
- Aerospace: LQR/LQG autopilots and attitude control.
- Inverted pendulums & Segways: Balancing unstable systems.
- Power electronics: State-feedback inverter control.
Key takeaways
- u = −Kx places eig(A − BK).
- Check controllability and observability.
- Observers estimate unmeasured states.
- LQR balances state error vs control effort.
Going further
- LQG and loop transfer recovery: Recovering LQR robustness with a Kalman filter.
- H∞ state feedback: Worst-case disturbance attenuation.
- Nonlinear control: Feedback linearisation, sliding mode, backstepping.