Luenberger observer
Suppose we want to control the velocity of a motor-driven cart. Our controller needs its current velocity to compare against the desired one, but our sensor measures only position. We could estimate velocity by subtracting consecutive position readings and dividing by the time between them. Unfortunately, this also amplifies measurement noise.
We also have a model. Given an estimated state and the input applied to the cart, it predicts how the cart will move. This gives us two complementary sources of information: the (imperfect) model which predicts motion, while sensor measurements reveal when that prediction is wrong. An observer combines them, into a better estimate than either can provide individually.
One might ask - how can a model be wrong? Indeed, the model for a cart is pretty simple. One easy example is if the moving cart is traversing rocky terrain, where wheels may slip and the acceleration applied to the wheels is hence not the acceleration that the cart would experience along the ground.
Let’s formalize the example. The controller sends an acceleration command to the motor drive. We assume the drive produces the force , so . The sensor reports position, . The observer receives both and , and estimates velocity for the controller.
Play the cart below and adjust the command to accelerate or brake. Here you supply manually to explore the controller’s input to the plant.
Measured position y = 1.00 m
Scalar Observer
Ignoring friction, our cart obeys
Position changes at the cart’s velocity, and velocity changes at the commanded acceleration. The observer runs a copy of these rules with its own estimates:
A hat means “our estimate of.” Knowing the acceleration tells us how velocity changes, but does not tell us its starting value. We must initialize with a guess. Likewise, we initialize , perhaps using the first position reading.
Suppose the cart is moving at , but we initially guess that it is stationary. With , the model keeps predicting zero velocity and a fixed position, while the real cart moves away.
Correcting position
The position sensor reports , and our predicted sensor reading from the model is . Their difference
is the residual (also known as the innovation). A positive residual means the cart is farther forward than we predicted. We can use it to correct the position estimate:
The model term predicts motion and the correction pulls the estimate toward the measurement proportionally to the disagreement between them. The gain determines how strongly we respond.
Correcting position alone leaves our velocity guess unchanged. In our example, that guess is zero, so the position correction must keep dragging the estimate forward to follow the cart. To predict its motion correctly, we need to estimate velocity too. But what can a position residual actually tell us about velocity?
Correcting velocity
Recall that we have a position sensor that we can fuse with our position model to predict a better position than either could supply individually. However, in order for the model to be effective, we cannot assume constant velocity, since that is wrong. We should estimate it, but how do we do it with only a position sensor?
A single position residual cannot tell us whether our position estimate, velocity estimate, or both are wrong. If the cart is one meter ahead of our prediction, it might simply have started one meter farther forward. That measurement alone does not imply that it is moving faster than our model predicts.
The distinction appears over time. For a moment, consider the model running without measurement corrections, with . Its position error is
If the initial position is wrong but velocity is right, the offset stays constant. If velocity is wrong, the offset grows or shrinks. For example, starting one meter behind produces a constant one-meter discrepancy; underestimating velocity by produces another meter of discrepancy every second. A sequence of position measurements can distinguish these cases even though one measurement cannot.
How do we use this information without directly differentiating noisy position readings? We let the position residual gradually adjust the velocity estimate as well:
For a positive gain , a positive residual nudges the velocity estimate upward. This is a provisional correction, not necessarily a conclusion that the velocity is wrong. The observer also corrects position, then compares its revised prediction against subsequent measurements. Its two estimates carry the effects of earlier readings forward, so the correction uses a history of measurements even though only the current residual appears explicitly in the equation.
If only the initial position was wrong, this rule can temporarily push the velocity estimate away from its true value, but later residuals undo that adjustment. With suitable gains, errors in both estimated position and velocity decay;
Also, note the units. We are correcting , an acceleration, so has units of . Multiplying it by the position residual in meters gives .
Together, the two rules form our Luenberger observer:
One residual now affects two estimates. How can we tell whether these corrections actually make the errors disappear? Define and . With an exact model and noiseless position measurements, subtracting the observer equations from the physical equations gives
Error Dynamics
These equations let us check convergence to the true state directly. Let’s differentiate the position-error equation, then substitute the velocity-error equation:
Rearrange it:
This has the same form as a damped mass–spring system, with position error playing the role of spring displacement. We can verify the decay algebraically. As with the mass-spring damper, let’s try a solution . Substitution gives
When both gains are positive, both roots have negative real parts. If the square root is imaginary, their real part is . If it is real, it is smaller than , so even the root with the plus sign is negative. Thus every exponential mode decays.
For a concrete choice, let and . The roots are and , so, with time in seconds,
The constants and depend on our initial errors. Whatever those constants are, both terms go to zero. This establishes position convergence, but we still need to check velocity. Rearrange the first error equation:
For our chosen gains, substituting the position-error solution gives
where the coefficients 3 and 2 have units of inverse seconds. Velocity error is made of the same decaying modes, so it also goes to zero. More generally, the decaying solutions above make both and vanish, and hence make vanish.
Measurement Noise
If the position sensor reports , where is noise, the error equations become
Larger gains can speed up convergence, but also feed measurement noise more strongly into both estimates. We want errors to disappear at a useful rate without making the estimates too noisy, and how much noise we’re willing to accept in the estimate versus how quick the observer is to converge to the correct estimate as a tuning parameter.
For example, if the controller uses the estimate to control the vehicle, then an excessively noisy estimate will result in the vehicle motion being unacceptably jerky.
Matrix Form
Stacking the equations makes their structure visible:
Then the system and observer become
couples velocity into position. selects the quantity our sensor sees. distributes one sensor residual across two state corrections.
For states and sensor outputs, is , is , and is . Each column of describes how one sensor residual affects every state.
Choosing the error dynamics
Collect the errors into . With an exact model and noiseless measurements,
The eigenvalues of are the observer’s error poles. For the cart,
To choose poles at and , match this polynomial to . Thus and . Both position and velocity errors decay, even though velocity is never directly measured.
Simulation
Now that we’ve done all of the hard math for our cart, let’s simulate it! Choose starting positions and velocities for the cart and observer, and adjust both gains. The defaults use the example above. Only position is measured; true velocity is shown for comparison and is never given to the observer. No acceleration is applied in this simulation.
Press play or scrub the time slider. Changing a parameter pauses playback and recalculates the trajectory from your initial conditions at the selected time. Reset returns to time zero with your settings. Plot scales adapt to the full trajectory and remain fixed during playback.
Things to try:
- Set the initial estimated velocity equal to the real velocity, but start at the wrong position. Watch the velocity estimate temporarily move away from the truth before both errors decay.
- Match the starting positions but choose different velocities. A position residual develops even though the carts initially overlap, and it drives a velocity correction.
- Set . Position corrections alone cannot fix an incorrect velocity estimate.
- Set with . Errors oscillate without damping. Raise to make them decay.
- Try , for repeated error poles, then lower to see oscillatory convergence. Try negative starting velocities too; the equations work in either direction.
Observability and Detectability
An observer cannot recover arbitrary hidden quantities just because we add them to a vector. The measurements over time must contain information about them.
For the cart with no acceleration, . Two noiseless position readings at distinct times determine both the initial position and velocity. The system is observable. The matrix test expresses the same fact:
Its rank is two, so neither state direction is hidden. In an -state linear time-invariant system, stack and check for rank . Observability permits arbitrary observer pole placement.
If we measured only velocity, , adding a constant to the cart’s position would never change any reading. Absolute position is unobservable, and its error cannot be corrected by this sensor. More generally, a convergent observer needs detectability: any unobservable modes must already decay on their own.
How to choose a gain?
The Luenberger observer gives us a reusable structure - predict from a model, compare predicted and actual measurements, and feed the residual back into the estimate. We choose to get useful error dynamics. This is a powerful structure, but the gain we choose and the observer dynamics implied by it are somewhat arbitrary - we have no notion of whether the estimate we produce is optimal.
In the next note, we will explore the Kalman Filter, which defines what optimal means for our observer and how we can automatically compute the optimal gain for our observer.