Balancing & Optimal Control, step 2
Why it falls: eigenvalues
Read the pole's fall from the eigenvalues of A, see how feedback moves them, and watch the obvious rule balance the pole while the cart runs off the rail.
Builds on Feedback: P and PD control, from the free Foundations.
Write and run this step in the simulator with ProModes and eigenvalues
Every period, the model multiplies the state by . An eigenvector of is a direction that only stretches, by its eigenvalue : . Write the state as a mix of eigenvectors and each part, a mode, just gets multiplied by its own every period:
The numbers say how much of each mode the starting state holds. So is how much a mode grows per period. Below 1 it dies away, above 1 it grows, and at exactly 1 it just stays. Eigenvalues can be complex (a mode that spirals), so plot them as points : stable ones sit inside the unit circle.
The cart-pole has one eigenvalue at about 1.16: the pole falling. A mode growing times per period doubles after periods, when , which takes
Feedback moves eigenvalues
With state feedback , where is a row of four gains, each period becomes
Balancing means choosing so that every eigenvalue of is inside the unit circle.
The lean rule
The obvious rule is to push the way the pole leans: newtons (θ in radians). The second term pushes harder while the pole is tipping fast. It pays no attention to the cart, so as its gain is
Your task
growth_factors(A): for each eigenvalue of , largest first.doubling_time(lam, dt): in seconds.closed_loop(A, B, K): the matrix .- Set
K_LEAN.
The program plots the eigenvalues of and of against the unit circle, then runs the lean rule for 3 s from 4–6°. It passes when the rule catches the pole and the cart then runs into a stop. Which eigenvalues does the lean rule leave on the circle, and why does the cart drift?