Skip to the lesson
FixTheRobot Explore Robotics / Guidance, Navigation and Control / M5 Nonlinear, Scheduled and Adaptive Control / M5-T5

Guidance, Navigation and Control · Theory · M5

M5-T5 — Adaptive Control and Its Risks

An adaptive controller changes its own gains while it flies. The proof of stability is short. The reasons it is hard to certify are longer.

  • Lesson 5 of 7
  • Intermediate
  • Module 5: Nonlinear, Scheduled and Adaptive Control
  • Theory
  • About 13 minutes to read

Gain scheduling follows a change that is known. Adaptive control follows one that is not: the controller tunes its gains online so that the plant behaves like a reference model. The derivation from a Lyapunov function is a page long and the tracking is striking. This lesson derives the law on a scalar plant, shows it learning, and then shows what the proof leaves out: a parameter that drifts when nothing excites the loop, a measurement noise that pushes it further, and a delay that turns a larger adaptation gain into instability.

Learning objectives

After this lesson, you should be able to:

  • Derive the gradient adaptation law of a model-reference controller from a Lyapunov function.
  • State what the proof guarantees about the tracking error and the gains, and what it does not.
  • Demonstrate parameter drift with a noisy measurement and no excitation, and the effect of leakage.
  • Explain how a delay and a large adaptation gain destroy the loop.

The intuition

The last lesson's hybrid learning and control counterpart learns a model offline. Adaptive control learns a controller online, from the error, in closed loop, and stability depends on how it is done.

The idea

A reference model says how the vehicle should behave: for the scalar example, x˙m=−amxm+bmr\dot{x}_m = -a_m x_m + b_m r, a first-order response to the command rr. The plant is x˙=ax+bu\dot{x} = a x + b u with aa unknown (and positive, so the plant alone is unstable). A control u=kxx+krru = k_x x + k_r r makes the plant match the model for exactly one pair of gains, kx∗=−(a+am)/bk_x^* = -(a + a_m)/b and kr∗=bm/bk_r^* = b_m/b. The adaptive law adjusts kxk_x and krk_r in the direction that shrinks the difference between plant and model.

Why it is stable

The law is chosen so that a quantity made of the tracking error and the gain errors, V=e2/2+(b/2γ)(k~x2+k~r2)V = e^2/2 + (b/2\gamma)(\tilde{k}_x^2 + \tilde{k}_r^2), never grows. It is a Lyapunov function in the sense of M5-T1: Lyapunov Stability. It proves that the error is bounded and tends to zero. It does not prove that the gains reach their ideal values: the error can vanish with the gains at the wrong place.

What the proof leaves out

Three things appear in simulation and not in the proof. First, with no command to excite the loop and a little noise in the measurement, the gain drifts away from its value, because the update law integrates a signal that the error does not constrain. Second, the standard cure, leakage, bounds the drift but biases the gain. Third, a delay in the input that the proof ignores turns a large adaptation gain into instability: with a 0.1 s delay the adaptation gain of 2 is already marginal, and 5 diverges. The loop has no margin to give away, and the margin shrinks with the learning rate.

An adaptive loop learning to follow its reference modelThe plant state and the reference model state against time for a square-wave command that alternates every 5 seconds. In the first few seconds the plant departs from the model, with a large overshoot at the first reversal. By the fourth reversal, after about 20 seconds, the two curves coincide.051015202530-1.4-0.700.71.4time (s)plant state x reference model plant with adaptive gains
The plant (with its adapting gains) and the reference model for a square-wave command. The first reversals show large errors; after about 20 s the plant follows the model.

Adaptive control gets tracking from learning, and the price is a time-varying nonlinear loop that has no fixed margin. The hard part is not the law but what to do when the assumptions of the proof fail.

Definitions

Reference model
A stable linear system x˙m=−amxm+bmr\dot{x}_m = -a_m x_m + b_m r whose response is the one wanted from the closed loop.
Tracking error ee
e=x−xme = x - x_m: the plant against the model.
Parameter error k~\tilde{k}
k~=k−k∗\tilde{k} = k - k^*: the gap between the current gains and the ideal gains. It is not measured.
Persistent excitation
A command rich enough that the gains are pinned down by the data: for a scalar gain, a signal that does not vanish.
Leakage (σ-modification)
A term −σk-\sigma k added to the update so that the gain is pulled toward zero when the error gives no information.
The model-reference adaptive law
k˙x=−γ sgn(b) x e,k˙r=−γ sgn(b) r e\dot{k}_x = -\gamma\,\mathrm{sgn}(b)\,x\,e, \qquad \dot{k}_r = -\gamma\,\mathrm{sgn}(b)\,r\,e
The gains move opposite to the product of the error and the signal each gain multiplies. Only the sign of b has to be known. The adaptation gain γ\gamma sets the speed.
The Lyapunov function and its derivative
V=12e2+∣b∣2γ(k~x2+k~r2),V˙=−ame2≤0V = \tfrac{1}{2}e^2 + \dfrac{|b|}{2\gamma}\bigl(\tilde{k}_x^2 + \tilde{k}_r^2\bigr), \qquad \dot{V} = -a_m e^2 \le 0
The cross terms cancel by the choice of the adaptive law, leaving a nonpositive derivative.

Derivation: the adaptive law from a Lyapunov function

The scalar plant, the reference model and the control above.

  1. x˙=ax+b(kxx+krr)=(a+bkx)x+bkrr\dot{x} = a x + b(k_x x + k_r r) = (a + b k_x)x + b k_r r

    The closed loop for given gains.

  2. a+bkx∗=−am,bkr∗=bma + b k_x^* = -a_m, \qquad b k_r^* = b_m

    The ideal gains make the plant equal to the model.

  3. e˙=−ame+bk~x x+bk~r r\dot{e} = -a_m e + b\tilde{k}_x\,x + b\tilde{k}_r\,r

    Subtract the model from the plant and substitute the gain errors k~=k−k∗\tilde{k} = k - k^*: the error obeys a stable equation driven by the gain errors times signals.

  4. V˙=ee˙+∣b∣γ(k~xk˙x+k~rk˙r)\dot{V} = e\dot{e} + \dfrac{|b|}{\gamma}\bigl(\tilde{k}_x\dot{k}_x + \tilde{k}_r\dot{k}_r\bigr)

    Differentiate V (k~˙=k˙\dot{\tilde{k}} = \dot{k} since the ideal gains are constant).

  5. V˙=−ame2+bk~x xe+bk~r re+∣b∣γ(k~xk˙x+k~rk˙r)\dot{V} = -a_m e^2 + b\tilde{k}_x\,x e + b\tilde{k}_r\,r e + \dfrac{|b|}{\gamma}\bigl(\tilde{k}_x\dot{k}_x + \tilde{k}_r\dot{k}_r\bigr)

    Substitute e˙\dot{e}.

  6. k˙x=−γ sgn(b) xe,k˙r=−γ sgn(b) re  ⇒  V˙=−ame2\dot{k}_x = -\gamma\,\mathrm{sgn}(b)\,x e, \quad \dot{k}_r = -\gamma\,\mathrm{sgn}(b)\,r e \;\Rightarrow\; \dot{V} = -a_m e^2

    Choose the update so that the cross terms cancel exactly. That choice is the adaptive law.

What the conclusion is

  1. V≥0, V˙≤0  ⇒  e, k~x, k~r boundedV \ge 0,\ \dot{V} \le 0 \;\Rightarrow\; e,\ \tilde{k}_x,\ \tilde{k}_r \text{ bounded}

    V cannot grow, so each of its terms stays below its initial value.

  2. ∫0∞e2 dt≤V(0)/am  ⇒  e→0\int_0^\infty e^2\,dt \le V(0)/a_m \;\Rightarrow\; e \to 0

    The integral of the squared error is finite and e˙\dot{e} is bounded, so by Barbalat's lemma the error tends to zero.

  3. k~→0 only if the command is persistently exciting\tilde{k} \to 0 \text{ only if the command is persistently exciting}

    The theorem constrains the error, not the gains. With a constant zero command the error can vanish with the gains anywhere in the bounded set.

The adaptive law is exactly what makes the cross terms of V̇ cancel. The proof guarantees a bounded loop with vanishing error and says nothing about the gains, about noise, or about delay: those are the failures of practice.

A worked example

The scalar plant a=0.5, b=2a = 0.5,\ b = 2 with reference am=2, bm=2a_m = 2,\ b_m = 2. The ideal gains are kx∗=−1.25, kr∗=1k_x^* = -1.25,\ k_r^* = 1.

  1. Learning. With γ=2\gamma = 2 and a square-wave command that reverses every 5 s the error has an rms of 0.323 in the first 5 s and 0.0008 in the last 5 s of 60 s; the gains reach kx=−1.249, kr=0.999k_x = -1.249,\ k_r = 0.999.
  2. No excitation, with noise. With a zero command and a measurement noise of standard deviation 0.05, the gain kxk_x is −0.743 after 100 s and −1.745 after 300 s, wandering across and beyond the ideal −1.250: nothing in the error pins it.
  3. Leakage 0.5. The gain stays at −0.248 after 100 s and −0.253 after 300 s: bounded, but at the wrong value, a fifth of the way to the ideal. Leakage trades drift for bias.
  4. Delay 0.1 s. With the same square wave and γ=0.5\gamma = 0.5 the largest error in the last 10 s is 0.366; with γ=2\gamma = 2 it is 0.504; with γ=5,10,30\gamma = 5, 10, 30 the loop diverges.
  5. Reading. The proof holds in all four runs for the delay-free noise-free model and fails in the last three for reasons it does not mention. A larger learning rate shortens the learning and removes the margin.
import math
import gnckit as g

# plant x' = a x + b u (a unknown), reference model xm' = -am xm + bm r. Hopper's pitch-rate loop, simplified to one state.
a, b = 0.5, 2.0
am, bm = 2.0, 2.0
kx_star = -(a + am) / b
kr_star = bm / b
print(f'ideal gains: kx* = {kx_star:.3f}, kr* = {kr_star:.3f}')

def lcg(seed):
    s = seed
    while True:
        s = (1103515245 * s + 12345) % 2147483648
        yield (s / 2147483648.0 - 0.5) * 3.4641016      # uniform with unit variance

def run(gamma, rfun, noise=0.0, leak=0.0, delay=0.0, T=60.0, dt=0.001):
    x = xm = 0.0
    kx = kr = 0.0
    rnd = lcg(12345)
    buf = [0.0] * (int(delay / dt) + 1)
    hist = []
    for k in range(int(T / dt)):
        t = k * dt
        r = rfun(t)
        xmeas = x + noise * next(rnd)
        e = xmeas - xm
        u = kx * xmeas + kr * r
        buf.append(u); ud = buf.pop(0)
        dx = a * x + b * ud
        dxm = -am * xm + bm * r
        dkx = -gamma * xmeas * e - leak * kx
        dkr = -gamma * r * e - leak * kr
        x += dt * dx; xm += dt * dxm; kx += dt * dkx; kr += dt * dkr
        hist.append((t, x, xm, kx, kr, e))
    return hist

square = lambda t: 1.0 if int(t / 5.0) % 2 == 0 else -1.0
h = run(2.0, square)
rms = lambda seg: math.sqrt(sum(s[5] ** 2 for s in seg) / len(seg))
print(f'square-wave command, gamma = 2: error rms {rms(h[:5000]):.3f} (first 5 s), {rms(h[-5000:]):.4f} (last 5 s); kx = {h[-1][3]:.3f}, kr = {h[-1][4]:.3f}')

zero = lambda t: 0.0
print('no command (nothing excites the loop), noise on the measurement of x with std 0.05:')
for leak in (0.0, 0.5):
    h = run(2.0, zero, noise=0.05, leak=leak, T=300.0, dt=0.002)
    print(f'  leakage {leak}: kx after 100 s = {h[50000][3]:+.3f}, after 300 s = {h[-1][3]:+.3f}  (ideal {kx_star:+.3f})')

print('input delay 0.1 s, square-wave command, larger adaptation gain:')
for gamma in (0.5, 2.0, 5.0, 10.0, 30.0):
    h = run(gamma, square, delay=0.1, T=40.0)
    mx = max(abs(s[5]) for s in h[-10000:])
    print(f'  gamma = {gamma:5.1f}: largest tracking error in the last 10 s = ' + (f'{mx:.3f}' if mx < 1e3 and mx == mx else 'diverged'))
ideal gains: kx* = -1.250, kr* = 1.000
square-wave command, gamma = 2: error rms 0.323 (first 5 s), 0.0008 (last 5 s); kx = -1.249, kr = 0.999
no command (nothing excites the loop), noise on the measurement of x with std 0.05:
  leakage 0.0: kx after 100 s = -0.743, after 300 s = -1.745  (ideal -1.250)
  leakage 0.5: kx after 100 s = -0.248, after 300 s = -0.253  (ideal -1.250)
input delay 0.1 s, square-wave command, larger adaptation gain:
  gamma =   0.5: largest tracking error in the last 10 s = 0.366
  gamma =   2.0: largest tracking error in the last 10 s = 0.504
  gamma =   5.0: largest tracking error in the last 10 s = diverged
  gamma =  10.0: largest tracking error in the last 10 s = diverged
  gamma =  30.0: largest tracking error in the last 10 s = diverged
The adaptive law is integrated with the plant at 1 ms; the noise is a deterministic linear congruential generator, so the printed gains are reproducible.

In robotics

Adaptive control has flown, and the experience shaped the way it is used.

  • Where it is used. Adaptive elements have been added to flight controllers (the X-15 programme of the 1960s, later experiments with the NASA Intelligent Flight Control System and the F-15 and others) to recover from failures and damage. The standard modern use is a fast adaptive element on top of a fixed baseline controller, so a failure of the adaptation leaves a safe loop.
  • Modification terms. Leakage, a dead zone, parameter projection and the use of both the tracking error and a prediction error are the standard guards against drift and noise, each with its cost in bias or in accuracy.
  • Delay and learning rate. The adaptation gain has to be small enough that the loop with the actuator delay and lag keeps its margin. Methods that filter the control signal (the L1 architecture) decouple the learning rate from the loop bandwidth, at the price of the filter.
  • Certification. The loop is nonlinear and time-varying, its gains depend on history, and its worst case is hard to bound. Gain and phase margins have no direct meaning, so certification relies on bounds from analysis, extensive simulation and monitors.
  • The alternative. A well-chosen schedule (M5-T2: Gain Scheduling) or an INDI loop (M5-T3: Dynamic Inversion and Its Incremental Form) covers many of the cases adaptation is proposed for, with margins that can be measured.

The robustness tools of M5-T7: Robustness Beyond Gain and Phase Margin are what a designer uses to put a number on the loss of margin seen above.

Common misconceptions

“If the tracking error goes to zero the gains have converged.”

The proof gives bounded gains and vanishing error. The gains converge to their ideal values only for a persistently exciting command. With no command the error can be zero while the gains are anywhere.

“A higher adaptation gain learns faster and is therefore better.”

It shortens the learning and removes margin: with a 0.1 s delay the loop of the example diverges at γ = 5. The rate of learning is bounded above by the delay and the actuator.

“Leakage fixes drift for free.”

It bounds the gain by pulling it to zero, and so leaves a bias whenever the ideal gain is not zero: in the example the gain sits at −0.25 instead of −1.25.

“Adaptive control makes a model unnecessary.”

The structure of the plant, the sign of the control effectiveness and the reference model are all prior knowledge. The adaptation estimates a few parameters inside that structure and cannot compensate for a wrong one.

“The Lyapunov proof makes the loop robust.”

It proves stability of the idealized system. Noise, delay, unmodelled dynamics and actuator limits are outside it, and the loop can be unstable with all of them present while the proof holds for the model.

Key takeaways

  1. Model-reference adaptive control adjusts the gains so that the plant follows a reference model; the ideal gains are kx∗=−(a+am)/bk_x^* = -(a + a_m)/b and kr∗=bm/bk_r^* = b_m/b.
  2. The law k˙=−γ sgn(b) (signal) e\dot{k} = -\gamma\,\mathrm{sgn}(b)\,(\text{signal})\,e comes from choosing the update that cancels the cross terms in the derivative of a Lyapunov function.
  3. The proof gives bounded signals and a vanishing error, and gain convergence only for a persistently exciting command.
  4. Without excitation, noise makes the gain drift (−0.74 to −1.75 over 300 s in the example); leakage bounds the drift and leaves a bias.
  5. A delay of 0.1 s makes adaptation gains of 5 and above diverge: the learning rate is limited by the loop, not by the proof.
  6. Adaptive elements are used on top of a fixed baseline, with modifications and monitors, because they are hard to certify.

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

In the example the tracking error tends to zero but with no command the gain kx wanders. How can both be true?

Explanation

The proof only constrains the error and shows that the gains stay bounded; it does not say where in the bounded set they end. With a zero command the plant stays near zero, so the error is near zero for any gain in a range, and the update ‘−γ x e’ is a product of two tiny numbers, so nothing pulls the gain toward the ideal value. Noise on the measurement then pushes the integral of that product around, which is the drift. Excitation is needed for the gains to be determined.

Question 2

Leakage with σ = 0.5 held the gain at −0.25 against an ideal of −1.25. Why, and when is that acceptable?

Explanation

The leakage term −σk pulls the gain to zero, and the adaptation term pulls it toward the ideal only in proportion to the error, which is nearly zero when nothing excites the loop. The two balance at a gain between zero and the ideal. It is acceptable when a baseline controller keeps the loop safe at that gain and the adaptation is only needed to correct large changes, since the leakage keeps the gain from drifting into a region where noise or a failure would make it dangerous.

Question 3

Adaptation gain γ = 5 diverges with an input delay of 0.1 s in the example. Why does a larger γ make the loop less tolerant of delay?

Explanation

The adaptation adds a loop around the plant whose bandwidth grows with γ and with the size of the signals. With a delay, the effective phase lag at that bandwidth is ω times 0.1 s, and when the bandwidth rises past about 1/(delay) the loop has no phase margin left and oscillates. The proof assumes the control acts instantly, so it cannot see the limit. The learning rate has to be set from the delay and actuator lag, as for any loop.

What’s next

Next lesson

M5-T6 — Control Allocation

Distribute a commanded force and moment over more effectors than degrees of freedom, with position and rate limits, and reallocate after one fails.

Nothing below is required to finish this lesson.

  • Before
    M5-T4: Sliding-Mode Control

    Design a sliding surface and a switching law for a second-order system, and remove chattering with a boundary layer at a stated cost in accuracy.

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

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