Balancing & Optimal Control, step 3
Balancing by pole placement
Choose where the closed-loop eigenvalues go, compute the gain that puts them there, and balance the pole with all four states.
Builds on Feedback: P and PD control and Linear systems: calibrate a camera, from the free Foundations.
Write and run this step in the simulator with ProChoose the eigenvalues
The lean rule failed because two eigenvalues of stayed on the unit circle. So turn it around: decide where all four closed-loop eigenvalues, the poles, should be, and compute the that puts them there. That's pole placement.
A pole makes its mode shrink by each period:
- close to 1 (0.95): a slow mode. The cart wanders a long way before it comes back, and much closer to 1 it reaches the stops.
- closer to 0 (0.7): a fast mode, but the motor has to push hard. From 6°, poles at 0.7 ask for 25 N; this motor gives 10.
- Negative or outside the unit circle: oscillating or unstable.
Somewhere between 0.8 and 0.95 works well here.
Ackermann's formula
The eigenvalues of are the roots of its characteristic polynomial. You want that to be
For one input, Ackermann's formula gives the gain directly:
- is the polynomial evaluated at the matrix .
- is the controllability matrix. It's invertible exactly when the force can steer every state, and then any poles you like can be placed.
np.poly(poles) returns , and np.linalg.solve(C, pA) computes without forming the inverse.
Your task
- Implement
place(A, B, poles)for any number of states . Return as a array. - Pick four
POLES.
The program plots your poles and the eigenvalues of together, then balances for 4 s from 4–6°. To pass, the pole must be within 1° of upright by 1.5 s, the force must stay within 10 N, the cart must stay off the stops, and it must end up back at the centre.