Skip to the lesson
FixTheRobot Explore Robotics / Guidance, Navigation and Control / M4 State-Space and Optimal Control / M4-T4

Guidance, Navigation and Control · Theory · M4

M4-T4 — The Linear-Quadratic Regulator from Dynamic Programming

LQR trades the size of the errors against the size of the effort, and the answer is a matrix equation. Its gains come out with margins that a designer could not have placed by hand.

  • Lesson 4 of 6
  • Intermediate
  • Module 4: State-Space and Optimal Control
  • Theory
  • About 19 minutes to read

Pole placement asked you to choose the poles and showed that the choice is hard: the gains and the actuator demand are not visible from the poles. LQR turns the question round. You state what you care about, a limit for each state and a limit for the actuator, and an optimization finds the gain. This lesson derives it from the principle of optimality, gives the rule for turning limits into weights, and proves the unexpected gift that comes with it: a loop with at least 60° of phase margin and unlimited gain margin, guaranteed.

Learning objectives

After this lesson, you should be able to:

  • Derive the Riccati equation and the optimal gain from dynamic programming with a quadratic value function.
  • Choose the weights of a regulator from the largest acceptable value of each state and of the input (Bryson's rule).
  • Prove that an LQR loop has |1 + L| ≥ 1, and deduce its gain and phase margins.
  • Say when the guarantees hold and when they do not.

The intuition

UAV M5-T7: LQR control introduced the regulator for a quadrotor hover, with the weights found by trial, and Navigation M5-T6 used it to track a path. Both treat the Riccati equation as a tool. This lesson looks inside: where the equation comes from, how to set the weights from physical limits instead of by trial, and why the resulting loop is unusually robust.

What it optimizes

A regulator brings the state to zero. The faster it does so, the larger the actuator effort. LQR writes the compromise as a cost, accumulated over the whole motion:

J=∫0∞(xTQx+uTR u) dtJ = \int_0^\infty \bigl(\mathbf{x}^{\mathsf{T}}\mathbf{Q}\mathbf{x} + u^{\mathsf{T}}R\,u\bigr)\,dt. The first term charges for every state error, the second for every unit of control effort. The two matrices are the designer's statement of what matters. The remarkable fact is that the minimizing input is a linear feedback of the state, u=−Kxu = -\mathbf{K}\mathbf{x}, whose gain comes from one matrix equation.

Where the equation comes from

The argument is dynamic programming (the same principle that the Robot Learning track uses for value iteration). Define the value of a state as the smallest cost that can still be incurred starting from it. The principle of optimality says that whatever the first moment's input, the rest of the motion must be optimal from where it lands. Written for a small time step, that gives an equation in the value alone. For a linear model and a quadratic cost the value is a quadratic V=xTPxV = \mathbf{x}^{\mathsf{T}}\mathbf{P}\mathbf{x}, and the equation for P\mathbf{P} is the algebraic Riccati equation.

Weights from limits

The weights are scaled by Bryson's rule: take the reciprocal of the square of the largest acceptable value. If the position may be off by 1 m, the weight on it is 1/121/1^2; if the gimbal may swing 0.15 rad, the weight on the input is 1/0.152=44.41/0.15^2 = 44.4. Then every term of the cost equals 1 when its quantity is at its limit, and the weights say, in common units, how much each limit matters. For Hopper: position 1 m, velocity 1 m/s, pitch 0.2 rad, pitch rate 0.5 rad/s, gimbal 0.15 rad. The gain comes out as K=(0.150, 0.272, 1.658, 0.386)\mathbf{K} = (0.150,\ 0.272,\ 1.658,\ 0.386) with closed-loop poles at −5.87, −1.61 ± 1.25j and −1.16, found by no one placing anything.

The gift: margins

The loop gain of an LQR design, cut at the plant input, is L(s)=K(sI−A)−1BL(s) = \mathbf{K}(s\mathbf{I} - \mathbf{A})^{-1}\mathbf{B}. The Riccati equation forces it to satisfy ∣1+L(jω)∣≥1|1 + L(j\omega)| \ge 1 at every frequency. That inequality has a picture: the Nyquist curve never enters the disk of radius 1 centred on the critical point −1. Everything else follows from the geometry: the gain can be raised without limit and lowered to half, and the phase margin is at least 60°. No such guarantee comes with a design by pole placement.

Return difference of the LQR loop, ideal and with the gimbal servoTwo curves of the logarithm of the magnitude of one plus L against the logarithm of frequency. A dashed horizontal line marks zero, where the magnitude equals 1. The ideal LQR loop stays on or above the line at every frequency, touching it at high frequency. The loop with the 40 radians per second gimbal servo dips below the line around 10 to 20 radians per second, to a magnitude of 0.82, which is the peak sensitivity of 1.22.-0.500.511.522.5-0.500.511.52log10 of frequency (rad/s)log10 of |1 + L| |1 + L| = 1 ideal LQR: never below 1 with the servo: dips to 0.82
The return difference |1 + L| of Hopper's LQR loop. The ideal loop never goes below 1. With the 40 rad/s servo, which the design did not include, it dips to 0.82 near 10 to 20 rad/s.

LQR starts from what you care about and returns a gain whose loop cannot have small margins, provided the model it was designed on is the loop that is closed. The guarantee has conditions, and the last section of the lesson is about them.

Definitions

Cost JJ
The integral over time of the weighted state error and weighted input: J=∫0∞(xTQx+uTRu) dtJ = \int_0^\infty (\mathbf{x}^{\mathsf{T}}\mathbf{Q}\mathbf{x} + u^{\mathsf{T}}\mathbf{R}u)\,dt.
Weights Q\mathbf{Q} and R\mathbf{R}
Q⪰0\mathbf{Q} \succeq 0 (positive semidefinite) and R≻0\mathbf{R} \succ 0 (positive definite): the price of each state error and of the input.
Value function V(x)V(\mathbf{x})
The smallest cost still to be paid starting from state x\mathbf{x}; for LQR, V=xTPxV = \mathbf{x}^{\mathsf{T}}\mathbf{P}\mathbf{x}.
Return difference 1+L1 + L
With L=K(sI−A)−1BL = \mathbf{K}(s\mathbf{I} - \mathbf{A})^{-1}\mathbf{B} the loop gain cut at the plant input. Its magnitude is the distance from the Nyquist curve to −1, the inverse of the sensitivity.

For a stabilizable model with the weights above, the optimal input and its gain are:

The LQR solution
u=−Kx,K=R−1BTP,ATP+PA−PBR−1BTP+Q=0u = -\mathbf{K}\mathbf{x}, \quad \mathbf{K} = \mathbf{R}^{-1}\mathbf{B}^{\mathsf{T}}\mathbf{P}, \quad \mathbf{A}^{\mathsf{T}}\mathbf{P} + \mathbf{P}\mathbf{A} - \mathbf{P}\mathbf{B}\mathbf{R}^{-1}\mathbf{B}^{\mathsf{T}}\mathbf{P} + \mathbf{Q} = 0
P\mathbf{P} is the unique positive-semidefinite solution that makes A−BK\mathbf{A} - \mathbf{B}\mathbf{K} stable. The last equation is the algebraic Riccati equation, quadratic in P\mathbf{P}. The cost of starting at x0\mathbf{x}_0 is x0TPx0\mathbf{x}_0^{\mathsf{T}}\mathbf{P}\mathbf{x}_0.

Bryson's rule for the weights, with the largest acceptable value of each quantity written xi,max⁡x_{i,\max} and umax⁡u_{\max}:

Bryson's rule
Qii=1xi,max⁡2,R=1umax⁡2Q_{ii} = \frac{1}{x_{i,\max}^2}, \qquad R = \frac{1}{u_{\max}^2}
A starting point, not a final answer: it puts every term of the cost on the same footing, and the weights are then adjusted by looking at the result. Only the ratios of Q to R matter: multiplying both by the same factor does not change the gain.

The guarantee of the margins comes from an identity, the return-difference equality of Kalman, for a single input:

Return-difference equality
R ∣1+L(jω)∣2=R+BT(−jωI−AT)−1Q (jωI−A)−1B  ≥  RR\,\bigl|1 + L(j\omega)\bigr|^2 = R + \mathbf{B}^{\mathsf{T}}(-j\omega\mathbf{I} - \mathbf{A}^{\mathsf{T}})^{-1}\mathbf{Q}\,(j\omega\mathbf{I} - \mathbf{A})^{-1}\mathbf{B}\;\ge\; R
The second term is nonnegative because Q is positive semidefinite (it is a quadratic form in a vector and its conjugate). So the return difference is at least 1 in magnitude at every frequency.

Derivation: the Riccati equation, and why |1 + L| ≥ 1

The derivation has two parts: the optimal gain from dynamic programming, then the margin identity from the Riccati equation.

  1. V(x)=min⁡u[ xTQx dt+uTRu dt+V(x+x˙ dt) ]V(\mathbf{x}) = \min_u\left[\,\mathbf{x}^{\mathsf{T}}\mathbf{Q}\mathbf{x}\,dt + u^{\mathsf{T}}\mathbf{R}u\,dt + V(\mathbf{x} + \dot{\mathbf{x}}\,dt)\,\right]

    The principle of optimality: the cost from x\mathbf{x} is the cost of the next instant plus the optimal cost from where the state then is.

  2. 0=min⁡u[xTQx+uTRu+∇VT(Ax+Bu)]0 = \min_u\left[\mathbf{x}^{\mathsf{T}}\mathbf{Q}\mathbf{x} + u^{\mathsf{T}}\mathbf{R}u + \nabla V^{\mathsf{T}}(\mathbf{A}\mathbf{x} + \mathbf{B}u)\right]

    Expand V(x+x˙dt)V(\mathbf{x} + \dot{\mathbf{x}}dt) to first order in dtdt and divide by dtdt. In steady state the value does not change with time, which gives the Hamilton-Jacobi-Bellman equation.

  3. V=xTPx  ⇒  ∇V=2PxV = \mathbf{x}^{\mathsf{T}}\mathbf{P}\mathbf{x} \;\Rightarrow\; \nabla V = 2\mathbf{P}\mathbf{x}

    Guess that the value is a quadratic form. A linear model with a quadratic cost makes this consistent, as the next steps confirm.

  4. 2Ru+2BTPx=0  ⇒  u=−R−1BTPx2\mathbf{R}u + 2\mathbf{B}^{\mathsf{T}}\mathbf{P}\mathbf{x} = 0 \;\Rightarrow\; u = -\mathbf{R}^{-1}\mathbf{B}^{\mathsf{T}}\mathbf{P}\mathbf{x}

    Set the derivative of the bracket with respect to uu to zero. The optimal input is linear in the state.

  5. xT(Q+ATP+PA−PBR−1BTP)x=0\mathbf{x}^{\mathsf{T}}\bigl(\mathbf{Q} + \mathbf{A}^{\mathsf{T}}\mathbf{P} + \mathbf{P}\mathbf{A} - \mathbf{P}\mathbf{B}\mathbf{R}^{-1}\mathbf{B}^{\mathsf{T}}\mathbf{P}\bigr)\mathbf{x} = 0

    Put the optimal input back into the bracket. For this to hold for every state, the matrix in brackets must vanish: the Riccati equation.

The margin identity

  1. P(jωI−A)+(−jωI−AT)P=−(ATP+PA)=Q−PBR−1BTP\mathbf{P}(j\omega\mathbf{I} - \mathbf{A}) + (-j\omega\mathbf{I} - \mathbf{A}^{\mathsf{T}})\mathbf{P} = -(\mathbf{A}^{\mathsf{T}}\mathbf{P} + \mathbf{P}\mathbf{A}) = \mathbf{Q} - \mathbf{P}\mathbf{B}\mathbf{R}^{-1}\mathbf{B}^{\mathsf{T}}\mathbf{P}

    The jωPj\omega\mathbf{P} terms cancel, and the Riccati equation gives the right side.

  2. BT(−jωI−AT)−1[⋯ ](jωI−A)−1B\mathbf{B}^{\mathsf{T}}(-j\omega\mathbf{I} - \mathbf{A}^{\mathsf{T}})^{-1}\bigl[\cdots\bigr](j\omega\mathbf{I} - \mathbf{A})^{-1}\mathbf{B}

    Multiply by BT(−jωI−AT)−1\mathbf{B}^{\mathsf{T}}(-j\omega\mathbf{I} - \mathbf{A}^{\mathsf{T}})^{-1} on the left and (jωI−A)−1B(j\omega\mathbf{I} - \mathbf{A})^{-1}\mathbf{B} on the right. The terms with P\mathbf{P} become BTP(jωI−A)−1B=R L(jω)\mathbf{B}^{\mathsf{T}}\mathbf{P}(j\omega\mathbf{I} - \mathbf{A})^{-1}\mathbf{B} = R\,L(j\omega), its conjugate, and L∗RLL^*RL.

  3. R+R L+L∗R+L∗R L=R+BT(⋯ )−1Q(⋯ )−1BR + R\,L + L^{*}R + L^{*}R\,L = R + \mathbf{B}^{\mathsf{T}}(\cdots)^{-1}\mathbf{Q}(\cdots)^{-1}\mathbf{B}

    Collect and add RR to both sides. The left side factors as R (1+L)∗(1+L)R\,(1 + L)^{*}(1 + L).

  4. ∣1+L(jω)∣2≥1|1 + L(j\omega)|^2 \ge 1

    The extra term on the right is v∗Qv≥0\mathbf{v}^{*}\mathbf{Q}\mathbf{v} \ge 0 for a vector v\mathbf{v}, so the right side is at least RR.

The margins that follow

  1. L real and negative  ⇒  ∣1+L∣≥1  ⇒  L≤−2L \text{ real and negative} \;\Rightarrow\; |1 + L| \ge 1 \;\Rightarrow\; L \le -2

    On the negative real axis the curve cannot enter the interval (−2, 0): the points there are less than 1 from −1.

  2. k L=−1 needs k=−1/L≤1/2 or no crossing at allk\,L = -1 \text{ needs } k = -1/L \le 1/2 \text{ or no crossing at all}

    Scaling the gain by kk moves the curve radially. A crossing of −1 can happen only for k≤1/2k \le 1/2: the gain can be raised without limit and cut to one half.

  3. ∣1+ej(PM−180∘)∣=2sin⁡PM2≥1  ⇒  PM≥60∘|1 + e^{j(\mathrm{PM} - 180^\circ)}| = 2\sin\tfrac{\mathrm{PM}}{2} \ge 1 \;\Rightarrow\; \mathrm{PM} \ge 60^\circ

    At the crossover the curve is on the unit circle at an angle PM from −1, at distance 2sin⁡(PM/2)2\sin(\mathrm{PM}/2) from it. That must be at least 1.

The Riccati equation forces the return difference to be at least 1 everywhere, and geometry turns that into at least 60° of phase margin and a gain margin from 1/2 to infinity. The guarantee is for the loop cut at the plant input, with the model the weights were designed for.

A worked example

Design the regulator for Hopper's lateral channel and examine it.

  1. Weights. Bryson's rule with limits of 1 m, 1 m/s, 0.2 rad and 0.5 rad/s for the states and 0.15 rad for the gimbal gives Q=diag⁡(1,1,25,4)\mathbf{Q} = \operatorname{diag}(1, 1, 25, 4) and R=44.4R = 44.4.
  2. Solve. The Riccati equation (the library solves it by the matrix sign function, checked against SciPy to 10⁻¹³) gives K=(0.150, 0.272, 1.658, 0.386)\mathbf{K} = (0.150,\ 0.272,\ 1.658,\ 0.386) and closed-loop poles at −5.87, −1.61 ± 1.25j and −1.16. A 1 m position error alone calls for 0.15 rad of gimbal, exactly the limit: Bryson's rule did what it says.
  3. The identity. The smallest value of ∣1+L(jω)∣|1 + L(j\omega)| over all frequencies is 1.000018: at the bound, as the theorem says.
  4. Margins. The loop crosses 0 dB at 10.22 rad/s with a phase margin of 71.3°, above the guaranteed 60°, and a delay margin of 0.122 s. It stays stable for any increase of gain and for a decrease down to 0.19 of the design gain, better than the guaranteed 0.5.
  5. Add the servo. The design did not include the 40 rad/s gimbal servo. With it the crossover is 9.93 rad/s, the phase margin 56.8° (below 60°: the guarantee does not cover the servo), the delay margin 0.100 s and the peak of the sensitivity 1.22. The servo costs arctan⁡(10.2/40)=14∘\arctan(10.2/40) = 14^\circ at the crossover, and 71.3−14=5771.3 - 14 = 57 predicts the result.
  6. Optimality. The cost of starting 1 m off is P11=1.81P_{11} = 1.81 for LQR (and the Lyapunov equation of the closed loop gives the same, 1.81). The pole placement of the last lesson with poles at (−1, −1.5, −3, −4) costs 1.90, 5% more, and the faster placement (−2, −3, −6, −8) costs 5.93, more than three times as much.
import cmath, math
import gnckit as g

gr, lam, b = 9.81, 0.7, 19.62
A = [[0, 1, 0, 0], [0, 0, gr, 0], [0, 0, 0, 1], [0, 0, lam ** 2, 0]]
B = [0, gr, 0, b]
x_max, v_max, th_max, q_max, d_max = 1.0, 1.0, 0.2, 0.5, 0.15       # Bryson's rule: the largest acceptable value of each quantity
Q = [[1 / x_max ** 2, 0, 0, 0], [0, 1 / v_max ** 2, 0, 0], [0, 0, 1 / th_max ** 2, 0], [0, 0, 0, 1 / q_max ** 2]]
R = [[1 / d_max ** 2]]
K, P = g.lqr(A, [[v] for v in B], Q, R)
K = K[0]
print('K =', [round(k, 4) for k in K])
poles = g.mat_eigvals(g.ss_closed_loop(A, B, K))
print('closed-loop poles:', sorted((round(complex(p).real, 2), round(complex(p).imag, 2)) for p in poles))

L = lambda w: g.ss_freq(A, B, K, 0.0, w)                                # loop broken at the plant input
ws = g.logspace(-2, 3, 4000)
print(f'smallest |1 + L| over all frequencies: {min(abs(1 + L(w)) for w in ws):.6f} (the theorem says at least 1)')
wc = [ws[i] for i in range(len(ws) - 1) if (abs(L(ws[i])) - 1) * (abs(L(ws[i + 1])) - 1) < 0][0]
pm = 180 + math.degrees(cmath.phase(L(wc)))
print(f'ideal LQR loop: crossover {wc:.2f} rad/s, phase margin {pm:.1f} deg (at least 60), delay margin {math.radians(pm) / wc:.3f} s')
lo = min(k for k in [10 ** (i / 100) for i in range(-300, 100)] if max(complex(p).real for p in g.mat_eigvals(g.ss_closed_loop(A, B, [k * c for c in K]))) < 0)
print(f'it stays stable for any gain increase and for a gain decrease down to x{lo:.2f} (the theorem guarantees x0.5)')

Ls = lambda w: L(w) / (1 + 1j * w / 40)                                  # the same loop with the 40 rad/s gimbal servo
wc = [ws[i] for i in range(len(ws) - 1) if (abs(Ls(ws[i])) - 1) * (abs(Ls(ws[i + 1])) - 1) < 0][0]
pm = 180 + math.degrees(cmath.phase(Ls(wc)))
print(f'with the servo: crossover {wc:.2f} rad/s, phase margin {pm:.1f} deg, delay margin {math.radians(pm) / wc:.3f} s, peak |S| {max(1 / abs(1 + Ls(w)) for w in ws):.2f}')

# optimality: cost of a 1 m position error, J = x0' P x0, for LQR and for two pole-placement designs
def cost(Kv):
    Acl = g.ss_closed_loop(A, B, Kv)
    Qc = [[Q[i][j] + Kv[i] * R[0][0] * Kv[j] for j in range(4)] for i in range(4)]
    return g.lyap(Acl, Qc)[0][0]
print(f'cost of a 1 m error: LQR {P[0][0]:.2f} (check {cost(K):.2f}); poles (-1,-1.5,-3,-4): {cost(g.acker(A, B, [-1, -1.5, -3, -4])):.2f}; poles (-2,-3,-6,-8): {cost(g.acker(A, B, [-2, -3, -6, -8])):.2f}')
K = [0.15, 0.2715, 1.6581, 0.3861]
closed-loop poles: [(-5.87, 0.0), (-1.61, -1.25), (-1.61, 1.25), (-1.16, 0.0)]
smallest |1 + L| over all frequencies: 1.000018 (the theorem says at least 1)
ideal LQR loop: crossover 10.22 rad/s, phase margin 71.3 deg (at least 60), delay margin 0.122 s
it stays stable for any gain increase and for a gain decrease down to x0.19 (the theorem guarantees x0.5)
with the servo: crossover 9.93 rad/s, phase margin 56.8 deg, delay margin 0.100 s, peak |S| 1.22
cost of a 1 m error: LQR 1.81 (check 1.81); poles (-1,-1.5,-3,-4): 1.90; poles (-2,-3,-6,-8): 5.93
lqr solves the Riccati equation; ss_freq gives L(jw) of the state-space loop; lyap evaluates the cost of any stabilizing gain.

In robotics

LQR is the standard first design for multivariable regulation, and its margins are why it is trusted.

  • Autopilots. Attitude and velocity regulators of aircraft, missiles and spacecraft are designed by LQR as often as by classical loop shaping. The weights express the requirements in the units of the problem, and an engineer can read the rule behind each gain.
  • Weights from requirements. Bryson's rule connects a requirement ("keep the pitch within 0.2 rad, the gimbal within 0.15 rad") to a design directly. Tuning then moves the weights by looking at the closed loop, as the lab M4-L1: LQR for Hopper and Its Margins does.
  • Checking a design. The identity ∣1+L∣≥1|1 + L| \ge 1 is a diagnostic: an LQR loop that violates it has a bug, an unmodelled actuator or a wrong weight. The worked example finds the 56.8° of the servo loop by this reasoning.
  • Beyond the regulator. The same machinery gives the Kalman gain of M4-T3: Observers and the Separation Principle (the dual problem), the linear-quadratic-Gaussian controller of the next lesson, and, over a finite horizon with constraints, the model predictive control of module 9.
  • Limits. The solution needs the whole state (the observer of the last lesson) and a model that is good in the region used. It does not know about actuator saturation, so the weight on the input has to be large enough to keep the input within its limits for the errors expected, as Bryson's rule does.

For the quadrotor version see UAV M5-L2: Implement LQR; this track's labs for the same ideas are in module 4. The math of positive-definite matrices that the cost relies on is in Linear Algebra M6-T4: Positive Definite Matrices.

Common misconceptions

“LQR minimizes the cost I really care about.”

It minimizes the quadratic cost you wrote down, and the weights are a design handle on the response, not a physical quantity. The real objective (a landing within 3 m, a bounded gimbal angle) is not quadratic. The weights are adjusted until the closed loop does what is needed.

“Only the values of Q and R matter.”

Only their ratios do: multiplying both by 10 leaves the gain unchanged, since the cost scales and the minimizer does not. It is the relative price of each state against the input that sets the speed of the response.

“LQR margins are guaranteed in a real vehicle.”

They hold for the loop cut at the plant input, with the full state and the model used in the design. Actuator lag, delay, an observer or model errors are outside the guarantee: Hopper's servo took the phase margin from 71° to 57°, below 60°, and the observer of the next lesson can destroy them.

“The optimal poles are the best poles.”

The poles are a result and not a choice, and they are best only for the cost that was written. The same design with another R has other poles and is optimal for that cost. What looks like an arbitrary placement is the consequence of the weights.

“Optimal means the best possible controller.”

It means optimal for this model and this cost over the infinite horizon, using linear state feedback without constraints. A constrained or finite-horizon problem has a different optimum, and a model that is wrong makes the optimal controller wrong by the same amount.

Key takeaways

  1. LQR minimizes ∫(xTQx+uTRu) dt\int(\mathbf{x}^{\mathsf{T}}\mathbf{Q}\mathbf{x} + u^{\mathsf{T}}\mathbf{R}u)\,dt by linear state feedback u=−R−1BTPxu = -\mathbf{R}^{-1}\mathbf{B}^{\mathsf{T}}\mathbf{P}\mathbf{x}, where P\mathbf{P} solves the Riccati equation.
  2. The equation comes from dynamic programming with a quadratic value function V=xTPxV = \mathbf{x}^{\mathsf{T}}\mathbf{P}\mathbf{x}; the cost of a start x0\mathbf{x}_0 is x0TPx0\mathbf{x}_0^{\mathsf{T}}\mathbf{P}\mathbf{x}_0.
  3. Bryson's rule sets each weight to one over the square of the largest acceptable value; only the ratios of the weights matter.
  4. The Riccati equation implies ∣1+L(jω)∣≥1|1 + L(j\omega)| \ge 1, hence a gain margin from 1/2 to infinity and a phase margin of at least 60°.
  5. The guarantee holds at the plant input, with full state and the design model; Hopper's servo takes the margin from 71.3° to 56.8°.
  6. For Hopper, K = (0.150, 0.272, 1.658, 0.386), with the cost of a 1 m error 1.81, below any pole placement tried.

References and further reading

Each source is marked free or paid. Free to read does not mean free to reuse: the course resources page lists every source with its licence.

Knowledge check

Three questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

A designer multiplies both Q and R by 10. What happens to the gain K and to the closed-loop poles, and why?

Explanation

Nothing changes. The cost becomes 10 times larger for every motion, so the minimizing motion is the same, and the Riccati equation becomes A^T (10P) + (10P) A − (10P) B (10R)^−1 B^T (10P) + 10Q = 0, which is solved by 10 P; the gain R^−1 B^T P is unchanged. Only the ratio of Q to R matters. To make the controller faster the designer must raise Q relative to R, which makes errors dearer than effort.

Question 2

The ideal LQR loop of the example has a phase margin of 71.3° at a crossover of 10.22 rad/s. A first-order servo with a corner at 40 rad/s is added. Estimate the new margin.

Explanation

The servo adds a lag of arctan(10.22 / 40) = 14.3° at the crossover, so the margin falls to about 71.3° − 14.3° = 57°, ignoring the small movement of the crossover. The computed value is 56.8° at a crossover of 9.93 rad/s. The loop is below the guaranteed 60° because the servo was not in the model the guarantee applies to; a designer who needs 60° with the servo includes it in the model, or slows the design.

Question 3

Using Bryson's rule, what happens to the weights if the pitch limit is tightened from 0.2 to 0.1 rad, and what does that do to the closed loop?

Explanation

The weight on pitch rises from 1/0.2² = 25 to 1/0.1² = 100, four times. Pitch errors are now four times as expensive relative to the gimbal effort, so the optimal gain on pitch (and with it the pitch rate) grows and the pitch loop is made faster and tighter, at the price of more gimbal activity. The input weight is unchanged, so the gimbal is used more freely, and if the new gains demand more than the 0.15 rad limit for ordinary errors, R must be raised to compensate.

What’s next

Practice this lesson

LQR for Hopper and Its Margins

Design an LQR for Hopper's lateral channel (position, velocity, pitch, pitch rate), then break the loop at the gimbal and measure the margins it actually has with the actuator lag included.

Next lesson

M4-T5 — LQG and Why the Guarantees Disappear

Combine LQR with a Kalman filter, show by example that the result can have arbitrarily small margins, and recover them by loop-transfer recovery.

Nothing below is required to finish this lesson.

  • Before
    M4-T3: Observers and the Separation Principle

    Design a Luenberger observer, show that controller and observer poles can be chosen separately, and identify the Kalman filter as the optimal observer.

  • Lab
    M4-L1: LQR for Hopper and Its Margins

    Design an LQR for Hopper's lateral channel (position, velocity, pitch, pitch rate), then break the loop at the gimbal and measure the margins it actually has with the actuator lag included.

  • Lab
    M12-L2: Capstone: Land Hopper

    Write the navigation filter, the guidance law and the controller of Hopper, and pass an acceptance campaign of dispersed flights with wind, sensor errors, mass uncertainty and one beacon fault.

Other courses on this site treat neighbouring topics from their own angle:

This course leaves the following to the pages that already teach them: