Professional Documents
Culture Documents
f e a t u r e
Kalman Filtering
Originally developed for use in spacecraft navigation, the Kalman filter
turns out to be useful for many applications. It is mainly used to estimate
system states that can only be observed indirectly or inaccurately by the
system itself.
F
iltering is desirable in many situations in engineering and
embedded systems. For example, radio communication signals
are corrupted with noise. A good filtering algorithm can remove
the noise from electromagnetic signals while retaining the useful
information. Another example is power supply voltages.
Uninterruptible power supplies are devices that filter line volt-
ages in order to smooth out undesirable fluctuations that might otherwise
shorten the lifespan of electrical devices such as computers and printers.
The Kalman filter is a tool that can estimate the variables of a wide range
of processes. In mathematical terms we would say that a Kalman filter esti-
mates the states of a linear system. The Kalman filter not only works well in
practice, but it is theoretically attractive because it can be shown that of all
possible filters, it is the one that minimizes the variance of the estimation
error. Kalman filters are often implemented in embedded control systems
because in order to control a process, you first need an accurate estimate
of the process variables.
This article will tell you the basic concepts that you need to know to
design and implement a Kalman filter. I will introduce the Kalman filter
algorithm and we’ll look at the use of this filter to solve a vehicle navigation
problem. In order to control the position of an automated vehicle, we first
must have a reliable estimate of the vehicle’s present position. Kalman fil-
tering provides a tool for obtaining that reliable estimate.
Linear systems
In order to use a Kalman filter to remove noise from a signal, the process
that we are measuring must be able to be described by a linear system.
Many physical processes, such as a vehicle driving along a road, a satellite
orbiting the earth, a motor shaft driven by winding currents, or a sinusoidal
radio-frequency carrier signal, can be need a way to estimate the state x. This
vk +1 = vk + Tuk
approximated as linear systems. A lin- is where the Kalman filter comes in.
ear system is simply a process that can
be described by the following two That is, the velocity one time-step The Kalman filter theory
equations: from now (T seconds from now) will and algorithm
be equal to the present velocity plus Suppose we have a linear system model
State equation: the commanded acceleration multi- as described previously. We want to use
xk +1 = Axk + Buk + wk plied by T. But the previous equation the available measurements y to esti-
does not give a precise value for vk+1. mate the state of the system x. We know
Output equation: Instead, the velocity will be perturbed how the system behaves according to
yk = Cxk + zk by noise due to gusts of wind, pot- the state equation, and we have mea-
holes, and other unfortunate realities. surements of the position, so how can
The velocity noise is a random variable we determine the best estimate of the
In the above equations A, B, and C that changes with time. So a more real- state x? We want an estimator that gives
are matrices; k is the time index; x is istic equation for v would be: an accurate estimate of the true state
called the state of the system; u is a even though we cannot directly mea-
known input to the system; y is the vk +1 = vk + Tuk + vk~ sure it. What criteria should our esti-
measured output; and w and z are the mator satisfy? Two obvious require-
~
noise. The variable w is called the where vk is the velocity noise. A simi- ments come to mind.
process noise, and z is called the mea- lar equation can be derived for the First, we want the average value of
surement noise. Each of these quanti- position p: our state estimate to be equal to the
ties are (in general) vectors and there- average value of the true state. That is,
1
fore contain more than one element. pk +1 = pk + Tvk + T 2uk + pk~ we don’t want our estimate to be biased
The vector x contains all of the infor- 2 one way or another. Mathematically, we
mation about the present state of the would say that the expected value of
system, but we cannot measure x where pk~ is the position noise. Now the estimate should be equal to the
directly. Instead we measure y, which is we can define a state vector x that con- expected value of the state.
a function of x that is corrupted by the sists of position and velocity: Second, we want a state estimate
noise z. We can use y to help us obtain that varies from the true state as little
an estimate of x, but we cannot neces- pk as possible. That is, not only do we
xk =
sarily take the information from y at vk want the average of the state estimate
face value because it is corrupted by to be equal to the average of the true
noise. The measurement is like a politi- Finally, knowing that the measured state, but we also want an estimator
cian. We can use the information that output is equal to the position, we can that results in the smallest possible
it presents to a certain extent, but we write our linear system equations as variation of the state estimate.
cannot afford to grant it our total trust. follows: Mathematically, we would say that we
For example, suppose we want to want to find the estimator with the
model a vehicle going in a straight 1 T T 2 2 smallest possible error variance.
x k +1 = xk + uk + wk
line. We can say that the state consists 0 1 It so happens that the Kalman filter
T
of the vehicle position p and velocity v. is the estimator that satisfies these two
yk = [1 0]xk + zk
The input u is the commanded accel- criteria. But the Kalman filter solution
eration and the output y is the mea- does not apply unless we can satisfy
sured position. Let’s say that we are zk is the measurement noise due to certain assumptions about the noise
able to change the acceleration and such things as instrumentation errors. that affects our system. Remember
HANNAH BLAIR
measure the position every T seconds. If we want to control the vehicle with from our system model that w is the
In this case, elementary laws of physics some sort of feedback system, we need process noise and z is the measure-
say that the velocity v will be governed an accurate estimate of the position p ment noise. We have to assume that
by the following equation: and the velocity v. In other words, we the average value of w is zero and the
1800
Kk = APk C T (CPk C T + Sz )
−1
1600
xˆ k +1 = ( Axˆ k + Buk ) + Kk ( yk +1 − Cxˆ k )
1400
Pk +1 = APk AT + Sw − APk C T Sz−1CPk AT
1200
Position (feet)
Vehicle navigation
average value of z is zero. We have to Measurement noise covariance Now consider the vehicle navigation
Sz = E( z z )
further assume that no correlation T problem that we looked at earlier. A
k k
exists between w and z. That is, at any vehicle is traveling along a road. The
time k, wk, and zk are independent ran- position is measured with an error of
dom variables. Then the noise covari- where wT and zT indicate the transpose 10 feet (one standard deviation). The
ance matrices Sw and Sz are defined as: of the w and z random noise vectors, commanded acceleration is a constant
and E(·) means the expected value. 1 foot/sec2. The acceleration noise is
Process noise covariance Now we are finally in a position to 0.2 feet/sec2 (one standard devia-
Sw = E(wk wkT )
look at the Kalman filter equations. tion). The position is measured 10
There are many alternative but equiva- times per second (T = 0.1). How can
1 0.1 0.005
x k +1 = xk + 0.1 uk + wk
50
0 1
Velocity (feet/sec)
yk = [1 0]xk + zk 40
30
Because the standard deviation of the
measurement noise is 10 feet, the Sz
matrix is simply equal to 100. 20
Now we need to derive the Sw
matrix. Since the position is propor- 10
tional to 0.005 times the acceleration,
and the acceleration noise is 0.2 0
feet/sec2, the variance of the position 0 10 20 30 40 50 60
Time (sec)
noise is (0.005)2·(0.2)2 = 10-6.
Similarly, since the velocity is propor-
tional to 0.1 times the acceleration,
the variance of the velocity noise is
(0.1)2·(0.2)2 = 4·10-4. Finally, the
covariance of the position noise and
velocity noise is equal to the standard
deviation of the position noise times
the standard deviation of the velocity
noise, which can be calculated as
(0.005·0.2)·(0.1·0.2) = 2·10-5. We
can combine all of these calculations
to obtain the following matrix for Sw:
p
Sw = E( xx T ) = E [ p v]
v
p2 pv 10 −6 2 × 10 −5
= E =
vp v 2 2 × 10 −5 4 × 10 −4
figure;
Historical perspective
plot(t,pos-posmeas, t,pos-poshat);
The Kalman filter was developed by
grid;
Rudolph Kalman, although Peter
xlabel(‘Time (sec)’);
Swerling developed a very similar algo-
ylabel(‘Position Error (feet)’);
rithm in 1958. The filter is named after
title(‘Figure 2 - Position Measurement Error and Position Estimation Error’);
Kalman because he published his results
in a more prestigious journal and his
figure;
work was more general and complete.
plot(t,vel, t,velhat);
Sometimes the filter is referred to as the
grid;
Kalman-Bucy filter because of Richard
xlabel(‘Time (sec)’);
Bucy’s early work on the topic, conduct-
ylabel(‘Velocity (feet/sec)’);
ed jointly with Kalman.
title(‘Figure 3 - Velocity (True and Estimated)’);
The roots of the algorithm can be
traced all the way back to the 18-year-
figure;
old Karl Gauss’s method of least squares
plot(t,vel-velhat);
in 1795. Like many new technologies,
grid;
the Kalman filter was developed to solve
xlabel(‘Time (sec)’);
a specific problem, in this case, space-
ylabel(‘Velocity Error (feet/sec)’);
craft navigation for the Apollo space
title(‘Figure 4 - Velocity Estimation Error’);
program. Since then, the Kalman filter
has found applications in hundreds of
diverse areas, including all forms of nav-
The Kalman filter not only works rather than the “average” estimation igation (aerospace, land, and marine),
well but is theoretically attractive. It error? This problem is solved by the nuclear power plant instrumentation,
can be shown that the Kalman filter H¥ filter. The H¥ filter (pronounced demographic modeling, manufactur-
minimizes the variance of the esti- “H infinity” and sometimes written ing, the detection of underground
mation error. But what if we have a as H¥ ) is an alternative to Kalman radioactivity, and fuzzy logic and neural
problem where we are more con- filtering that was developed in the network training. esp
cerned with the worst case estima- 1980s. It is less widely known and
tion error? What if we want to mini- less commonly applied than the Dan Simon is a professor in the electrical
mize the “worst” estimation error Kalman filter, but it has advantages and computer engineering department at