r 0.2 mN̄ ?x₁ 0.000 mk₂ ?k₁ ?+−x₁x₂u 12.8 N2 kgxx
r0123400.10.20.3time (s)mCART POSITION x₁open loop, 10 Nplaced, K = [14 12]jω axisstable: left half-6-4-20-6-4-20246real part (1/s)imaginary (rad/s)POLES IN THE s-PLANE
Lit wire with moving dashes: a signal is flowing along itBlocks: target r, gains N̄, k₁, k₂, the summing junction and the cart on its springPlots: cart position over time, and the poles in the s-plane, computed from the modelThe pills travelling to the gains are the measured states x₁ and x₂State feedback on a 2 kg cart: the position x₁ and velocity x₂ are measured, multiplied by the gains k₁ and k₂, and subtracted from the reference force N̄·r to make u. The plots are computed from the cart's state equation: the step response before and after feedback, and the poles moving from −1 ± j4.90 to the chosen −4 ± j4 as the gains grow. For a plant in phase-variable form, matching coefficients is the whole method. For any controllable single-input plant, Ackermann's formula gives the same K directly, and python-control's place(A, B, p) computes it numerically; with one input the answer is unique.

The cart and its poles

  1. Our plant is the cart from State-space models: 2 kg on a spring and damper, pushed by a force u. Its state x is position x₁ and velocity x₂, and it obeys ẋ = Ax + Bu.

State feedback

Placing the poles

Tracking a target

What is happening

# step 1/12 · plant
# about: Cart (plant)

x = [x1, x2]   position (m), velocity (m/s)

x' = A x + B u
A = [[  0,  1],
     [-25, -2]]
B = [0, 0.5]

2 kg · spring 50 N/m · damper 4 N·s/m

The cart is the same illustrative 2 kg cart as in State-space models. Every curve, pole and number in the figure is computed from its exact solution, and the Python on each step prints what the step says. The Python is plain Python 3. The simulation steps the state equation with Euler's method every 0.1 ms, close enough to the exact curve to print the same peak to three decimals.