Sunteți pe pagina 1din 6

47

Chapter 5. Introduction to Kalman filter


5.1 Introduction
Deriving or understanding Kalman filter requires some depth of knowledge in mathematics. Just
thinking of some fields of mathematics being used, like linear algebra, statistics, optimization
theory, and etc, you could easily figure out that it is not easy. But would all of these still be
necessary for just using Kalman filter? The required knowledge for just using Kalman filter might
not be the same as that required to perform an academic research on it.
However, most of the books on Kalman filter take the approach of mathematical proof and
derivation. Because of this, most of the people who heard the fame of Kalman filter and try to use
it start to learn but fall back with discouragement. Moreover, they dont even get any closer to
Kalman filter itself but get discouraged at the part describing some background knowledge, which
is normally placed in the beginning of the literature. Let us consider this with some strict judgment.
This technique has already been proven throughout decades1 and do we still need to know the
whole process of derivation?
This question was the motivation for writing this book. The algorithm for Kalman filter is already
established in clear manner. All we have to do is to follow the procedure according to the
algorithm. You dont have to know where the algorithm came from. If you know theoretical
background, it might help you better when you encounter a problem. However, the problem you
encounter during the application of Kalman filter seldom has its root in the algorithm itself. In
most cases, it is from system model. Therefore, if it is not a very special case, there is no problem
at all to apply Kalman filter even though you dont know how to derive it.

It was 1960 when the first paper on Kalman filter was presented to the world.

48

Also, the algorithm for Kalman filter is not complicated, either. It is more complicated than the
low-pass filter we saw in Part I, but absolutely not beyond our capability. Just a few additional
steps of computing and formulae are included. And one of the equations we have seen in Part I is
among them. This means there is a connection between the concepts of Kalman filter and low-pass
filter. This will be discussed in detail in Chapter 6.
Emphasizing once again, it is not difficult at all to apply Kalman filter algorithm to real world
problem without knowing its theoretical background. By understanding the explanation on the
algorithm in Part II and going through various examples in Part III, your fear towards Kalman
filter will melt away like snow.
Shall we go on, now?

5.2 Kalman filter algorithm


It is well known that it is good to dry the hay while there is sunshine and strike the iron while it
is hot. Let us directly face Kalman filter now. In Figure 5.1, whole computational process for
Kalman filter is laid out in a schematic diagram. Although it bears the name filter, Kalman filter
would rather be better considered as a computer algorithm. For now it may seem quite confusing
to you (this is natural, so do not panic), but please take a close look at it.
First of all, it seems much complicated than the low-pass filter we have seen in the previous
chapter. A 1st order low-pass filter is expressed as a very simple polynomial made of measurement
and previous estimate. However, Kalman filter seems somewhat different. There are not only more
computing steps but also numerous variables and computation itself seems to be more complicated.
Dont be surprised or alarmed because of this. At a first glance it seems very complicated, but
decomposing it, implementation is much simple than your imagination. Furthermore, the core
principle is similar to that of the 1st order low-pass filter we have seen in the previous chapter so it
is not difficult to understand. In fact, it is not an exaggeration to say Kalman filter is a sequential
execution of steps I through IV in Figure 5.1. Moreover, implementation could be done by just
following these steps mechanically without complete understanding of the meaning of each
equation.
Here, the procedure is divided into four but there are some cases with abbreviated procedure or
different style of beginning for the improvement of computational efficiency or readability of the
code. Nonetheless, the essence of the algorithm remains the same.

49

0. Set initial values:

x0 , P0

. Predict state & error covariance:

xk Ax k 1
Pk APk 1 AT Q

. Compute Kalman gain:

K k Pk H T ( HPk H T R) 1

Measurement

zk

. Compute the estimate:

xk xk K k ( z k Hx k )

. Compute the error covariance:

Pk Pk K k HPk

Figure 5.1 Kalman filter algorithm

Estimate

x k

50

In the figure, the part in the dashed box is Kalman filter algorithm. The structure is very simple. It
receives only one input (measurement, zk ) and returns one output (estimate, xk ).2 Internal process
is done through a four-step computation.
While analyzing the algorithm presented in Figure 5.1, it would be better not paying too much
attention to the subscript k in the name of each variable. It just serves to clarify that Kalman filter
algorithm is executed recursively and thats it. No meaning beyond that. If that subscript k makes
you confused, it is all right to ignore it completely. On the other hand, the superscript - has an
important meaning. Any variable bearing this has totally different meaning from the one without it
with same name.
Now let us look into the computational procedure of the algorithm in detail. The first step is for

prediction. The two variables xk and Pk , which will be used throughout the Steps II through IV,
are computed in this step. The superscript - means predicted value. The formulae in this
prediction step have very close relationship with system model. This will be discussed in detail
later.

In Step II, Kalman gain( Kk ) is being computed. The variable Pk computed in the previous step is
used. H and R are the values preset outside Kalman filter.
In Step III, an estimate is computed from a measurement given as input. It has not been clearly
revealed yet, but the formula in this step is related to low-pass filter. This will be explained later,

as well. The variable xk is the one computed in Step I.


In Step IV, error covariance is computed. Error covariance is a measure indicating how accurate
the estimate is. Normally, decision to trust and use or discard the estimate computed in the
previous step is made based on the review of the error covariance.
We have just skimmed through the whole procedure of Kalman filter algorithm. At this point the
concept might not have been grasped firmly in your mind, but if you read again after finishing the
remaining chapters of Part II, it will be straightforward. In addition to skimming through the whole
process, all the variables used in the algorithm are summarized in the following table. Categorizing
the variables according to their usage helps overall understanding or implementation of the
algorithm.

From now on, estimate will be denoted as

xk instead of xk .

51

External input

zk (measurement)

Final output

xk (estimate)

System model

A , H, Q, R

For internal computation

xk , Pk , Pk , Kk

Explanation for the variables in System model category, shown as A , H , Q , and R , were not
given so far. These should be set before implementing Kalman filter. In other words, these
variables are not computed or assumed in Kalman filter. These are the values preset by the user
according to the characteristics of the system and purpose of Kalman filter. Therefore, you could
assume that the values of these variables are already known and dont have to worry about them
when studying Kalman filter algorithm itself. However, please keep in mind that the performance
of Kalman filter is closely tied to these values. The relationship between system model and
Kalman filter will be discussed in detail in Chapter 8.
In the table above, all the variables except those categorized as System model could not be
changed arbitrarily by the designer because these are measured or computed by the algorithm.
Therefore, when the performance of Kalman filter designed is not satisfactory, the only variables
that could be adjusted are those four variables related to system modeling. In other words, the four
variables of the system model are the design factors. The performance of Kalman filter will be
determined by these. For your reference, the performance of Kalman filter gets better as your
system model gets closer to the actual system you are modeling.
Kalman filter algorithm laid out in Figure 5.1 has been divided into four steps, but if we divide this
according to the meaning, it becomes two parts.

Prediction process
Step I of Figure 5.1 falls into this process. The estimate and error covariance from the previous
time point ( xk 1 and Pk 1 , respectively) are used as input and prediction of these two at the

52

current time point ( xk and Pk , respectively) are returned as final result. These values are used
for estimation process. The system model parameters used in prediction process are A and Q .

Estimation process
In Kalman filter algorithm, Steps II, III, and IV fall into this process. The results of estimation
process are the estimate( xk ) and error covariance( Pk ). In this process, measurement( zk ) is also

included as an input in addition to the predictions from prediction process ( xk and Pk ). System
model variables used in estimation process are H and R .

From this perspective, Kalman filter could be summarized as following.


1. Predict state and error covariance for next time point, based on system model ( A and Q ):

xk and Pk
2. Compensate the difference between measurement and prediction, and compute new
estimate. This estimate is the final result of Kalman filter: xk and Pk
3. Loop through those two steps above.

Following the conceptual categorization shown above, prediction process and estimation process
will be presented in Chapters 6 and 7, respectively, in this book. This type of categorization is
helpful for understanding Kalman filter algorithm. Finally, system model will be discussed in
Chapter 8. System model is so important that it is not an exaggeration to say it determines the
performance of Kalman filter.

S-ar putea să vă placă și