Estimating hidden states with an observer
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
عن هذا الدرس
State feedback needs every state, but sensors rarely measure them all. Take the spring-mounted cart with only a position sensor: run a copy of its model in software, correct the copy with the gap between the measured and the predicted position, and pick the correction gain L so the estimation error dies fast. Then close the loop on the estimate and see the separation principle at work.
A state nobody measures
Pole placement fed the cart both states: position x₁ and velocity x₂. Our cart has only a position sensor. The velocity is a hidden state: it is real and it matters, but nothing measures it.
cart ẋ = A x + B u, y = C x
A = [[0, 1], [-25, -2]] B = [0, 0.5]
C = [1, 0] ← one sensor: position
x1 position measured: y = x1
x2 velocity hidden
State feedback u = -K x needs x2 too.اقرأ الدرس خطوة بخطوة
A state nobody measures
Pole placement fed the cart both states: position x₁ and velocity x₂. Our cart has only a position sensor. The velocity is a hidden state: it is real and it matters, but nothing measures it.
cart ẋ = A x + B u, y = C x A = [[0, 1], [-25, -2]] B = [0, 0.5] C = [1, 0] ← one sensor: position x1 position measured: y = x1 x2 velocity hidden State feedback u = -K x needs x2 too.Run a copy of the model
Idea one: simulate the cart in software, fed the same push u. Its state x̂ (x-hat) is our estimate. The cart was let go from 0.1 m; the copy starts at 0, because we never saw that. Nothing corrects it.
real cart x(0) = [0.1, 0] let go, u = 0 copy x̂(0) = [0, 0] a guess The copy obeys the same equation as the cart but starts somewhere else, so it sits still while the cart bounces.The copy forgets too slowly
Call the gap e = x − x̂. For the copy it obeys ė = Ae, so it fades only as fast as the cart's own poles, −1 ± j4.90. The velocity estimate is off by 0.01 m/s or more until 3.7 s.
# e = x - x̂ obeys ė = A e (u cancels); poles -1 ± j4.90 # if the cart were unstable, the gap would grow # the cart and its copy, Euler steps of 1 ms, u = 0 x1, x2 = 0.1, 0.0 # the real cart (x2 is hidden) h1, h2 = 0.0, 0.0 # the estimate dt, last = 0.001, 0.0 for n in range(5000): e = x1 - h1 # y - ŷ (the sensor reads x1) x1, x2 = x1 + dt*x2, x2 + dt*(-25*x1 - 2*x2) h1, h2 = h1 + dt*(h2 + 0*e), h2 + dt*(-25*h1 - 2*h2 + 0*e) if abs(x2 - h2) >= 0.01: last = (n + 1) * dt print(round(last, 1)) # 3.7Compare with the sensor
The sensor gives y, the real position. The copy predicts ŷ = Cx̂ = x̂₁. Their difference, y − ŷ, is the output error: the only evidence that the copy is wrong. At the start it is 0.100 − 0 = 0.100 m.
y = x1 measured 0.100 m ŷ = x̂1 predicted 0.000 m y - ŷ output error 0.100 m If the estimate were right, y - ŷ would be zero forever.Nudge the copy
Feed the output error back into the copy: x̂̇ = Ax̂ + Bu + L(y − ŷ). The column L = [l₁, l₂] says how hard each estimate is pushed. A copy corrected this way is called a Luenberger observer.
x̂̇ = A x̂ + B u + L (y - ŷ) model correction L = [l1, l2] l1 nudges x̂1, l2 nudges x̂2 The observer is just code: the "feedback" closes inside the computer.The gap gets its own poles
Subtract the observer from the cart and u cancels again: ė = (A − LC)e. Now L moves the gap's poles, just as K moved the cart's. The characteristic polynomial is s² + (2 + l₁)s + (25 + 2l₁ + l₂).
ė = (A - L C) e A - L C = [[-l1, 1], [-25 - l2, -2]] det(sI - (A - LC)) = s² + (2 + l1) s + (25 + 2 l1 + l2)Choose L
Put both error poles at −10, 2.5 times further left than the controller's −4 ± j4. Match (s + 10)² = s² + 20s + 100: 2 + l₁ = 20 and 25 + 2l₁ + l₂ = 100. So L = [18, 39].
want (s + 10)² = s² + 20 s + 100 2 + l1 = 20 → l1 = 18 25 + 2·18 + l2 = 100 → l2 = 39 L = [18, 39] python-control: L = place_acker(A.T, C.T, [-10, -10]).T (place() refuses a double pole with one output).The ghost catches up
Same wrong start, now with L. The ghost cart snaps onto the real one. The velocity estimate is off by 0.24 m/s at worst, and within 0.01 m/s after 0.6 s, where the plain copy needed 3.7 s. Nobody measured velocity.
# the cart and its copy, Euler steps of 1 ms, u = 0 x1, x2 = 0.1, 0.0 # the real cart (x2 is hidden) h1, h2 = 0.0, 0.0 # the estimate dt, last = 0.001, 0.0 for n in range(5000): e = x1 - h1 # y - ŷ (the sensor reads x1) x1, x2 = x1 + dt*x2, x2 + dt*(-25*x1 - 2*x2) h1, h2 = h1 + dt*(h2 + 18*e), h2 + dt*(-25*h1 - 2*h2 + 39*e) if abs(x2 - h2) >= 0.01: last = (n + 1) * dt print(round(last, 1)) # 0.6Feed the estimate to K
Now close the loop on the estimate: u = −Kx̂ + N̄r, with K = [14, 12] and N̄ = 64 from pole placement, aiming at r = 0.2 m. The controller never sees x₂; it trusts the observer.
u = -K x̂ + N̄ r K = [14, 12] N̄ = 64 r = 0.2 m at t = 0 x̂ = [0, 0] u = 12.8 N (fed the true x it would be 11.4 N) at t = 3 s cart at 0.200 mTwo designs, no clash
The loop's poles are the controller's −4 ± j4 plus the observer's −10, −10. This is the separation principle: design K and L apart. The wrong start only costs 23.1 mm at t = 0.42 s, then the curves join.
closed loop on the estimate, states (x, e): ẋ = (A - BK) x + BK e + B N̄ r ė = (A - LC) e poles = poles(A - BK) ∪ poles(A - LC) = {-4 ± j4} ∪ {-10, -10} biggest gap from the true-state loop: 23.1 mm at t = 0.42 sWhy not make it faster
A faster observer means a bigger L, so it leans harder on y and copies the sensor's noise into x̂ and then into u. A rough rule: make it about twice as fast as the controller. And it needs an observable system.
bigger L → error dies faster → noise in y leaks into x̂, u smaller L → smooth, but trusts the model rough rule: observer about 2× faster than the controller (here 10 vs 4) needs (A, C) observable: rank [C; CA] = 2
أسئلة سريعة: 5
اختر إجابة واحدة لكل سؤال. يمكنك تغيير اختياراتك قبل التحقق منها.
01The cart has a position sensor only. Why does a plain copy of the model (L = 0) estimate the velocity badly?
Subtracting the copy from the cart cancels u and leaves ė = Ae. The cart's poles are −1 ± j4.90, so the velocity estimate stays off by 0.01 m/s or more until 3.7 s. An unstable plant would make it grow.
02What does the observer feed back into its copy of the model?
The observer compares the measured output y with its prediction ŷ = Cx̂ and adds L(y − ŷ) to its rates. The true velocity is exactly the thing it cannot see.
03For A = [[0, 1], [−25, −2]] and C = [1, 0], the error polynomial is s² + (2 + l₁)s + (25 + 2l₁ + l₂). Which L puts both error poles at −10?
(s + 10)² = s² + 20s + 100, so 2 + l₁ = 20 gives l₁ = 18, and 25 + 36 + l₂ = 100 gives l₂ = 39. [14, 12] is the controller gain K from pole placement.
04The controller uses u = −Kx̂ + N̄r with K placing poles at −4 ± j4, and the observer's error poles are at −10, −10. Where are the poles of the whole loop?
With states (x, e) the closed-loop matrix is block triangular, so its poles are those of A − BK together with those of A − LC. K and L can be designed separately.
05Why not put the observer poles at −1000 to make the estimate converge almost instantly?
MIT 16.30 notes that high-bandwidth estimators accentuate sensing noise. A rough rule is to make the observer about twice as fast as the controller.
المسرد
- Hidden state
- A state of the system that affects its behaviour but is not measured by any sensor, like the cart's velocity here.
- Estimate x̂ (x-hat)
- The observer's best guess of the full state, computed in software.
- Output error (y − ŷ)
- Measured output minus the output the estimate predicts. It is zero when the estimate is right.
- Observer (Luenberger observer)
- A copy of the model, x̂̇ = Ax̂ + Bu, corrected by L(y − ŷ) so its estimate converges to the true state.
- Observer gain L
- The column that says how strongly the output error nudges each estimated state. It sets the poles of A − LC.
- Estimation error e
- The true state minus the estimate, e = x − x̂. For a Luenberger observer it obeys ė = (A − LC)e, whatever the input.
- Separation principle
- With state feedback on the estimate, the closed-loop poles are the controller's poles plus the observer's poles, so the two can be designed separately.
- Observability
- Whether the state can be worked out from the outputs. For two states and one output it holds when [C; CA] has rank 2; then L can place the error poles anywhere.
الملاحظات والمصادر
- The cart is the same model as in "State-space models" (2 kg, 4 N·s/m, 50 N/m). Every curve and number in the figure is integrated from its equations with 1 ms steps; the estimation error is also checked against its exact solution.
- The plots show the true velocity, which a real observer never sees. Only a simulation knows both, which is exactly why we can check the estimate here.
- The rule of thumb and the warning about noise come from MIT 16.30 (lecture 14). When sensor noise is described statistically, the best L is the Kalman filter gain, a topic beyond this lesson.
- The Python in the step details is plain Python 3 with Euler steps of 1 ms. It prints the same settling time the figure computes with RK4.
- N. S. Nise, Control Systems Engineering, 8th ed., Wiley (ch. 12, design via state space: observers)
- K. Ogata, Modern Control Engineering, 5th ed., Pearson (§10-5 state observers; §10-6, 10-7 designs with observers)
- G. F. Franklin, J. D. Powell, A. Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed., Pearson (ch. 7, state-space design)
- MIT OCW 16.30 Feedback Control Systems (J. How), lecture 14: open-loop and closed-loop estimators
- MIT OCW 16.30 Feedback Control Systems (J. How), lecture 15: combined estimators and regulators
- MIT OpenCourseWare 16.06 Principles of Automatic Control (S. Hall)
- MIT OpenCourseWare 6.302 Feedback Systems (Roberge, Dawson, Lundberg)
- python-control: control.place_acker (Ackermann pole placement)
اختبار يتاح بعد الخطوة الأخيرة.