Guidance, Navigation and Control · Theory · M2
M2-T4 — Trim and Linearization
A nonlinear model is accurate and hard to analyse. A linear model is easy to analyse and true only near one operating point. Trim and linearization are how the two meet.
The tools of the next two modules, poles, margins, regulators, observers, all work on linear models. Hopper's model is not linear: it has sines, products and a mass that changes. The step between them is standard and short. Choose a steady condition about which the vehicle can sit, which is called its trim, and expand the equations to first order around it. This lesson does both for Hopper, with a numerical Jacobian, and then asks the question that decides whether the linear model can be used: how far from the trim does it stop being true?
Learning objectives
After this lesson, you should be able to:
- Find a trim of a nonlinear model by solving the steady-state equations numerically.
- Linearize the model about a trim to state-space form with a Jacobian.
- Read the poles of the linear model and relate them to the behaviour of the vehicle.
- Estimate the range of the linear model's validity, and name the couplings it leaves out.
The intuition
Hopper's nonlinear model, from the last two lessons, has seven states and two inputs. Its lateral acceleration is , which is not a linear function of anything. The methods of the next modules (poles, frequency response, linear-quadratic regulators) need a model of the form . The way to get one is to look at the vehicle close up, near one steady condition, where the curved relations are nearly straight.
Trim: a condition the vehicle can hold
A trim is a steady operating condition: the inputs are constant and the accelerations that matter are constant too. Every vehicle has its own.
- A multirotor in hover: zero velocity, zero tilt, rotor thrusts that add up to the weight.
- An aircraft in level flight at a given airspeed: an angle of attack, an elevator angle and a throttle setting at which lift equals weight and thrust equals drag.
- A satellite spinning at a constant rate about a principal axis.
- Hopper in hover (zero tilt, thrust equal to weight) or in a steady acceleration (a constant lateral acceleration, with the thrust tilted to give it).
Finding a trim is solving equations: set the derivatives that must vanish to zero, and solve for the inputs and the states that remain. For hover the answer is obvious. For a steady acceleration it is not: the thrust, the pitch and the gimbal angle have to be found together, because the aerodynamic moment and the gimbal moment have to cancel at the same time as the forces balance. A numerical solver (Newton's method, with a numerical Jacobian) does it for any model.
Linearize: the straight line that touches the curve
Around a trim, small deviations from it obey equations that are linear in the deviations. The figure shows the idea for one term: the straight line touches the curve at the origin and stays close for a while. The slope of that line is a partial derivative, and the collection of such slopes for every state and every input is a pair of matrices, and .
What the linear model tells you
The poles of , its eigenvalues, say how the vehicle behaves near the trim: which modes grow, which decay, which neither. For Hopper in hover they are 0, 0, +0.7 and −0.7 per second: two integrators (position and velocity) and the unstable pair of the pitch axis. The same four numbers were already in the model; the linearization exposes them and makes them computable for a model whose structure is not obvious by inspection.
What it leaves out
A linear model is true at one point and an approximation near it. Two things go wrong as the vehicle moves away. The curvature of each term shows up, as in the figure. And couplings that vanished at the trim come back: at hover, the lateral and vertical motions are independent to first order, but a Hopper tilted by 40° has lost 2.3 m/s² of vertical acceleration that the lateral model knows nothing of.
Trim finds the condition. Linearization gives the model around it. The range of validity, which the linear model cannot tell you about itself, is something you compute separately.
Definitions
- Nonlinear model
- with state and input .
- Equilibrium or trim
- A state and input at which the part of the motion that must be steady has no acceleration. For a true equilibrium, . For a steady acceleration the equations are solved for the states and inputs that make the other derivatives vanish.
- Deviations
- The difference from the trim: , .
- Jacobian
- The matrix of partial derivatives of a vector function: its entry is how output changes with input .
- Pole
- An eigenvalue of . A mode with eigenvalue behaves as (M1-T3: One Block Diagram, Four Vehicles explains why).
The linearization is the first-order expansion of the model about the trim:
For a steady lateral acceleration , the trim of Hopper has no vertical or pitch acceleration. Its three unknowns, the thrust , the pitch and the gimbal , satisfy three equations:
Linearizing the lateral channel, with states and input , gives:
Derivation: the Jacobian of Hopper, its poles, and how far it can be trusted
The linearization follows from one expansion. Then the entries of and for Hopper can be written down by hand, and the model's range of validity estimated.
Expand each component of in a Taylor series about the trim. The first-order coefficients are the partial derivatives, collected into the Jacobians and .
At a trim the derivative of the part of the state that must stay steady is zero (or constant), so it drops out of the difference. Neglecting the second-order terms leaves the linear model.
The entries for Hopper
Differentiate the lateral acceleration with respect to pitch. At the trim the vertical balance of the trim equations says , so the entry is exactly at every steady acceleration, not just in hover. The same holds for the derivative with respect to .
Differentiate the pitch acceleration. The aerodynamic term is already linear. The gimbal term has slope , the authority at the trim.
Expand the determinant. The chain is two integrators driven by the pitch, and the pitch pair is . The characteristic polynomial factors into and .
The poles: two integrators and a divergent and a convergent pitch mode. They do not depend on the trim, and they do not depend on the pitch authority. Only changes with the thrust.
How far can it be trusted?
The first neglected term of the series for the sine. The relative error of the linear lateral acceleration grows as the square of the tilt.
Choose an acceptable error and solve for the tilt. Both numbers match the figure (the 10% point, at 43°, is a little lower because the next term of the series matters there).
The vertical acceleration that the lateral model leaves out when thrust is held at the hover value. It is a second-order effect that is missing from the linear model of the lateral channel.
The linearization is exact only at the trim. Near it the error is second order in the distance, and the question is never "is the model linear?" but "how far from the trim will the vehicle go?".
A worked example
Find the trim of Hopper for a lateral acceleration of 2 m/s² at liftoff mass, linearize its lateral channel about hover and about that trim, and measure where the hover model stops being accurate.
- Trim. Newton's method on the three equations of the definitions, with a numerical Jacobian, starting from the weight and small angles, finds a thrust of 1201.4 N (1.0206 times the weight), a pitch of 11.81° and a gimbal angle of −0.289°. The thrust direction is 11.52°, which is : the direction of the vector sum of weight and the required acceleration.
- Linearize. A central-difference Jacobian of the nonlinear model gives the matrices at both operating points. At hover has the entries and and has . At the trim is identical, as the derivation says, and is 20.02.
- Poles. The eigenvalues are −0.7, 0, 0 and +0.7 per second at both operating points.
- Validity. The linear lateral acceleration is 0.5% too high at 10° of tilt, 2.1% at 20°, 4.7% at 30°, 8.6% at 40° and 20.9% at 60°. The vertical acceleration that it leaves out is −0.15 m/s² at 10° and −2.3 m/s² at 40°, nearly a quarter of gravity.
- Read it. For a hop whose tilt stays below about 20° the hover model is good to 2% and the missing vertical coupling is below 0.6 m/s². For manoeuvres beyond 30° one linear model is not enough, and the options are several linearizations (gain scheduling, module 5) or a nonlinear controller.
import math
from gnckit import HOPPER, hopper_deriv, jacobian, newton, mat_eigvals
P = HOPPER
g, m, J, l, lam = P['g'], P['m0'], P['J'], P['l'], P['lam']
def f(state, T, delta):
return hopper_deriv(list(state) + [m], T, delta)[:6]
# trim for a steady lateral acceleration a: no vertical acceleration, no pitch acceleration
def residual(u, a=2.0):
T, th, delta = u
d = hopper_deriv([0.0, 10.0, th, 0.0, 0.0, 0.0, m], T, delta)
return [d[3] - a, d[4], d[5]]
T, th, dl = newton(residual, [m * g, 0.1, -0.01])
print(f'trim at a = 2 m/s^2: thrust {T:.1f} N ({T / (m * g):.4f} x weight), pitch {math.degrees(th):.2f} deg, gimbal {math.degrees(dl):.3f} deg')
lat_idx = (0, 3, 2, 5)
def lateral_AB(T, th, dl):
x0 = [0.0, 10.0, th, 0.0, 0.0, 0.0]
A = jacobian(lambda s: f(s, T, dl), x0)
h = 1e-6
dfdu = [(a - b) / (2 * h) for a, b in zip(f(x0, T, dl + h), f(x0, T, dl - h))]
return [[A[i][j] for j in lat_idx] for i in lat_idx], [dfdu[i] for i in lat_idx]
for name, args in (('hover', (m * g, 0.0, 0.0)), ('a = 2 trim', (T, th, dl))):
A, B = lateral_AB(*args)
ev = sorted(mat_eigvals(A), key=lambda c: complex(c).real)
print(f'{name:10s} A[1][2] = {A[1][2]:.3f} A[3][2] = {A[3][2]:.3f} B = ({B[1]:.3f}, {B[3]:.3f}) poles {[round(complex(e).real, 3) for e in ev]}')
print('how far the linear model is from the nonlinear one (hover linearization):')
for deg in (10, 20, 30, 40, 60):
t = math.radians(deg)
a_nl = g * math.sin(t); a_lin = g * t
az = g * (math.cos(t) - 1.0)
print(f' theta {deg:2d} deg: lateral accel {a_nl:5.2f} vs linear {a_lin:5.2f} m/s^2 ({100 * (a_lin / a_nl - 1):4.1f}% high), vertical accel the linear model leaves out {az:6.2f} m/s^2')trim at a = 2 m/s^2: thrust 1201.4 N (1.0206 x weight), pitch 11.81 deg, gimbal -0.289 deg hover A[1][2] = 9.810 A[3][2] = 0.490 B = (9.810, 19.620) poles [-0.7, 0.0, 0.0, 0.7] a = 2 trim A[1][2] = 9.810 A[3][2] = 0.490 B = (9.810, 20.023) poles [-0.7, 0.0, 0.0, 0.7] how far the linear model is from the nonlinear one (hover linearization): theta 10 deg: lateral accel 1.70 vs linear 1.71 m/s^2 ( 0.5% high), vertical accel the linear model leaves out -0.15 m/s^2 theta 20 deg: lateral accel 3.36 vs linear 3.42 m/s^2 ( 2.1% high), vertical accel the linear model leaves out -0.59 m/s^2 theta 30 deg: lateral accel 4.90 vs linear 5.14 m/s^2 ( 4.7% high), vertical accel the linear model leaves out -1.31 m/s^2 theta 40 deg: lateral accel 6.31 vs linear 6.85 m/s^2 ( 8.6% high), vertical accel the linear model leaves out -2.30 m/s^2 theta 60 deg: lateral accel 8.50 vs linear 10.27 m/s^2 (20.9% high), vertical accel the linear model leaves out -4.90 m/s^2
In robotics
Linearization is the first step of almost every control design, and the choice of trim shapes the result.
- Aircraft. The trim is a level flight at a chosen airspeed and altitude, found by solving for the angle of attack, elevator and throttle. Linearizing there gives the longitudinal and lateral models whose modes (short period, phugoid, roll, spiral, Dutch roll) module 10 studies. A different airspeed is a different trim and a different model, so an aircraft has a family of them.
- Multirotors. The hover trim and its linear model are the basis of the attitude and position controllers of UAV M5-T2: Quadrotor dynamic modelling. The lateral channel of Hopper has the same structure as the translational channel of a quadrotor: two integrators fed by the tilt.
- Tools. Simulation environments linearize a model with a numerical Jacobian exactly as in the worked example: Simulink's
linmod, python-control'slinearizeand the linearization functions of robotics toolboxes. The step size of the numerical derivative matters: too large and it measures curvature, too small and it measures rounding error. - Gain scheduling. A family of linearizations over a changing parameter, such as the mass or the dynamic pressure, gives a family of controllers (module 5). Hopper's depends on the thrust, so its pitch authority is 19.6 at liftoff and 11.8 at burnout.
- Stability of the nonlinear system. If every pole of is in the left half-plane, the nonlinear system is locally stable at the trim, and if one is in the right half-plane, it is unstable. Poles at zero decide nothing. This is Lyapunov's indirect method (module 5). It says nothing about how large the region of stability is.
The Jacobian is the same object that appears in kinematics and in estimation: Linear Algebra M8-T4: Jacobian Matrices derives it for a robot arm, and the extended Kalman filter of module 7 linearizes its measurement model in the same way.
Common misconceptions
“A linearized model is valid everywhere.”
It is exact at the trim and a first-order approximation near it, with an error that grows as the square of the distance. Hopper's lateral model is 5% off at 31° of tilt and 21% off at 60°. A controller designed on it is only guaranteed to work in the region where the model is accurate enough.
“A trim must be a rest state.”
A trim is a steady condition, and the vehicle may be moving. Level flight at 80 m/s, a steady turn and a constant lateral acceleration are all trims. The condition that defines it is that the accelerations that matter are constant, not that the vehicle is still.
“Poles at zero mean the vehicle is unstable.”
A pole at zero is an integrator: the mode neither grows nor decays by itself. Hopper's position and velocity are two such modes, and the vehicle drifts if there is any velocity. Instability is a pole in the right half-plane: Hopper's +0.7.
“The linear model is the same at every trim.”
The poles of Hopper's lateral channel are the same at every steady acceleration, but the input matrix is not: the pitch authority is 19.6 at hover and 20.0 at the 2 m/s² trim, and falls with the mass. The model depends on the operating point through the entries that involve thrust and mass.
“Linearization at hover captures the whole vehicle.”
It decouples the channels. At hover the lateral and vertical motions are independent to first order. Away from hover they interact: at 40° of tilt the thrust loses 23% of its vertical component, an effect that appears in none of the lateral model's equations.
Key takeaways
- A trim is a steady operating condition that a vehicle can hold: hover, level flight at an airspeed, a steady acceleration. It is found by solving the steady-state equations, numerically if need be.
- Linearizing about a trim gives with the Jacobians of the model as and .
- Hopper's lateral channel has poles 0, 0, +0.7 and −0.7 per second at every steady acceleration; only the input matrix changes with thrust and mass.
- The error of the linear model is second order in the distance from the trim: for Hopper about in lateral acceleration.
- The linear model also drops couplings: at 40° of tilt, 2.3 m/s² of vertical acceleration is missing.
- Compute the range over which the linear model holds before designing on it, and use several linearizations when the vehicle will go farther.
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 section on linearization. Free to read as the authors' PDF; the book is copyrighted.
- B. L. Stevens, F. L. Lewis and E. N. Johnson, Aircraft Control and Simulation, 3rd edition, Wiley, 2016, the chapter on aircraft trim and linearization. The standard treatment, with the numerical methods. Paid book.
- J. How, MIT 16.333 Aircraft Stability and Control (OpenCourseWare) , the lectures on trim and linearized equations. Free; licence CC BY-NC-SA 4.0.
- R. Tedrake, Underactuated Robotics , the chapter on linearization and stability of nonlinear systems, with runnable notebooks. Free to read; no licence statement was found.
Knowledge check
Three questions. Write an answer, then reveal the explanation. Your answers stay in your browser.
Question 1
At a pitch of 0.3 rad (17°), by what percentage does the linear lateral acceleration gθ differ from the true g sin θ, and does the θ²/6 estimate agree?
Explanation
The true value is sin 0.3 = 0.2955, the linear value is 0.3, so the linear model is 0.3 / 0.2955 − 1 = 1.5% high. The estimate θ²/6 = 0.09/6 = 0.015 = 1.5% agrees to the digit shown. At 17° the hover model is accurate enough for most purposes, and the error would not matter against a navigation budget of tens of centimetres.
Question 2
Between liftoff and burnout, which of the numbers of Hopper's linear lateral model change, and which do not?
Explanation
The matrix A does not change: its entries are g, 1, and λ², and the poles stay at 0, 0, ±0.7 per second. The input matrix changes: the pitch authority b = T l cos δ0 / J falls from 19.6 rad/s² per rad at liftoff to 11.8 at burnout, because the hover thrust follows the mass. The entry g in B does not change. So the open-loop vehicle is the same, and a controller's gain has to be scheduled to keep the closed loop the same.
Question 3
Hopper at liftoff mass must accelerate sideways at 3 m/s². What direction must the thrust have, and what thrust is needed?
Explanation
The thrust vector must balance weight and give the lateral acceleration, so its direction is arctan(a / g) = arctan(3 / 9.81) = 17.0° from vertical and its size is m √(g² + a²) = 120 × √(96.2 + 9) = 120 × 10.26 = 1231 N, which is 1.046 times the weight. The pitch θ is slightly more than 17° because the trim gimbal angle is a small negative number (as in the 2 m/s² case, where θ = 11.81° and δ = −0.29° add to 11.52°); a Newton solve of the three trim equations gives the exact split.
What’s next
Related content
Nothing below is required to finish this lesson.
- BeforeM2-T3: Forces, Moments and Actuator Models
Model gravity, thrust and aerodynamic forces with coefficients, and model an actuator by its lag, rate limit and saturation.
- LabM2-L1: Trim and Linearize Hopper
Find the gimbal angle and thrust that hold Hopper in hover with an off-centre mass, linearize about that point, and show where the linear model stops matching the simulator.
Other courses on this site treat neighbouring topics from their own angle:
- UAV M1-T4: UAV coordinate frames
- UAV M1-T5: Six-degree-of-freedom UAV dynamics
- UAV M5-T1: UAV equations of motion
- UAV M5-T2: Quadrotor dynamic modelling
- Linear Algebra M7-T3: Three-Dimensional Rotation Matrices
- Linear Algebra M7-T8: Euler Angles and Quaternions
- Linear Algebra M8-T4: Jacobian Matrices
- Navigation M1-T3: Robot Motion Models for Navigation
- Robot Learning M7-T2: System Identification
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.