Guidance, Navigation and Control · Theory · M5
M5-T4 — Sliding-Mode Control
Force the error onto a surface where it must decay, and switch hard enough to stay there against any bounded disturbance. The hardness is both the strength and the cost.
Dynamic inversion needs a model. Sliding-mode control needs only a bound on what the model gets wrong, and gives in return an error dynamics that does not depend on the disturbance at all. This lesson designs the surface and the switching law for Hopper's pitch, proves that the surface is reached, shows what the switching does to a gimbal with a servo lag and a rate limit, and replaces it with a boundary layer at a stated cost in accuracy.
Learning objectives
After this lesson, you should be able to:
- Choose a sliding variable so that motion on it is a first-order decay with a chosen rate.
- Derive the switching gain that guarantees the surface is reached against a bounded disturbance.
- Explain chattering and relate it to the actuator servo and rate limit.
- Choose a boundary-layer width and state the resulting error bound.
The intuition
UAV M5-T16: Disturbance rejection and wind compensation cancelled a disturbance by estimating it. Sliding-mode control takes the opposite stance: the disturbance is not estimated, only bounded, and the controller is made strong enough to beat any disturbance inside the bound.
A surface to live on
For Hopper's pitch, , define the sliding variable with rad/s. If is held at zero the pitch obeys : a first-order decay with a pole at −3, whatever the plant or the disturbance does, because they never enter. The second-order problem has been reduced to two steps: bring to zero, then let the pitch decay on its own.
Switching to stay on it
The control that drives to zero in finite time is a hard switch: push as hard as the largest disturbance whenever is positive, and the opposite way whenever it is negative. If the push exceeds the disturbance bound, cannot stay on either side, and slides along zero. With a gimbal that has a 40 rad/s servo and a 3 rad/s rate limit, though, a hard switch is a command that flips sign thousands of times per second, and the gimbal tries to follow: chattering.
A boundary layer
The remedy is to replace the switch by a saturation: full push when exceeds a thickness , proportional inside. The gimbal then moves smoothly. The surface is no longer held exactly: the loop stays within , and the pitch within of zero. A thicker layer gives a gentler gimbal and a larger error, and the width is chosen from the rate limit and the accuracy needed.
Sliding mode buys independence from a bounded disturbance with a hard switch. The switch is paid for in actuator activity, and a boundary layer pays it back in accuracy.
Definitions
- Sliding variable
- A combination of the states, , whose zero set is the sliding surface.
- Reaching and sliding
- The first phase brings to zero; the second keeps it there while the state moves along the surface.
- Matched disturbance
- A disturbance that enters through the same channel as the control, as does in . Only matched disturbances are rejected completely.
- Boundary layer
- The thickness of the band around inside which the switch is replaced by a linear segment.
Derivation: the reaching condition and the layer bound
Hopper's pitch with a matched disturbance and the law with .
Differentiate the sliding variable and substitute the plant.
Substitute the sign form of the law (): the model terms cancel and what remains is the disturbance and the switching term.
Multiply by and use . This is .
With the function is a Lyapunov function (the method of M5-T1: Lyapunov Stability) that decreases at a rate no smaller than , so reaches zero in finite time.
The boundary layer
Inside the layer the saturation is linear, so the sliding variable obeys a first-order stable equation driven by the disturbance.
At a steady state , which is smaller than when .
On the band the pitch obeys , a stable first-order system driven by a bounded input, so its steady value is bounded by .
The switching term overpowers any matched disturbance within a known bound, so the error dynamics on the surface are those the designer chose. The price is a command that switches faster than the actuator can follow; the boundary layer trades exactness for a smooth command.
A worked example
Hopper's pitch from 0.3 rad with , switching gain against a disturbance rad/s² (so ), a 40 rad/s gimbal servo, a 0.15 rad limit and a 3 rad/s rate limit that is only monitored.
- Pure switching. The sliding variable is held to |s| ≤ 0.002 and the pitch to 3·10⁻⁴ rad after 5 s: near-perfect rejection. The gimbal rate has an rms of 2.71 rad/s and exceeds the 3 rad/s limit 30% of the time.
- Boundary layer 0.05. |s| ≤ 0.033 and |θ| ≤ 0.0079 rad; the gimbal rate has an rms of only 0.12 rad/s and never exceeds the limit.
- Wider layers. φ = 0.2, 0.5, 1.0 give |θ| ≤ 0.030, 0.058, 0.074 rad, and the same gimbal activity (rms 0.12 to 0.13 rad/s).
- Bound check. The bound is 0.017, 0.067, 0.17 and 0.33 rad for the layers 0.05 to 1.0: always above the measured values, and conservative because the disturbance is not at its worst the whole time.
- Reading. The pure switch is the most accurate and the only one that violates the actuator. The thinnest layer already removes the chatter and costs an error of 0.008 rad, small against a 0.3 rad start.
import math
import gnckit as g
lam2, b = 0.49, 19.62
c = 3.0 # sliding surface s = q + c theta : on it, theta decays with pole -c
D = 1.0 # bound on the unknown disturbance acceleration
eta = 1.5 # switching gain > D
wservo, dmax = 40.0, 0.15
dt = 0.0005
def run(phi, T=10.0):
th, q, d = 0.3, 0.0, 0.0
ths, qs, ss, ds, drate = [], [], [], [], []
for k in range(int(T / dt)):
t = k * dt
s = q + c * th
sat = 1.0 if phi == 0 else max(-1.0, min(1.0, s / phi))
sgn = (1.0 if s > 0 else -1.0 if s < 0 else 0.0) if phi == 0 else sat
u = -(lam2 * th + c * q + eta * sgn) / b
u = max(-dmax, min(dmax, u))
dist = D * math.sin(3.0 * t)
dd = wservo * (u - d)
th, q, d = th + dt * q, q + dt * (lam2 * th + b * d + dist), d + dt * dd
ths.append(th); qs.append(q); ss.append(q + c * th); ds.append(d); drate.append(dd)
return ths, qs, ss, ds, drate
print('sliding mode, s = q + 3 theta, switching gain 1.5 against a disturbance of 1.0 sin(3 t) rad/s^2, 40 rad/s gimbal servo:')
n0 = int(5.0 / dt)
for phi in (0.0, 0.05, 0.2, 0.5, 1.0):
th, q, s, d, dr = run(phi)
tail = slice(n0, None)
maxth = max(abs(x) for x in th[tail]); maxs = max(abs(x) for x in s[tail])
rms = math.sqrt(sum(x * x for x in dr[tail]) / len(dr[tail]))
# fraction of time the gimbal rate exceeds the 3 rad/s limit (the actuator would be rate limited)
frac = sum(1 for x in dr[tail] if abs(x) > 3.0) / len(dr[tail])
label = 'sign (phi = 0)' if phi == 0 else f'phi = {phi:4.2f}'
print(f' {label:14s}: |theta| <= {maxth:.4f} rad after 5 s, |s| <= {maxs:.3f}, gimbal rate rms {rms:5.2f} rad/s, rate above 3 rad/s {100 * frac:4.0f}% of the time')sliding mode, s = q + 3 theta, switching gain 1.5 against a disturbance of 1.0 sin(3 t) rad/s^2, 40 rad/s gimbal servo: sign (phi = 0): |theta| <= 0.0003 rad after 5 s, |s| <= 0.002, gimbal rate rms 2.71 rad/s, rate above 3 rad/s 30% of the time phi = 0.05 : |theta| <= 0.0079 rad after 5 s, |s| <= 0.033, gimbal rate rms 0.12 rad/s, rate above 3 rad/s 0% of the time phi = 0.20 : |theta| <= 0.0298 rad after 5 s, |s| <= 0.127, gimbal rate rms 0.13 rad/s, rate above 3 rad/s 0% of the time phi = 0.50 : |theta| <= 0.0581 rad after 5 s, |s| <= 0.246, gimbal rate rms 0.13 rad/s, rate above 3 rad/s 0% of the time phi = 1.00 : |theta| <= 0.0743 rad after 5 s, |s| <= 0.315, gimbal rate rms 0.12 rad/s, rate above 3 rad/s 0% of the time
In robotics
Sliding-mode control is used where the disturbances are large, bounded and poorly modelled, and where the actuator is fast.
- Power electronics and motor drives. The switches are the actuator, so hard switching costs nothing: the original home of the method.
- Vehicles. Attitude and trajectory loops with large aerodynamic or thrust uncertainty use a boundary layer (smoothed sliding mode) or a higher-order variant. Hopper's thrust-vector actuator, with a rate limit, is on the unfavourable side of this trade.
- Choosing the layer. Pick the width from the rate limit first (the gimbal must follow the command), and read the error bound from it. If the error is too large, a faster actuator or a lower switching gain is what is needed, not a thinner layer.
- Unmatched and dynamic effects. A disturbance that does not enter through the control channel, a servo lag or a delay is not rejected, and can excite the chatter. The 40 rad/s servo above is already enough to make the pure switch violate the rate limit.
- Higher-order sliding modes. Variants that switch the derivative of the control keep finite-time convergence and give a continuous command. They are in the references.
Design the same loop with the tools of module 3 and compare delay margins: the boundary-layer law is a saturated high-gain PD loop, and its margins are those of the linear segment, as the lab M5-L1: Schedule the Gains Through the Burn shows when the schedule is added.
Common misconceptions
“Sliding mode is robust to everything.”
It rejects matched disturbances inside the assumed bound. Unmatched disturbances, actuator lag and delay are not covered, and they are the usual source of chatter.
“A thinner boundary layer is always better.”
It improves accuracy and returns the chatter. Below a width set by the servo bandwidth and the rate limit the gimbal is asked for what it cannot do. The layer is chosen from the actuator first.
“The switching gain should be as large as possible.”
It must exceed the disturbance bound, and any excess only increases the activity of the command and the noise sensitivity. The smallest value that clears the bound with some margin is the right one.
“Chattering is a numerical artefact.”
In a simulation with a fixed step the chatter is visible at the step frequency, but the cause is physical: a real servo with lag cannot follow the switching and produces a real oscillation, as the 30% rate violation above shows.
“On the sliding surface the system forgets the plant.”
The motion along the surface depends only on the surface, but only after the state reaches it. Reaching takes time, during which the plant and the disturbance matter, and the control saturates if the start is far.
Key takeaways
- A sliding variable such as reduces the second-order problem to a first-order decay with pole −c on the surface.
- A switching gain larger than the matched-disturbance bound brings s to zero in a time at most .
- The hard switch rejects the disturbance almost perfectly but chatters: with a 40 rad/s servo Hopper's gimbal exceeds its rate limit 30% of the time.
- A boundary layer φ removes the chatter and leaves , so .
- With φ = 0.05 the error is 0.008 rad and the gimbal rate rms is 0.12 rad/s.
- Unmatched disturbances, lag and delay are outside the guarantee; the layer is chosen from the actuator first.
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.
- K. J. Åström and R. M. Murray, Feedback Systems, 2nd edition, Princeton University Press, 2021 , the nonlinear control sections (Lyapunov analysis of switching). Free to read as the authors' PDF; the book is copyrighted.
- MIT 6.243J Dynamics of Nonlinear Systems (OpenCourseWare) , the Lyapunov background used in the reaching argument. Free; licence CC BY-NC-SA 4.0.
- J.-J. E. Slotine and W. Li, Applied Nonlinear Control, Prentice Hall, 1991, chapter 7 on sliding control. The standard text. Paid.
- Y. Shtessel, C. Edwards, L. Fridman and A. Levant, Sliding Mode Control and Observation, Birkhäuser, 2014, on higher-order sliding modes. Paid.
Knowledge check
Three questions. Write an answer, then reveal the explanation. Your answers stay in your browser.
Question 1
The disturbance bound is D = 1 rad/s² and the switching gain is η = 1.5. Starting at |s| = 0.9, give an upper bound on the time to reach the surface.
Explanation
The sliding variable satisfies s·ṡ ≤ −(η − D)|s| = −0.5|s|, so |s| falls at least at 0.5 per second, and treach ≤ 0.9/0.5 = 1.8 s. The actual time is shorter because the disturbance is rarely at its worst: in the simulation the variable is within 0.05 in about 1 s. The bound shows that raising η toward D lengthens the reach, and η below D gives no guarantee.
Question 2
With a boundary layer φ = 0.2 and c = 3, what pitch error does the theory allow, and what does the simulation give?
Explanation
The bound is |θ| ≲ φ/c = 0.2/3 = 0.067 rad. The simulation gives 0.030 rad, smaller than the bound because the disturbance is a sine of amplitude D, not a worst-case constant, and the bound assumes the sliding variable sits at the edge of the layer. A conservative bound is the correct behaviour of a theorem; a designer who needs less error has to narrow the layer or lower c.
Question 3
Why can a pure switching law violate a rate limit that the same law with a boundary layer satisfies?
Explanation
The pure switch flips the command between two values whenever s changes sign, which in a loop with delay and servo lag happens many times per second, so the command has an effective rate far above the limit (the rms gimbal rate is 2.71 rad/s, above 3 rad/s 30% of the time). The boundary layer replaces the flips by a proportional command inside the band, which moves at the rate of the disturbance (rms 0.12 rad/s). The disturbance rejection is the same in kind and the actuator activity is 20 times smaller.
What’s next
Related content
Nothing below is required to finish this lesson.
- BeforeM5-T3: Dynamic Inversion and Its Incremental Form
Cancel a known nonlinearity by feedback linearization, state what the method assumes about the model, and explain how incremental inversion replaces the model with a measurement.
Other courses on this site treat neighbouring topics from their own angle:
- Lab: Build a CBF Safety Filter
- Navigation M7-T2: Safety Filters: Control Barrier Functions
- UAV M5-T5: Attitude control
- UAV M5-T16: Disturbance rejection and wind compensation
- UAV M1-T6: Roll, pitch, yaw and thrust generation
- Linear Algebra M6-T7: The Moore-Penrose Pseudoinverse
- Linear Algebra M8-T9: Null-Space Control
- Robot Learning M9-T4: Hybrid Learning and Control Systems
This course leaves the following to the pages that already teach them:
Get notified when the next lesson and new labs are released.
One email per new lesson or lab.