SlideShare a Scribd company logo
1 of 28
Download to read offline
1
ACM 116: The Kalman filter
• Example
• General Setup
• Derivation
• Numerical examples
– Estimating the voltage
– 1D tracking
– 2D tracking
2
Example: Navigation Problem
• Truck on “frictionless” straight rails
• Initial position X0 = 0
• Movement is buffeted by random accelerations
• We measure the position every ∆t seconds
• State variables (Xk, Vk) position and velocity at time k∆t
Xk = Xk−1 + Vk−1∆t + ak−1∆t2
/2
Vk = Vk−1 + ak−1∆t
where ak−1 is a random acceleration
• Observations
Yk = Xk + Zk
where Zk is a noise term.
The goal is to estimate the position and velocity at all times.
3
General Setup
Estimation of a stochastic dynamic system
• Dynamics
Xk = Fk−1Xk−1 + Bk−1uk−1 + Wk−1
– Xk: state of the system at time k
– uk−1: control-input
– Wk−1: noise
• Observations
Yk = HkXk + Zk
– Yk is observed
– Zk is noise
• The noise realizations are all independent
• Goal: predict state Xk from past data Y0, Y1, . . . , Yk−1.
4
Derivation
Derivation in the simpler model where the dynamics is of the form
Xk = ak−1Xk−1 + Wk−1
and the observations
Yk = Xk + Zk
The objective is to find, for each time k, the minimum MSE filter based on
Y0, Y1, . . . , Yk−1
ˆXk =
k
j=1
h
(k−1)
j Yk−j
To find the filter, we apply the orthogonality principle
E((Xk −
k
j=1
h
(k−1)
j Yk−j)Y ) = 0, = 0, 1, . . . , k − 1.
5
Recursion
The beautiful thing about the Kalman filter is that one can almost deduce the
optimal filter to predict Xk+1 from that predicting Xk.
h
(k)
j+1 = (ak − h
(k)
1 )h
(k−1)
j , j = 1, . . . , k.
Given the filter h(k−1)
, we only need to find h
(k)
1 to get the filter at the next
time step.
6
How to find h
(k)
1 ?
Observe that the next prediction is equal to
ˆXk+1 = h
(k)
1 Yk +
k
j=1
(ak − h
(k)
1 )h
(k−1)
j Yk−j
= ak
ˆXk + h
(k)
1 (Yk − ˆXk)
Interpretation
ˆXk+1 = ak
ˆXk + h
(k)
1 Ik
• ak
ˆXk is the prediction based on the estimate at time k
• h
(k)
1 Ik is a corrective term which is available since we now see Yk
– h
(k)
1 is called the gain
– Ik = Yk − ˆXk is called the innovation
7
Error of Prediction
To find h
(k)
1 , we look at the error of prediction
k = Xk − ˆXk
We have the recursion
k+1 = (ak − h
(k)
1 ) k + Wk − h
(k)
1 Zk
• 0 = Z0
• E( k) = 0
• E( 2
k+1) = [ak − h
(k)
1 ]2
E( 2
k) + E(W 2
k ) + [h
(k)
1 ]2
E(Z2
k)
8
To minimize the MSE k+1, we adjust h
(k)
1 so that
∂h
(k)
1
E( 2
k+1) = 0 = −2(ak − h
(k)
1 )E( 2
k) + 2h
(k)
1 E(Z2
k)
which is given by
h
(k)
1 =
akE( 2
k)
E( 2
k) + E(Z2
k)
Note that this gives the recurrence relation
E( 2
k+1) = ak(ak − h
(k)
1 )E( 2
k) + E(W 2
k )
9
The Kalman Filter Algorithm
• Initialization ˆX0 = 0, E( 2
0) = E(Z2
0 )
• Loop: for k = 0, 1, . . .
h
(k)
1 =
akE( 2
k)
E( 2
k) + E(Z2
k)
ˆXk+1 = ak
ˆXk + h
(k)
1 (Yk − ˆXk)
E( 2
k+1) = ak(ak − h
(k)
1 )E( 2
k) + E(W 2
k )
10
Benefits
• Requires no knowledge about the structure of Wk and Zk (only variances)
• Easy implementation
• Many applications
– Inertial guidance system
– Autopilot
– Satellite navigation system
– Many others
11
General Formulation
Xk = Fk−1Xk−1 + Wk−1
Yk = HkXk + Zk
The covariance of Wk is Qk and that of Zk is Rk.
Two variables:
• ˆXk|k estimate of the state at time k based upon Y0, . . . , Yk−1
• Ek|k error covariance matrix, Ek|k = Cov(Xk − ˆXk|k)
12
Prediction
ˆXk+1|k = Fk
ˆXk|k−1
Ek+1|k = FkEk|k−1F T
k + Qk
Update
Ik = Yk − Hk
ˆXk+1|k Innovation
Sk = HkEk+1|kHT
k + Rk Innovation covariance
Kk = Ek+1|kHT
k S−1
k Kalman Gain
ˆXk+1|k+1 = ˆXk+1|k + KkIk Updated state estimate
Ek+1|k+1 = (Id − KkHk)Ek+1|k Updated error covariance
13
Estimating Constant Voltage
We wish to estimate some voltage which is almost constant except for some
small random fluctuations. Our measuring device is imperfect (e.g. because of
a poor A/D conversion). The process is governed by:
Xk = X0 + Wk, k = 1, 2, . . .
with X0 = 0.5V , and the measurements are
Zk = Xk + Vk, k = 1, 2, . . .
where Wk, Vk are uncorrelated Gaussian white noise processes, with
R := Var(Vk) = 0.01, Var(Wk) = 10−5
.
14
0 5 10 15 20 25 30 35 40 45 50
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
Accurate knowledge of measurement variance, Rest
=R=0.01
Iteration
Voltage
estimate
exact process
measurements
15
0 5 10 15 20 25 30 35 40 45 50
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
Optimistic estimate of measurement variance, Rest
=0.0001
Iteration
Voltage
estimate
exact process
measurements
16
0 5 10 15 20 25 30 35 40 45 50
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
Pessimistic estimate of measurement variance, Rest
=1
Iteration
Voltage
estimate
exact process
measurements
17
1D Tracking
Estimation of the position of a vehicle.
Let X be a state variable (position and speed), and A is a transition matrix
A =


1 ∆t
0 1

 .
The process is governed by:
Xn+1 = AXn + Wn
where Wn is a zero-mean Gaussian white noise process. The observation is
Yn = CXn + Zn
where the matrix C only picks up the position and Zn is another zero-mean
Gaussian white noise process independent of Wn.
18
0 5 10 15 20 25
!4
!2
0
2
4
6
8
Time
Position
Estimation of a moving vehicle in 1!D.
exact position
measured position
estimated position
19
2D Example
General setup
X(t + 1) = F X(t) + W (t), W ∼ N(0, Q),
Y (t) = HX(t) + V (t), V ∼ N(0, R)
Moving particle at constant velocity subject to random perturbations in its
trajectory. The new position (x1, x2) is the old position plus the velocity
(dx1, dx2) plus noise w.







x1(t)
x2(t)
dx1(t)
dx2(t)







=







1 0 1 0
0 1 0 1
0 0 1 0
0 0 0 1














x1(t − 1)
x2(t − 1)
dx1(t − 1)
dx2(t − 1)







+







w1(t − 1)
w2(t − 1)
dw1(t − 1)
dw2(t − 1)







20
Observations
We only observe the position of the particle.


y1(t)
y2(t)

 =


1 0 0 0
0 1 0 0









x1(t)
x2(t)
dx1(t)
dx2(t)







+


v1(t)
v2(t)


Source: http://www.cs.ubc.ca/∼murphyk/Software/Kalman/kalman.html
21
Implementation
% Make a point move in the 2D plane
% State = (x y xdot ydot). We only observe (x y).
% This code was used to generate Figure 17.9 of
% "Artificial Intelligence: a Modern Approach",
% Russell and Norvig, 2nd edition, Prentice Hall, in preparation.
% X(t+1) = F X(t) + noise(Q)
% Y(t) = H X(t) + noise(R)
ss = 4; % state size
os = 2; % observation size
F = [1 0 1 0; 0 1 0 1; 0 0 1 0; 0 0 0 1];
H = [1 0 0 0; 0 1 0 0];
Q = 1*eye(ss);
R = 10*eye(os);
initx = [10 10 1 0]’;
initV = 10*eye(ss);
22
seed = 8; rand(’state’, seed);
randn(’state’, seed);
T = 50;
[x,y] = sample_lds(F,H,Q,R,initx,T);
23
Apply Kalman Filter
[xfilt,Vfilt] = kalman_filter(y,F,H,Q,R,initx,initV);
dfilt = x([1 2],:) - xfilt([1 2],:);
mse_filt = sqrt(sum(sum(dfilt.ˆ2)))
figure;
plot(x(1,:), x(2,:), ’ks-’);
hold on
plot(y(1,:), y(2,:), ’g*’);
plot(xfilt(1,:), xfilt(2,:), ’rx:’);
hold off
legend(’true’, ’observed’, ’filtered’, 0)
xlabel(’X1’), ylabel(’X2’)
24
!40 !30 !20 !10 0 10 20
10
20
30
40
50
60
70
X1
X2
true
observed
filtered
25
0 20 40 60 80 100 120 140
0
20
40
60
80
100
120
140
X1
X2
true
observed
filtered
26
Apply Kalman Smoother
[xsmooth, Vsmooth] = kalman_smoother(y,F,H,Q,R,initx,initV);
dsmooth = x([1 2],:) - xsmooth([1 2],:);
mse_smooth = sqrt(sum(sum(dsmooth.ˆ2)))
figure;
hold on
plot(x(1,:), x(2,:), ’ks-’);
plot(y(1,:), y(2,:), ’g*’);
plot(xsmooth(1,:), xsmooth(2,:), ’rx:’);
hold off
legend(’true’, ’observed’, ’smoothed’, 0)
xlabel(’X1’), ylabel(’X2’)
27
!!0 !#0 !20 !10 0 10 20
10
20
#0
!0
50
'0
(0
)1
)2
*+,-
./0-+1-2
03..*4-2
28
0 20 40 60 80 100 120 140
0
20
40
60
80
100
120
140
X1
X2
true
observed
smoothed

More Related Content

What's hot

Sliding Mode Observers
Sliding Mode ObserversSliding Mode Observers
Sliding Mode ObserversSolo Hermelin
 
ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)Antonin Hoskovec
 
Reduced order observers
Reduced order observersReduced order observers
Reduced order observersSolo Hermelin
 
Chapter 11 kinematics of particles
Chapter 11 kinematics of particlesChapter 11 kinematics of particles
Chapter 11 kinematics of particlesRogin Beldeneza
 
Equation of motion of a variable mass system3
Equation of motion of a variable mass system3Equation of motion of a variable mass system3
Equation of motion of a variable mass system3Solo Hermelin
 
12EE62R11_Final Presentation
12EE62R11_Final Presentation12EE62R11_Final Presentation
12EE62R11_Final PresentationAmritesh Maitra
 
Equation of motion of a variable mass system1
Equation of motion of a variable mass system1Equation of motion of a variable mass system1
Equation of motion of a variable mass system1Solo Hermelin
 
Kinetics kinematics
Kinetics kinematicsKinetics kinematics
Kinetics kinematicsshanth_95
 
Ppt of aem some special function
Ppt of aem some special functionPpt of aem some special function
Ppt of aem some special functionNirali Akabari
 
Passivity-based control of rigid-body manipulator
Passivity-based control of rigid-body manipulatorPassivity-based control of rigid-body manipulator
Passivity-based control of rigid-body manipulatorHancheol Choi
 
Daa divide-n-conquer
Daa divide-n-conquerDaa divide-n-conquer
Daa divide-n-conquersankara_rao
 
Viktor Urumov - Time-delay feedback control of nonlinear oscillators
Viktor Urumov -  Time-delay feedback control of nonlinear oscillatorsViktor Urumov -  Time-delay feedback control of nonlinear oscillators
Viktor Urumov - Time-delay feedback control of nonlinear oscillatorsSEENET-MTP
 

What's hot (20)

Ece4510 notes04
Ece4510 notes04Ece4510 notes04
Ece4510 notes04
 
Control assignment#4
Control assignment#4Control assignment#4
Control assignment#4
 
Sliding Mode Observers
Sliding Mode ObserversSliding Mode Observers
Sliding Mode Observers
 
ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)ML Reading Group (Intro to Quantum Computation)
ML Reading Group (Intro to Quantum Computation)
 
Reduced order observers
Reduced order observersReduced order observers
Reduced order observers
 
Asmm portal by hafiz
Asmm portal by hafizAsmm portal by hafiz
Asmm portal by hafiz
 
Chapter 11 kinematics of particles
Chapter 11 kinematics of particlesChapter 11 kinematics of particles
Chapter 11 kinematics of particles
 
Lecture13 controls
Lecture13  controls Lecture13  controls
Lecture13 controls
 
Equation of motion of a variable mass system3
Equation of motion of a variable mass system3Equation of motion of a variable mass system3
Equation of motion of a variable mass system3
 
12EE62R11_Final Presentation
12EE62R11_Final Presentation12EE62R11_Final Presentation
12EE62R11_Final Presentation
 
Equation of motion of a variable mass system1
Equation of motion of a variable mass system1Equation of motion of a variable mass system1
Equation of motion of a variable mass system1
 
Kinetics kinematics
Kinetics kinematicsKinetics kinematics
Kinetics kinematics
 
Ppt of aem some special function
Ppt of aem some special functionPpt of aem some special function
Ppt of aem some special function
 
Passivity-based control of rigid-body manipulator
Passivity-based control of rigid-body manipulatorPassivity-based control of rigid-body manipulator
Passivity-based control of rigid-body manipulator
 
Cap 12
Cap 12Cap 12
Cap 12
 
Contraction mapping
Contraction mappingContraction mapping
Contraction mapping
 
Bode lect
Bode lectBode lect
Bode lect
 
Daa divide-n-conquer
Daa divide-n-conquerDaa divide-n-conquer
Daa divide-n-conquer
 
Viktor Urumov - Time-delay feedback control of nonlinear oscillators
Viktor Urumov -  Time-delay feedback control of nonlinear oscillatorsViktor Urumov -  Time-delay feedback control of nonlinear oscillators
Viktor Urumov - Time-delay feedback control of nonlinear oscillators
 
Adaptive dynamic programming algorithm for uncertain nonlinear switched systems
Adaptive dynamic programming algorithm for uncertain nonlinear switched systemsAdaptive dynamic programming algorithm for uncertain nonlinear switched systems
Adaptive dynamic programming algorithm for uncertain nonlinear switched systems
 

Similar to The Kalman filter: A tutorial and MATLAB implementation

Discrete control2 converted
Discrete control2 convertedDiscrete control2 converted
Discrete control2 convertedcairo university
 
Adaptive dynamic programming for control
Adaptive dynamic programming for controlAdaptive dynamic programming for control
Adaptive dynamic programming for controlSpringer
 
Control of Uncertain Nonlinear Systems Using Ellipsoidal Reachability Calculus
Control of Uncertain Nonlinear Systems Using Ellipsoidal Reachability CalculusControl of Uncertain Nonlinear Systems Using Ellipsoidal Reachability Calculus
Control of Uncertain Nonlinear Systems Using Ellipsoidal Reachability CalculusLeo Asselborn
 
FirstAndSecond.pptx.pdf
FirstAndSecond.pptx.pdfFirstAndSecond.pptx.pdf
FirstAndSecond.pptx.pdfShanmukhSaiR
 
Robust Control of Uncertain Switched Linear Systems based on Stochastic Reach...
Robust Control of Uncertain Switched Linear Systems based on Stochastic Reach...Robust Control of Uncertain Switched Linear Systems based on Stochastic Reach...
Robust Control of Uncertain Switched Linear Systems based on Stochastic Reach...Leo Asselborn
 
Probabilistic Control of Uncertain Linear Systems Using Stochastic Reachability
Probabilistic Control of Uncertain Linear Systems Using Stochastic ReachabilityProbabilistic Control of Uncertain Linear Systems Using Stochastic Reachability
Probabilistic Control of Uncertain Linear Systems Using Stochastic ReachabilityLeo Asselborn
 
Computer Controlled Systems (solutions manual). Astrom. 3rd edition 1997
Computer Controlled Systems (solutions manual). Astrom. 3rd edition 1997Computer Controlled Systems (solutions manual). Astrom. 3rd edition 1997
Computer Controlled Systems (solutions manual). Astrom. 3rd edition 1997JOAQUIN REA
 
controllability-and-observability.pdf
controllability-and-observability.pdfcontrollability-and-observability.pdf
controllability-and-observability.pdfLAbiba16
 
Control of Discrete-Time Piecewise Affine Probabilistic Systems using Reachab...
Control of Discrete-Time Piecewise Affine Probabilistic Systems using Reachab...Control of Discrete-Time Piecewise Affine Probabilistic Systems using Reachab...
Control of Discrete-Time Piecewise Affine Probabilistic Systems using Reachab...Leo Asselborn
 
Probabilistic Control of Switched Linear Systems with Chance Constraints
Probabilistic Control of Switched Linear Systems with Chance ConstraintsProbabilistic Control of Switched Linear Systems with Chance Constraints
Probabilistic Control of Switched Linear Systems with Chance ConstraintsLeo Asselborn
 
Schrodinger equation in QM Reminders.ppt
Schrodinger equation in QM Reminders.pptSchrodinger equation in QM Reminders.ppt
Schrodinger equation in QM Reminders.pptRakeshPatil2528
 
Kalman filter for object tracking
Kalman filter for object trackingKalman filter for object tracking
Kalman filter for object trackingMohit Yadav
 
Ahsan 10X Engineering Talk (Quantum Computing).pptx
Ahsan 10X Engineering Talk (Quantum Computing).pptxAhsan 10X Engineering Talk (Quantum Computing).pptx
Ahsan 10X Engineering Talk (Quantum Computing).pptxMuhammad Ahsan
 
Solution to schrodinger equation with dirac comb potential
Solution to schrodinger equation with dirac comb potential Solution to schrodinger equation with dirac comb potential
Solution to schrodinger equation with dirac comb potential slides
 
Journey to structure from motion
Journey to structure from motionJourney to structure from motion
Journey to structure from motionJa-Keoung Koo
 

Similar to The Kalman filter: A tutorial and MATLAB implementation (20)

Discrete control2 converted
Discrete control2 convertedDiscrete control2 converted
Discrete control2 converted
 
Adaptive dynamic programming for control
Adaptive dynamic programming for controlAdaptive dynamic programming for control
Adaptive dynamic programming for control
 
Control of Uncertain Nonlinear Systems Using Ellipsoidal Reachability Calculus
Control of Uncertain Nonlinear Systems Using Ellipsoidal Reachability CalculusControl of Uncertain Nonlinear Systems Using Ellipsoidal Reachability Calculus
Control of Uncertain Nonlinear Systems Using Ellipsoidal Reachability Calculus
 
FirstAndSecond.pptx.pdf
FirstAndSecond.pptx.pdfFirstAndSecond.pptx.pdf
FirstAndSecond.pptx.pdf
 
Robust Control of Uncertain Switched Linear Systems based on Stochastic Reach...
Robust Control of Uncertain Switched Linear Systems based on Stochastic Reach...Robust Control of Uncertain Switched Linear Systems based on Stochastic Reach...
Robust Control of Uncertain Switched Linear Systems based on Stochastic Reach...
 
Probabilistic Control of Uncertain Linear Systems Using Stochastic Reachability
Probabilistic Control of Uncertain Linear Systems Using Stochastic ReachabilityProbabilistic Control of Uncertain Linear Systems Using Stochastic Reachability
Probabilistic Control of Uncertain Linear Systems Using Stochastic Reachability
 
cheb_conf_aksenov.pdf
cheb_conf_aksenov.pdfcheb_conf_aksenov.pdf
cheb_conf_aksenov.pdf
 
Computer Controlled Systems (solutions manual). Astrom. 3rd edition 1997
Computer Controlled Systems (solutions manual). Astrom. 3rd edition 1997Computer Controlled Systems (solutions manual). Astrom. 3rd edition 1997
Computer Controlled Systems (solutions manual). Astrom. 3rd edition 1997
 
controllability-and-observability.pdf
controllability-and-observability.pdfcontrollability-and-observability.pdf
controllability-and-observability.pdf
 
QMC: Operator Splitting Workshop, A New (More Intuitive?) Interpretation of I...
QMC: Operator Splitting Workshop, A New (More Intuitive?) Interpretation of I...QMC: Operator Splitting Workshop, A New (More Intuitive?) Interpretation of I...
QMC: Operator Splitting Workshop, A New (More Intuitive?) Interpretation of I...
 
Control of Discrete-Time Piecewise Affine Probabilistic Systems using Reachab...
Control of Discrete-Time Piecewise Affine Probabilistic Systems using Reachab...Control of Discrete-Time Piecewise Affine Probabilistic Systems using Reachab...
Control of Discrete-Time Piecewise Affine Probabilistic Systems using Reachab...
 
Probabilistic Control of Switched Linear Systems with Chance Constraints
Probabilistic Control of Switched Linear Systems with Chance ConstraintsProbabilistic Control of Switched Linear Systems with Chance Constraints
Probabilistic Control of Switched Linear Systems with Chance Constraints
 
Assignment2 control
Assignment2 controlAssignment2 control
Assignment2 control
 
Schrodinger equation in QM Reminders.ppt
Schrodinger equation in QM Reminders.pptSchrodinger equation in QM Reminders.ppt
Schrodinger equation in QM Reminders.ppt
 
Kalman filter for object tracking
Kalman filter for object trackingKalman filter for object tracking
Kalman filter for object tracking
 
2018 MUMS Fall Course - Sampling-based techniques for uncertainty propagation...
2018 MUMS Fall Course - Sampling-based techniques for uncertainty propagation...2018 MUMS Fall Course - Sampling-based techniques for uncertainty propagation...
2018 MUMS Fall Course - Sampling-based techniques for uncertainty propagation...
 
Ahsan 10X Engineering Talk (Quantum Computing).pptx
Ahsan 10X Engineering Talk (Quantum Computing).pptxAhsan 10X Engineering Talk (Quantum Computing).pptx
Ahsan 10X Engineering Talk (Quantum Computing).pptx
 
Solution to schrodinger equation with dirac comb potential
Solution to schrodinger equation with dirac comb potential Solution to schrodinger equation with dirac comb potential
Solution to schrodinger equation with dirac comb potential
 
12handout
12handout12handout
12handout
 
Journey to structure from motion
Journey to structure from motionJourney to structure from motion
Journey to structure from motion
 

Recently uploaded

Vip Hot🥵 Call Girls Delhi Delhi {9711199012} Avni Thakur 🧡😘 High Profile Girls
Vip Hot🥵 Call Girls Delhi Delhi {9711199012} Avni Thakur 🧡😘 High Profile GirlsVip Hot🥵 Call Girls Delhi Delhi {9711199012} Avni Thakur 🧡😘 High Profile Girls
Vip Hot🥵 Call Girls Delhi Delhi {9711199012} Avni Thakur 🧡😘 High Profile Girlsshivangimorya083
 
Digamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and QualificationsDigamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and QualificationsMihajloManjak
 
FULL ENJOY - 9953040155 Call Girls in Sector 61 | Noida
FULL ENJOY - 9953040155 Call Girls in Sector 61 | NoidaFULL ENJOY - 9953040155 Call Girls in Sector 61 | Noida
FULL ENJOY - 9953040155 Call Girls in Sector 61 | NoidaMalviyaNagarCallGirl
 
(8264348440) 🔝 Call Girls In Shaheen Bagh 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Shaheen Bagh 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Shaheen Bagh 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Shaheen Bagh 🔝 Delhi NCRsoniya singh
 
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls  Size E6 (O525547819) Call Girls In DubaiDubai Call Girls  Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubaikojalkojal131
 
VIP Kolkata Call Girl Kasba 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kasba 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kasba 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kasba 👉 8250192130 Available With Roomdivyansh0kumar0
 
John Deere 200lc Excavator Operation And Tests Repair Manual.pdf
John Deere 200lc Excavator Operation And Tests Repair Manual.pdfJohn Deere 200lc Excavator Operation And Tests Repair Manual.pdf
John Deere 200lc Excavator Operation And Tests Repair Manual.pdfExcavator
 
如何办理(UQ毕业证书)昆士兰大学毕业证毕业证成绩单原版一比一
如何办理(UQ毕业证书)昆士兰大学毕业证毕业证成绩单原版一比一如何办理(UQ毕业证书)昆士兰大学毕业证毕业证成绩单原版一比一
如何办理(UQ毕业证书)昆士兰大学毕业证毕业证成绩单原版一比一hnfusn
 
Delhi Call Girls Saket 9711199171 ☎✔👌✔ Full night Service for more than 1 person
Delhi Call Girls Saket 9711199171 ☎✔👌✔ Full night Service for more than 1 personDelhi Call Girls Saket 9711199171 ☎✔👌✔ Full night Service for more than 1 person
Delhi Call Girls Saket 9711199171 ☎✔👌✔ Full night Service for more than 1 personshivangimorya083
 
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptxUNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptxDineshKumar4165
 
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
2024 WRC Hyundai World Rally Team’s i20 N Rally1 HybridHyundai Motor Group
 
( Best ) Genuine Call Girls In Mandi House =DELHI-| 8377087607
( Best ) Genuine Call Girls In Mandi House =DELHI-| 8377087607( Best ) Genuine Call Girls In Mandi House =DELHI-| 8377087607
( Best ) Genuine Call Girls In Mandi House =DELHI-| 8377087607dollysharma2066
 
The 10th anniversary, Hyundai World Rally Team's amazing journey
The 10th anniversary, Hyundai World Rally Team's amazing journeyThe 10th anniversary, Hyundai World Rally Team's amazing journey
The 10th anniversary, Hyundai World Rally Team's amazing journeyHyundai Motor Group
 
Innovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC TechnologyInnovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC Technologyquickpartslimitlessm
 
UNIT-V-ELECTRIC AND HYBRID VEHICLES.pptx
UNIT-V-ELECTRIC AND HYBRID VEHICLES.pptxUNIT-V-ELECTRIC AND HYBRID VEHICLES.pptx
UNIT-V-ELECTRIC AND HYBRID VEHICLES.pptxDineshKumar4165
 
办理埃默里大学毕业证Emory毕业证原版一比一
办理埃默里大学毕业证Emory毕业证原版一比一办理埃默里大学毕业证Emory毕业证原版一比一
办理埃默里大学毕业证Emory毕业证原版一比一mkfnjj
 
BLUE VEHICLES the kids picture show 2024
BLUE VEHICLES the kids picture show 2024BLUE VEHICLES the kids picture show 2024
BLUE VEHICLES the kids picture show 2024AHOhOops1
 
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhiHauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhiHot Call Girls In Sector 58 (Noida)
 

Recently uploaded (20)

Vip Hot🥵 Call Girls Delhi Delhi {9711199012} Avni Thakur 🧡😘 High Profile Girls
Vip Hot🥵 Call Girls Delhi Delhi {9711199012} Avni Thakur 🧡😘 High Profile GirlsVip Hot🥵 Call Girls Delhi Delhi {9711199012} Avni Thakur 🧡😘 High Profile Girls
Vip Hot🥵 Call Girls Delhi Delhi {9711199012} Avni Thakur 🧡😘 High Profile Girls
 
Digamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and QualificationsDigamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and Qualifications
 
FULL ENJOY - 9953040155 Call Girls in Sector 61 | Noida
FULL ENJOY - 9953040155 Call Girls in Sector 61 | NoidaFULL ENJOY - 9953040155 Call Girls in Sector 61 | Noida
FULL ENJOY - 9953040155 Call Girls in Sector 61 | Noida
 
(8264348440) 🔝 Call Girls In Shaheen Bagh 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Shaheen Bagh 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Shaheen Bagh 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Shaheen Bagh 🔝 Delhi NCR
 
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls  Size E6 (O525547819) Call Girls In DubaiDubai Call Girls  Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubai
 
VIP Kolkata Call Girl Kasba 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kasba 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kasba 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kasba 👉 8250192130 Available With Room
 
John Deere 200lc Excavator Operation And Tests Repair Manual.pdf
John Deere 200lc Excavator Operation And Tests Repair Manual.pdfJohn Deere 200lc Excavator Operation And Tests Repair Manual.pdf
John Deere 200lc Excavator Operation And Tests Repair Manual.pdf
 
如何办理(UQ毕业证书)昆士兰大学毕业证毕业证成绩单原版一比一
如何办理(UQ毕业证书)昆士兰大学毕业证毕业证成绩单原版一比一如何办理(UQ毕业证书)昆士兰大学毕业证毕业证成绩单原版一比一
如何办理(UQ毕业证书)昆士兰大学毕业证毕业证成绩单原版一比一
 
Delhi Call Girls Saket 9711199171 ☎✔👌✔ Full night Service for more than 1 person
Delhi Call Girls Saket 9711199171 ☎✔👌✔ Full night Service for more than 1 personDelhi Call Girls Saket 9711199171 ☎✔👌✔ Full night Service for more than 1 person
Delhi Call Girls Saket 9711199171 ☎✔👌✔ Full night Service for more than 1 person
 
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptxUNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
UNIT-IV-STEERING, BRAKES AND SUSPENSION SYSTEMS.pptx
 
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
2024 WRC Hyundai World Rally Team’s i20 N Rally1 Hybrid
 
( Best ) Genuine Call Girls In Mandi House =DELHI-| 8377087607
( Best ) Genuine Call Girls In Mandi House =DELHI-| 8377087607( Best ) Genuine Call Girls In Mandi House =DELHI-| 8377087607
( Best ) Genuine Call Girls In Mandi House =DELHI-| 8377087607
 
The 10th anniversary, Hyundai World Rally Team's amazing journey
The 10th anniversary, Hyundai World Rally Team's amazing journeyThe 10th anniversary, Hyundai World Rally Team's amazing journey
The 10th anniversary, Hyundai World Rally Team's amazing journey
 
Innovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC TechnologyInnovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC Technology
 
UNIT-V-ELECTRIC AND HYBRID VEHICLES.pptx
UNIT-V-ELECTRIC AND HYBRID VEHICLES.pptxUNIT-V-ELECTRIC AND HYBRID VEHICLES.pptx
UNIT-V-ELECTRIC AND HYBRID VEHICLES.pptx
 
办理埃默里大学毕业证Emory毕业证原版一比一
办理埃默里大学毕业证Emory毕业证原版一比一办理埃默里大学毕业证Emory毕业证原版一比一
办理埃默里大学毕业证Emory毕业证原版一比一
 
BLUE VEHICLES the kids picture show 2024
BLUE VEHICLES the kids picture show 2024BLUE VEHICLES the kids picture show 2024
BLUE VEHICLES the kids picture show 2024
 
Call Girls In Kirti Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Kirti Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In Kirti Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Kirti Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
(NEHA) Call Girls Pushkar Booking Open 8617697112 Pushkar Escorts
(NEHA) Call Girls Pushkar Booking Open 8617697112 Pushkar Escorts(NEHA) Call Girls Pushkar Booking Open 8617697112 Pushkar Escorts
(NEHA) Call Girls Pushkar Booking Open 8617697112 Pushkar Escorts
 
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhiHauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
 

The Kalman filter: A tutorial and MATLAB implementation

  • 1. 1 ACM 116: The Kalman filter • Example • General Setup • Derivation • Numerical examples – Estimating the voltage – 1D tracking – 2D tracking
  • 2. 2 Example: Navigation Problem • Truck on “frictionless” straight rails • Initial position X0 = 0 • Movement is buffeted by random accelerations • We measure the position every ∆t seconds • State variables (Xk, Vk) position and velocity at time k∆t Xk = Xk−1 + Vk−1∆t + ak−1∆t2 /2 Vk = Vk−1 + ak−1∆t where ak−1 is a random acceleration • Observations Yk = Xk + Zk where Zk is a noise term. The goal is to estimate the position and velocity at all times.
  • 3. 3 General Setup Estimation of a stochastic dynamic system • Dynamics Xk = Fk−1Xk−1 + Bk−1uk−1 + Wk−1 – Xk: state of the system at time k – uk−1: control-input – Wk−1: noise • Observations Yk = HkXk + Zk – Yk is observed – Zk is noise • The noise realizations are all independent • Goal: predict state Xk from past data Y0, Y1, . . . , Yk−1.
  • 4. 4 Derivation Derivation in the simpler model where the dynamics is of the form Xk = ak−1Xk−1 + Wk−1 and the observations Yk = Xk + Zk The objective is to find, for each time k, the minimum MSE filter based on Y0, Y1, . . . , Yk−1 ˆXk = k j=1 h (k−1) j Yk−j To find the filter, we apply the orthogonality principle E((Xk − k j=1 h (k−1) j Yk−j)Y ) = 0, = 0, 1, . . . , k − 1.
  • 5. 5 Recursion The beautiful thing about the Kalman filter is that one can almost deduce the optimal filter to predict Xk+1 from that predicting Xk. h (k) j+1 = (ak − h (k) 1 )h (k−1) j , j = 1, . . . , k. Given the filter h(k−1) , we only need to find h (k) 1 to get the filter at the next time step.
  • 6. 6 How to find h (k) 1 ? Observe that the next prediction is equal to ˆXk+1 = h (k) 1 Yk + k j=1 (ak − h (k) 1 )h (k−1) j Yk−j = ak ˆXk + h (k) 1 (Yk − ˆXk) Interpretation ˆXk+1 = ak ˆXk + h (k) 1 Ik • ak ˆXk is the prediction based on the estimate at time k • h (k) 1 Ik is a corrective term which is available since we now see Yk – h (k) 1 is called the gain – Ik = Yk − ˆXk is called the innovation
  • 7. 7 Error of Prediction To find h (k) 1 , we look at the error of prediction k = Xk − ˆXk We have the recursion k+1 = (ak − h (k) 1 ) k + Wk − h (k) 1 Zk • 0 = Z0 • E( k) = 0 • E( 2 k+1) = [ak − h (k) 1 ]2 E( 2 k) + E(W 2 k ) + [h (k) 1 ]2 E(Z2 k)
  • 8. 8 To minimize the MSE k+1, we adjust h (k) 1 so that ∂h (k) 1 E( 2 k+1) = 0 = −2(ak − h (k) 1 )E( 2 k) + 2h (k) 1 E(Z2 k) which is given by h (k) 1 = akE( 2 k) E( 2 k) + E(Z2 k) Note that this gives the recurrence relation E( 2 k+1) = ak(ak − h (k) 1 )E( 2 k) + E(W 2 k )
  • 9. 9 The Kalman Filter Algorithm • Initialization ˆX0 = 0, E( 2 0) = E(Z2 0 ) • Loop: for k = 0, 1, . . . h (k) 1 = akE( 2 k) E( 2 k) + E(Z2 k) ˆXk+1 = ak ˆXk + h (k) 1 (Yk − ˆXk) E( 2 k+1) = ak(ak − h (k) 1 )E( 2 k) + E(W 2 k )
  • 10. 10 Benefits • Requires no knowledge about the structure of Wk and Zk (only variances) • Easy implementation • Many applications – Inertial guidance system – Autopilot – Satellite navigation system – Many others
  • 11. 11 General Formulation Xk = Fk−1Xk−1 + Wk−1 Yk = HkXk + Zk The covariance of Wk is Qk and that of Zk is Rk. Two variables: • ˆXk|k estimate of the state at time k based upon Y0, . . . , Yk−1 • Ek|k error covariance matrix, Ek|k = Cov(Xk − ˆXk|k)
  • 12. 12 Prediction ˆXk+1|k = Fk ˆXk|k−1 Ek+1|k = FkEk|k−1F T k + Qk Update Ik = Yk − Hk ˆXk+1|k Innovation Sk = HkEk+1|kHT k + Rk Innovation covariance Kk = Ek+1|kHT k S−1 k Kalman Gain ˆXk+1|k+1 = ˆXk+1|k + KkIk Updated state estimate Ek+1|k+1 = (Id − KkHk)Ek+1|k Updated error covariance
  • 13. 13 Estimating Constant Voltage We wish to estimate some voltage which is almost constant except for some small random fluctuations. Our measuring device is imperfect (e.g. because of a poor A/D conversion). The process is governed by: Xk = X0 + Wk, k = 1, 2, . . . with X0 = 0.5V , and the measurements are Zk = Xk + Vk, k = 1, 2, . . . where Wk, Vk are uncorrelated Gaussian white noise processes, with R := Var(Vk) = 0.01, Var(Wk) = 10−5 .
  • 14. 14 0 5 10 15 20 25 30 35 40 45 50 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Accurate knowledge of measurement variance, Rest =R=0.01 Iteration Voltage estimate exact process measurements
  • 15. 15 0 5 10 15 20 25 30 35 40 45 50 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Optimistic estimate of measurement variance, Rest =0.0001 Iteration Voltage estimate exact process measurements
  • 16. 16 0 5 10 15 20 25 30 35 40 45 50 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Pessimistic estimate of measurement variance, Rest =1 Iteration Voltage estimate exact process measurements
  • 17. 17 1D Tracking Estimation of the position of a vehicle. Let X be a state variable (position and speed), and A is a transition matrix A =   1 ∆t 0 1   . The process is governed by: Xn+1 = AXn + Wn where Wn is a zero-mean Gaussian white noise process. The observation is Yn = CXn + Zn where the matrix C only picks up the position and Zn is another zero-mean Gaussian white noise process independent of Wn.
  • 18. 18 0 5 10 15 20 25 !4 !2 0 2 4 6 8 Time Position Estimation of a moving vehicle in 1!D. exact position measured position estimated position
  • 19. 19 2D Example General setup X(t + 1) = F X(t) + W (t), W ∼ N(0, Q), Y (t) = HX(t) + V (t), V ∼ N(0, R) Moving particle at constant velocity subject to random perturbations in its trajectory. The new position (x1, x2) is the old position plus the velocity (dx1, dx2) plus noise w.        x1(t) x2(t) dx1(t) dx2(t)        =        1 0 1 0 0 1 0 1 0 0 1 0 0 0 0 1               x1(t − 1) x2(t − 1) dx1(t − 1) dx2(t − 1)        +        w1(t − 1) w2(t − 1) dw1(t − 1) dw2(t − 1)       
  • 20. 20 Observations We only observe the position of the particle.   y1(t) y2(t)   =   1 0 0 0 0 1 0 0          x1(t) x2(t) dx1(t) dx2(t)        +   v1(t) v2(t)   Source: http://www.cs.ubc.ca/∼murphyk/Software/Kalman/kalman.html
  • 21. 21 Implementation % Make a point move in the 2D plane % State = (x y xdot ydot). We only observe (x y). % This code was used to generate Figure 17.9 of % "Artificial Intelligence: a Modern Approach", % Russell and Norvig, 2nd edition, Prentice Hall, in preparation. % X(t+1) = F X(t) + noise(Q) % Y(t) = H X(t) + noise(R) ss = 4; % state size os = 2; % observation size F = [1 0 1 0; 0 1 0 1; 0 0 1 0; 0 0 0 1]; H = [1 0 0 0; 0 1 0 0]; Q = 1*eye(ss); R = 10*eye(os); initx = [10 10 1 0]’; initV = 10*eye(ss);
  • 22. 22 seed = 8; rand(’state’, seed); randn(’state’, seed); T = 50; [x,y] = sample_lds(F,H,Q,R,initx,T);
  • 23. 23 Apply Kalman Filter [xfilt,Vfilt] = kalman_filter(y,F,H,Q,R,initx,initV); dfilt = x([1 2],:) - xfilt([1 2],:); mse_filt = sqrt(sum(sum(dfilt.ˆ2))) figure; plot(x(1,:), x(2,:), ’ks-’); hold on plot(y(1,:), y(2,:), ’g*’); plot(xfilt(1,:), xfilt(2,:), ’rx:’); hold off legend(’true’, ’observed’, ’filtered’, 0) xlabel(’X1’), ylabel(’X2’)
  • 24. 24 !40 !30 !20 !10 0 10 20 10 20 30 40 50 60 70 X1 X2 true observed filtered
  • 25. 25 0 20 40 60 80 100 120 140 0 20 40 60 80 100 120 140 X1 X2 true observed filtered
  • 26. 26 Apply Kalman Smoother [xsmooth, Vsmooth] = kalman_smoother(y,F,H,Q,R,initx,initV); dsmooth = x([1 2],:) - xsmooth([1 2],:); mse_smooth = sqrt(sum(sum(dsmooth.ˆ2))) figure; hold on plot(x(1,:), x(2,:), ’ks-’); plot(y(1,:), y(2,:), ’g*’); plot(xsmooth(1,:), xsmooth(2,:), ’rx:’); hold off legend(’true’, ’observed’, ’smoothed’, 0) xlabel(’X1’), ylabel(’X2’)
  • 27. 27 !!0 !#0 !20 !10 0 10 20 10 20 #0 !0 50 '0 (0 )1 )2 *+,- ./0-+1-2 03..*4-2
  • 28. 28 0 20 40 60 80 100 120 140 0 20 40 60 80 100 120 140 X1 X2 true observed smoothed