See discussions, stats, and author profiles for this publication at: https://www.researchgate.
net/publication/273381901
Simple Example of Applying Extended Kalman Filter
Conference Paper · March 2014
CITATION READS
1 15,223
3 authors:
Keatmanee Chadaporn Junaid Baber
Japan Advanced Institute of Science and Technology University of Balochistan
7 PUBLICATIONS 14 CITATIONS 30 PUBLICATIONS 133 CITATIONS
SEE PROFILE SEE PROFILE
Maheen Bakhtyar
Asian Institute of Technology
26 PUBLICATIONS 93 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
Facial Expression Recognition View project
All content following this page was uploaded by Keatmanee Chadaporn on 11 March 2015.
The user has requested enhancement of the downloaded file.
Simple Example of Applying
Extended Kalman Filter
Chadaporn Keatmanee Junaid Baber Maheen Bakhtyar
Faculty of Information Technology Computer Science Computer Science
Sripatum University and Information Management and Information Management
Bangkok, Thailand Asian Institute of Technology Asian Institute of Technology
Email: chadaporn.ke@spu.ac.th Pathumtani, Thailand Pathumtani, Thailand
Email: junaid.j.baber@ait.asia Email: maheen.bakhtyar@ait.asia
Abstract—Kalman Filter (KF) is a well-known algorithm for measured value, unsure of its accuracy, is a linear combination
estimation and prediction especially when data has a lot of noise. of the measurement noise and the signal value and both of
KF is used for linear transition functions whereas under non- these are considered to be Gaussian. Both noise and measured
linear transition, Extended Kalman Filter(EKF) is used. The EKF
is also considered to be the de-facto standard. There are tons noise are statistically independent in the process.
of papers about EKF however very few of them show working Even though the entities A, B and H are general form ma-
of the algorithm. The purpose of this paper is to explain how
trices, in most of our models for signal processing problems,
to apply EKF on simple application, explaining model creation,
substitution, simulation and illustration of adjusting an accuracy we treat these entities to be just numeric values. In addition
of the model. to further easing out, even these values may change between
states; it can be assumed them to be constant, most of the
Keywords:Kalman Filter, Extended Kalman Filter, Kalman times.
filter application
Upon being sure that our system fits into this model, which
I. I NTRODUCTION was difficult to be fitted in the first time, estimation of the mean
KF is a recursive algorithm used for estimating a dynamic and standard deviation of the noise functions wk and vk would
system which lacks data. The cause of lack of data is noise, or be the only thing left to do. Even though in reality no signal is
environment, example of such systems includes: autonomous pure Gaussian, we may assume it with some approximation.
and assisted navigation system. It uses prior knowledge to This will not pose a problem, as we will see that the Kalman
predict the past, present, as well as future state of system. Filtering Algorithm tries to converge into correct estimations,
The advantage of KF is that the data is updated in each and even if the Gaussian noise parameters are poorly estimated.
every iteration so that we dont need much memory to keep all KF results from the continuously updating the estimation
data of the system for prediction. The only difference between data based on prior knowledge in each and every iteration of
KF and EKF is that for EKF we have to linearize, non-linear prediction and filtering[4] . The changing in each iteration is
function using Jacobian matrix then we could use the rest of derived and interpreted in the term of Gaussian probability
process of the KF algorithm. density functions. The innovation process of KF associates
KF is a popular recursive algorithm for motion prediction[1] with the filter, that represents the novel prediction of informa-
as this simple application which has purpose to predict the tion in noisy environment conveyed to the state estimate by
next position of the bug movement walking in straight line. using data in the last system measurement.
The principle of Kalman Filter is to find the probability of
When either the system state (a state model) dynamics
the hypothesis of predicted state is given by hypothesis of
or the observation (measurement model) dynamics is nonlin-
prior state and then using the data from measurement sensor
ear, the conditional probability density functions that provide
to correct the hypothesis to get the best estimation for each
the minimum mean-square estimate are no longer Gaussian.
time. Basically, Applying KF has to concern about model
The optimal non-linear filter propagates these non-Gaussian
creation including state and measurement model[2] as shown
functions and evaluate their mean, which represents an high
in equation 1 and 2.
computational burden. A non-optimal approach to solve the
problem, in the frame of linear filters, is the Extended Kalman
xk+1 = Ax + Buk + wk (1) filter (EKF).
The EKF implements a KF for a system dynamics that
zk = Hxk + vk (2)
results from the linearization of the original non-linear filter,
The first equation is linear stochastic equation means that KF around the previous state estimates using Jacobian matrix
each xk is evaluated[3]. The second equation explains that any sometime call only Jacobian.
II. E XTENDED K ALMAN F ILTER
The most important part of applying EKF is model creation
using knowledge of mathematics to create transition function
which is non-linear for unknown parameter in each state of
estimation. There are 2 models for EKF including
State Model xk+1 = f (xk , uk + wk ) (3)
Where
x is the state model which composes of parameters using for
prediction in each state
xk+1 is the next state that we should get the predicted data
from using transition function which is non-linear function
uk is the control data which is optional
wk is Gaussian white noise
Measurement Model zk = h(xk + vk ) (4)
Where
zk is the measurement model including parameters
which data come from various kinds of sensors
such as thermal sensor and infrared sensor
vk is Gaussian white noise Fig. 1. A complete process of the operation of the Extended Kalman Filter[2]
The process of the recursive algorithm, EKF is depicted III. A PPLYING E XTENDED K ALMAN F ILTER
in figure1. There are 2 main parts including prediction and
correction state. At the correction state, using x̂−k and Pk
− For applying both KF and EKF, knowledge of mathematics,
− physics, probability and statistics is required for model cre-
obtained from prediction state where x̂k is calculated by using
state transition model and Pk− is user defined, to calculate ation which is the most important. In this paper, we examine
Kalman Gain or K which represents the trustable value of applying of simple applicant using bug movement in the
state model and measurement variable. In case, R approaches straight line. There are 6 steps to apply EKF [5] and described
to 0, it means measurement variable is more trustable than state as an example below:
model, but if Pk− approaches to 0, then it is vice versa. After
that, estimated data is updated based on K values. Finally, the
error covariance is updated for next iteration. Therefore, all
parameters are updated in each and every iteration hence; pre-
dicted and estimated data continue to become more accurate.
The important feature of EKF is linearization of non-linear
function f and h using Jacobian matrix which almost is first
order derivative. The example of calculating Jacobian matrix
for State transition matrix is shown as equation (5)
∂f[i]
A[i,j] = (x̂k , uk , 0) (5)
∂x[i]
The Jacobian of functions fi (x1 , x2 , ..., xn ), i = 1, 2, ..., n of
Fig. 2. A bug is walking in a stright line
real variables xi is the determinant of the matrixwhose ith
row lists all the first-order partial derivatives of the function
fi (x1 , x2 , ..., xn ). 1) Understanding the current system status
The estimated values for state model and measurement The simple application as an example is shown in
model come from equations shown below figure 2 consisting of a dynamic system. Assume a
bug is moving away from the sink measuring the angle
xk+1 ≈ x̃k+1 + A(xk − x̂k ) + W wk (6) and velocity of the moving bug in a straight line. The
movement is linear and the only parameter changing is
zk ≈ z̃k + H(xk − x̂k ) + V vk (7) the distance of the bug from the sink and our objective
is to estimate the lateral distance between them.A lot Estimation of dl
of noise during the measurement is expected due to 3
the measuring equipment such as a digital distance
meter. Cosine function is used to create the state model 2.5
and hence, we apply EKf and not KF, sine being a
non-linear function. 2
2) Modeling the state process
1.5
The state model is shown in equation 8 where xt
represents the current state and xt+1 denotes the next
state that needs to be predicted. The defined transition 1
function is dl + λ in the model that estimates the lateral
distance of the bug from the sink. 0.5
True value
t t 0 Measured value
dl dl + λ
xt = θt , xt+1 = θt (8) Estimated value
v v −0.5
0 10 20 30 40 50 60
Where ,
Fig. 3. A successfully working model simulation with R=0.05
x is the state model
dl is the lateral distance between edge of sink and
shown in figure 3. The model successfully works and
the bug at the nearest point to the bug origin the estimated value is very close to the actual true value
θ is the tangent angle of the edge of sink at the point even when a lot of noise is introduced.
closest to the bug origin 6) Filter Refinement The EKF is refined by changing
v is velocity of the bug movement the value of the noise parameters such as P (state
variance variable) or R (measurement variance variable).
Transition matrix At that is obtained from Jacobain In our experiment we change the values of R, being
matrix for linearization is shown in equation 9 a trustworthy candidate of measurement variable, and
analyze its effect.
1 ∆t ∗ v ∗ (−sinθ) ∆t ∗ cosθ
The results of our simulation(figure 3, figure 4 and figure
At = 0 1 0 (9) 5) depicts the effect of varying the values of R In figure
0 0 1 3, R is assigned the value 0.05 that means medium level
of trust in the measured value by the sensor, moreover
To keep the demonstration simple, we only discuss it is suitable for successfully model.
the lateral distance prediction (dl ) keeping the distance In figure 4, R is given the value 0.001 depicting a trust in
changing and the rest of the values are kept constant. the measured variables obtained from the sensor because
it is approached to 0 so the estimated value is following
3) Measurement process modeling the measured value and not the actual true value.
The measurement parameters are constant keeping the In figure 5, R is assigned the value 0.1, quite different
example simple. They are the constant values obtained from 0, depicting a no trust state on the measured
from the digital distance meter. variable. Therefore, the estimated value is based on the
z is value measured using digital distance meter results obtained from the transition function in the state
model.
H is 1 because no unit transformation
Defining the noise parameters show that every parameter
in EKF is important for adjusting an accuracy level of
4) Noise modeling Kalman and extended Kalman filter the model.
use Gaussian white noise that makes the variance and IV. C ONCLUSION
covariance meaningful. Noise is introduced in the filter
Our results show that the novel EKF algorithm is working
as in the matlab code1 .
quite satisfactory even in the presence of high noise from the
sensor. The estimated values are obtained from EKF using
5) Filter Testing Matlab is used to simulate the execution
state and transition model. Both the models are extremely
of EKF algorithm. The results of our simulation are
important for the prediction. If any of these models is
1 can be downloaded from http://chadaphone.wordpress.com/2012/10/19/ incorrect then it is not useful and meaningful for the EKF.
simple-example-of-applying-extended-kalman-implementation-with-matlab/ Accuracy of the system can be increased if the model is
Estimation of dl Estimation of dl
2.5 2.5
2 2
1.5 1.5
1 1
0.5 0.5
True value True value
0 Measured value 0 Measured value
Estimated value Estimated value
−0.5 −0.5
0 10 20 30 40 50 60 0 10 20 30 40 50 60
Fig. 4. The simulation with R=0.001 Fig. 6. The simulation with R=0.08
Estimation of dl
R EFERENCES
2.5
[1] R. Azuma and G. Bishop, “Improving static and dynamic registration in
an optical see-through hmd,” in Proceedings of the 21st annual conference
on Computer graphics and interactive techniques, 1994.
2 [2] G. Welch and G. Bishop, “An introduction to the kalman filter,” 1995.
[3] B. Esme, “Kalman filter for dummies.” [Online]. Available: http:
//bilgin.esme.org/BitsBytes/KalmanFilterforDummies.aspx
1.5 [4] C. Derivation, , and M. I. Ribeiro, “Kalman and extended kalman
filters:,” 2004. [Online]. Available: http://www.isr.ist.utl.pt/∼mir
[5] “Kalman filter applications.” [Online]. Available: www.cs.unc.edu/
1 ∼welch/kalman/media/pdf/kftool models.pdf
0.5
True value
0 Measured value
Estimated value
−0.5
0 10 20 30 40 50 60
Fig. 5. The simulation with R=0.1
kept simple at first and then tested for the complex cases.
Moreover, the noise parameters also play a very important
role and the model can be defined by adjusting the parameters
such as R and P to make the model more accurate.
ACKNOWLEDGMENT
I would like to thank EEAAT Conference Publishing for
providing their guidelines and opportunity of sharing the
knowledge. I sincerely thank Associate Professor Matthew N.
Dailey for his valuable comments, suggestions, and motiva-
tion.
View publication stats