School/✦ Research Engineer/Week 14
Second-order systems as two-state models
A rover's suspension bounces after every rock. One second-order equation, or two first-order ones: which can a computer step forward?
About 40 min · 3 goals · Checked by automated tests
1.Why should I care?
Most physical systems are second order: springs, pendulums, suspensions, attitude dynamics. Turning them into two-state form lets you simulate them, and lets a Kalman filter estimate the velocity you never directly measure.
- ◇ Rewrite m·ẍ + c·ẋ + k·x = u as two first-order equations.
- ◇ Discretise the model with Euler's method and build A and B.
- ◇ Check the discrete model's stability and the effect of the time step.
2.Predict
You simulate an undamped spring with forward Euler and a fairly large time step. What happens to the oscillation amplitude?
Guess first. Being wrong here is how the surprise works.
3.Discover
In the Robotics Workbench (or Code Lab), model one wheel's suspension: m = 1 kg, k = 4 N/m, c = 1 N·s/m. Build A = [[1, Δt], [−kΔt/m, 1 − cΔt/m]] for Δt = 0.1 s, release it from x = 0.1 m, and step it 100 times. Then set c = 0 and watch forward Euler pump energy in.
Can't use the interactive? Read a description instead
The simulation can be followed as a table of x and v at each step; the key result (|λ| ≈ 0.970 with damping, growth with c = 0) is stated in the text.
4.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1
A = [[1, 0.1], [−0.4, 0.9]] has complex eigenvalues. What is |λ| (to 3 decimal places)?
5.Understand
Two states from one equation
Choose x₁ = x (position) and x₂ = ẋ (velocity). Then ẋ₁ = x₂ and ẋ₂ = (u − c·x₂ − k·x₁)/m. In matrix form ẋ = F·x + G·u with F = [[0, 1], [−k/m, −c/m]] and G = [0, 1/m]ᵀ.
Discretise
Forward Euler: x[k+1] = x[k] + Δt·(F·x[k] + G·u[k]), so A = I + Δt·F and B = Δt·G. For m = 1, k = 4, c = 1, Δt = 0.1: A = [[1, 0.1], [−0.4, 0.9]], B = [0, 0.1]ᵀ. Its eigenvalues are complex with |λ| = √det(A) = √0.94 ≈ 0.970: a decaying oscillation.
Time step matters
The continuous system is stable for any c > 0, but the discrete model can disagree if Δt is too large. Smaller steps, or better integrators (semi-implicit Euler, Runge–Kutta, or the exact matrix exponential), keep the simulation faithful. Always check |λ| of the A you actually run.
Explain it another way
Position alone cannot tell you where a bouncing wheel is going next: it could be on its way up or on its way down. Add velocity and the future is determined.
Natural frequency ωₙ = √(k/m) = 2 rad/s, damping ratio ζ = c/(2√(km)) = 0.25. Continuous poles s = −ζωₙ ± jωₙ√(1 − ζ²) = −0.5 ± 1.94j.
For a 2 × 2 matrix with complex eigenvalues, |λ|² = det(A). det [[1, 0.1], [−0.4, 0.9]] = 0.9 + 0.04 = 0.94. With c = 0: det = 1 + 0.04 = 1.04 > 1: Euler makes the frictionless spring grow.
Spacecraft attitude about one axis is a two-state model (angle, rate) driven by reaction-wheel torque. Star trackers measure the angle; gyros measure the rate; the filter needs both states.
Worked example 1
m = 2 kg, k = 8 N/m, c = 2 N·s/m, Δt = 0.05 s. Write A.
F = [[0, 1], [−4, −1]]. A = I + 0.05F = [[1, 0.05], [−0.2, 0.95]].
Common mix-ups
- If the physics is stable, the simulation is stable.
✓ The discretised A has its own eigenvalues; a large Δt can make a stable system simulate as unstable. - You need a sensor for every state.
✓ Unmeasured states can be estimated if the system is observable: their effect shows up in the measured ones over time.
6.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 2
For m = 0.5 kg, k = 2 N/m, c = 0.5 N·s/m and Δt = 0.1 s, what is the bottom-right entry of the Euler A matrix, 1 − cΔt/m?
Practice 3 · a fresh version every time
A lander's state is x = [position; velocity] with x_{k+1} = A·x_k + B·u_k, A = [[1, Δt], [0, 1]], B = [Δt²/2; Δt], Δt = 0.5 s. Now position = 5 m, velocity = 1 m/s and thrust acceleration u = 0.5 m/s². What is the next velocity, in m/s?
Practice 4
Why does a Kalman filter for a suspension need the velocity state even if only position is measured?
7.Apply it
Find the largest Δt for which forward Euler keeps the m = 1, k = 4, c = 1 suspension stable (solve det(A) < 1 with A = I + ΔtF). Check your answer by simulation.
8.Reflect
Concepts: States and state-space models · Simulation and time stepping