Professional Documents
Culture Documents
15 KalmanFilter
15 KalmanFilter
Ioannis Rekleitis
Example of a Parameterized Bayesian Filter:
Kalman Filter
Kalman filters (KF) represent posterior belief by a
Gaussian (normal) distribution
2 (2 ) | |
n
• Measurement model is z Hx r
t t t
CS-417 Introduction to Robotics and Intelligent Systems Images courtesy of Maybeck, 1979 6
What we know…
What we don’t know…
• We know what the control inputs of our process are
– We know what we’ve told the system to do and have a model for what the
expected output should be if everything works right
• We don’t know what the noise in the system truly is
– We can only estimate what the noise might be and try to put some sort of upper
bound on it
• When estimating the state of a system, we try to find a set of
values that comes as close to the truth as possible
– There will always be some mismatch between our estimate of the system and the
true state of the system itself. We just try to figure out how much mismatch there
is and try to get the best estimate possible
• The minimum mean square error estimator equals the expected (mean) value of x
conditioned on the observations Z
• The minimum mean square error term is quadratic:
E[( x xˆ ) 2 | Z t ]
– Its minimum can be found by taking the derivative of the function w.r.t x and setting that
value to 0.
x ( E[( x xˆ ) 2 | Z ]) 0
• It is interesting to note that when they use the Gaussian assumption, Maximum A
Posteriori estimators and MMSE estimators find the same value for the parameters.
– This is because mean and the mode of a Gaussian distribution are the same.
xt 1 Ft xt Bt ut Gt wt
xˆt 1|t 1 E[ xt 1 | Z t 1 ]
xˆt |t E[ xt | Z t ]
xˆt 1|t E[ xt 1 | Z t ]
Pt 1|t Ft Pt|t Ft Gt Qt Gt
T T
Covariance matrix for the state
1
K t 1 Pt 1/ t H t 1 S t 1
T
Pt 1/ t Ft Pt / t Ft Gt Qt Gt
T T
- Uncertainty estimate GROWS
S t 1 H t 1 Pt 1/ t H t 1 Rt 1
T - Compute covariance of sensor reading
1
K t 1 Pt 1/ t H t 1 S t 1 - Compute the Kalman Gain (how much to correct est.)
T
xˆt 1/ t 1 xˆt 1/ t K t 1rt 1 - Multiply residual times gain to correct state estimate
1
Pt 1/ t 1 Pt 1/ t Pt 1/ t H t 1 S t 1 H t 1 Pt 1/ t
T
- Uncertainty estimate SHRINKS
• Sensor modeling
– The odometry estimate is not a reflection of the robot’s control
system is rather treated as a sensor
– Instead of directly measuring the error in the state vector (such as
when doing tracking), the error in the state must be estimated
– This is referred to as the Indirect Kalman Filter
• State vector for robot moving in 2D
– The state vector is 3x1: [x,y,q]
– The covariance matrix is 3x3
• Problem: Mobile robot dynamics are NOT linear
xt Vt
Y From a robot-centric
y x perspective, the velocities y t 0
v
look like this: w
t t
w xt Vt cos t
From the global
perspective, the y t Vt sin t
velocities look like this: w
G X t t
The discrete time state xˆt 1 xˆt (Vt wVt )t cos ˆt Problem! We don’t know
estimate (including noise) linear and rotational
yˆ t 1 yˆ t (Vt wVt )t sin ˆt velocity errors. The state
looks like this:
estimate will rapidly
ˆt 1 ˆt (wt ww )t
t
diverge if this is the only
CS-417 Introduction to Robotics and Intelligent Systems source of information! 30
Linearized Motion Model for a Robot
Now, we have to compute the covariance matrix propagation
equations.
The indirect Kalman filter derives the pose equations from the
estimated error of the state: xt 1 xˆt 1 ~
xt 1
yt 1 yˆ t 1 ~
yt 1
~
ˆ
t 1 t 1 t 1
Pt 1/ t Ft Pt / t Ft Gt Qt Gt
T T
~ ~T T
Ft E[ X t X t ]Ft Gt E[ wt wt ]Gt
T T
Ft Pt / t Ft Gt Qt Gt
T T
where
v 0
2
Qt E[ wt wt ]
T
2
0 w
CS-417 Introduction to Robotics and Intelligent Systems 35
Alternative Calculation
X t 1 f ( X t , wt )
X t 1 Xˆ t 1 Fx ( X t Xˆ t ) Fw wt
~ ~
X t 1 Xˆ t 1 Fx ( X t ) Fw wt
1 0 vt t sin(ˆt )
f ˆ
Fx | Xˆ 0 1 vt t cos(t )
X t
0 0 1
t cos(ˆt ) 0
f ˆ
Fw | Xˆ t sin(t ) 0
w t
0 t
CS-417 Introduction to Robotics and Intelligent Systems 36
Propagation
• Finally, for a mobile robot EKF propagation step we
have:
xˆt 1 xˆt Vt mt cos ˆt
yˆ yˆ V mt sin ˆ
t 1 t t t
where :
1 0 Vt t sin ˆ t cos t 0
2
0
Ft 0 1 Vt t cos , Gt t sin t
ˆ 0 , Qt v 2
0 0 0 w
1 0
t
CS-417 Introduction to Robotics and Intelligent Systems 37
Sensor Model for a Robot with a Perfect Map
From the robot, the measurement
looks like this: n
zt 1
xLi xr y Li yr
2 2
n
Y
q nq atan 2 y Li yr , xLi xr r nq
Li =[xLi, yLi]T
y x
z x Li xr y Li yr
2 2
xLi xr y Li yr
0
G X H
y Li yr
xLi xr
1
2 2
1
K P*H *S T
xt 1/ t 1 xt / t 1 K * r
P (I K * H ) * P * (I K * H ) K * R * K T T
P * PT
P
2
CS-417 Introduction to Robotics and Intelligent Systems 39
See Matlab Examples
xLt 1 nx
Y From the robot, the
measurement looks zt 1 y Lt 1 n y
L like this: L n
x t 1
y
z From a global
perspective, the
measurement looks
like:
G X
cos t 1 sin t 1
0 xLt 1 xt 1 nx
zt 1 sin t 1 cos t 1
0 y Lt 1 yt 1 n y
1 Lt 1 t 1 n
0 0
The measurement equation is nonlinear and must also be linearized!
CS-417 Introduction to Robotics and Intelligent Systems 41
Sensor Model for a Robot with a Perfect Map
Now, we have to compute the linearized sensor function. Once
again, we make use of the indirect Kalman filter where the error in
the reading must be estimated.
The final expression for the error in the sensor reading is:
~xLt 1 cos ˆt 1 sin ˆt 1 sin ˆt 1 ( xL xˆt 1 ) cos ˆt ( y L yˆ t 1 ) ~
xt 1 nx
~
ˆ
y Lt 1 sin t 1 cos ˆ t 1 cos ˆt 1 ( xL xˆt 1 ) sin ˆt ( y L yˆ t 1 ) ~
yt 1 n y
~L 1 ~ n
t 1
t 1 0 0
Propagation only
CS-417 Introduction to Robotics and Intelligent Systems Propagation and update 43
Extended Kalman Filter for SLAM
• State vector
– Expanded to contain entries for all landmarks
positions: X X RT X LT X LT
T
1 n
xˆ Li t 1 xˆ Li t
yˆ Li t 1 yˆ Li t
ˆL t 1 ˆL t
i i