ARS4 Course
ARS4 Course
Philippe Bonnifait
2
Contents
1 Generic problems 8
1.1 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.1 Robotic navigation . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.2 Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.3 Multi-sensor fusion . . . . . . . . . . . . . . . . . . . . . . . . 9
1.1.4 Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.1.5 Performance metrics . . . . . . . . . . . . . . . . . . . . . . . 10
1.1.6 Soft sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2 Main categories of estimation and fusion problems . . . . . . . . . . . 14
1.2.1 Static problems . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.2.2 Dynamic problems . . . . . . . . . . . . . . . . . . . . . . . . 15
1.3 Modeling moving objects . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.3.1 Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.3.2 Notations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.3.3 Evolution models . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.3.4 Observation models . . . . . . . . . . . . . . . . . . . . . . . . 21
1.3.5 Mobile robot modeling . . . . . . . . . . . . . . . . . . . . . . 23
1.4 Classical navigation problems in robotics . . . . . . . . . . . . . . . . 23
2 Static Estimation 25
2.1 Linear case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.1.1 Problem statement . . . . . . . . . . . . . . . . . . . . . . . . 25
2.1.2 Least Squares . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.1.3 Weighted Least Squares . . . . . . . . . . . . . . . . . . . . . 27
2.1.4 Example: combination of observations . . . . . . . . . . . . . 29
2.1.5 Robustification . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2 Nonlinear Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2.1 Searching for the zeros of a function: the iterative Newton-
Raphson method . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2.2 Adaptation of the method to state estimation . . . . . . . . . 32
2.2.3 Non-linear least squares: Gauss-Newton method . . . . . . . . 32
2.3 Examples of localization problems . . . . . . . . . . . . . . . . . . . . 34
2.3.1 Localization of a robot with goniometric measurements . . . . 34
2.3.2 Computation of a GPS fix . . . . . . . . . . . . . . . . . . . . 38
3
Contents
5 Bayesian filtering 89
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.2 Bayesian Reminders . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.2.1 Continuous Case . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.2.2 Discrete case . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
5.3 Bayesian Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
5.3.1 Observation Update . . . . . . . . . . . . . . . . . . . . . . . 97
5.3.2 State and Covariance Estimates . . . . . . . . . . . . . . . . . 98
5.3.3 Prediction (time-update) . . . . . . . . . . . . . . . . . . . . . 98
4
Contents
5
Contents
6
Nomenclature
(x, y) 2D Cartesian coordinates
α Model error
β Measurement error
ω Yaw Rate
ϕ Roll angle
ψ Yaw angle
Pxy Cross-covariance matrix between the prediction error and the predicted ob-
servation
7
1 Generic estimation and
multi-sensor fusion problems for
robot navigation
1.1 Basic concepts
1.1.1 Robotic navigation
Navigation is a field of study that focuses on the process of monitoring and control-
ling the movement of a mobile platform from one place to another. For a mobile
robot (e.g. an autonomous vehicle, a UAV), the main objective is to reach a given
goal while avoiding obstacles.
For some authors (like [2]), navigation is the estimation of the state of the platform
on which the sensors are located.
In this course which deals with mobile robots, navigation is the simultaneous
estimation of the state of the robot and of the dynamic environment.
The content focuses on the following elementary functions:
• The vehicle must determine its own location (in absolute and with respect to
a map),
Based on this knowledge, the robot can plan a path or a trajectory and control its
motion until the end of the mission.
1.1.2 Estimation
Estimation is the process of inferring the value of a quantity of interest from indirect,
inaccurate and uncertain observations.
In a continuous space, estimation can be viewed as the process of selecting a
particular point - the “best estimate” [2].
In a discrete-valued case, estimation (also called decision in this particular case)
can be viewed as the selection of one out of a set of discrete alternatives.
In estimation theory, two approaches are generally considered:
• The probabilistic approach assumes that the measured data is random with
probability distribution dependent on the parameters or variables of interest,
• The set-membership approach assumes that the measured data vector belongs
to a set which depends on the parameter vector.
8
1 Generic problems
Both theories have advantages and drawbacks. On the one hand, representing ran-
dom vectors by sets makes it possible to have less assumptions on the random
variables (such as independence) and dealing with non-linearities is easier. On the
other hand, a probability distribution function provides a richer information than a
set enclosing its support.
9
1 Generic problems
1.1.4 Tracking
Tracking is the estimation of the state of a moving object based on remote measure-
ments. It can be done using one or more sensors at fixed locations or on moving
platforms.
In this course, the sensors are attached to the mobile robot that has to track by
itself the moving objects in its surrounding.
[Link] Uncertainty
There exists different meanings of the word “uncertainty”.
Usually, in a multi-sensor fusion context, uncertainty is linked to the confidence
one has in a proposal (or an hypothesis) to be true.
Higher the uncertainty, lower the trueness of the proposal.
Uncertainty is a different concept from inaccuracy.
Examples:
10
1 Generic problems
• Time To Alert (T T A), is the maximum allowable time from the appearance
of position failure until the alert.
• Integrity Risk (IR), is the probability (per operation or per hour) that the
position error exceeds a protection level (see definition below) at any moment
without providing a timely warning. In other words, it is the maximum prob-
ability with which the receiver is allowed to provide position failure without
warning the user.
• Protection Level (PL), is a statistical bound on the Position Error (PE) such
that the probability of the absolute error exceeding the PL is smaller or equal
to the Target Integrity Risk (T IR), which is defined as a requirement for the
application:
P r(PE > PL) ≤ T IR. (1.2)
The T IR is used to tune the parameters of the models and filters to compute the
PL in real-time. A system is considered as satisfying the integrity requirement at a
given T IR, if the following relation is empirically verified:
11
1 Generic problems
• Misleading Information (MI), arises when the position error exceeds the pro-
tection level (underestimation of PE by PL) but stays below the alert limit.
Alert Limit
Alert Limit
In this case and to achieve these functions, the computers use the following mea-
surements:
12
1 Generic problems
5. Longitudinal accelerometer.
On a car equipped with a CAN bus, this information may be made available to any
computer connected to the same bus.
Now, if it is desired to have a measure of the speed of the vehicle, there appears
a redundancy of measures. Which to choose? Instead of answering this question,
multi-sensor fusion is an approach that provides a generic methodology.
One can also note that some sensors can expect input parameters and not only
upon initial configuration.
This is for example the case for
2. A steerable camera,
3. A digital map in which we will look for information around a given point.
Soft
Sensors sensor
Sensors with
input parameters
Soft
sensor
Information exchange
The engine that fuses and filters the data has the following characteristics.
It can
2. Filter it if necessary
5. Match data
6. Detect inconsistencies
13
1 Generic problems
The outputs are estimated with associated quantified inaccuracies and uncertainties.
The module presented here is centralized, but this is not the only possibility. In
practice, there are often multiple levels of fusion for reasons of implementation and
achievement (eg, video pre-processing to extract primitives).
2. The state of a dynamic system (usually a vector), which evolves in time ac-
cording to a stochastic equation
1. The system is static (stationary). The data were obtained at the same place
possibly by different sensors,
Let denote
y = C.x + β (1.4)
1
An "observation" is data that can be directly used in a filter or state observer. A "measurement"
is a data measured by a sensor. Often, measurements and observations are the same but, in
some problems, measurements must be associated (to a map for example) to be used in a filter.
In this case, when the measurement is unambiguously associated, it becomes an observation.
14
1 Generic problems
u y
system
The state x is a vector that contains the relevant variables to observe and control the
system with the input u. The first equation is called evolution model and the second
one observation model where y represents the measurements from the sensors. In
general, x, u and y are vectors. When the input appears in the observation model,
we say that there is transmission of the input to the output.
In the linear case, the state space is:
15
1 Generic problems
xk = x(t0 + [Link] )
In this case, the continuous state space (1.6) which is a view of the system, becomes
a discrete state space:
xk+1 = fd (xk , uk )
(
(1.9)
yk = g(xk , uk )
The model function fd is different from f .
Within the framework of automatic control, the input u(t) is the output of a
control program which periodically updates the output of its D/A converter. In this
case, u(t) is constant between sampling times and it is possible to find exact discrete
models in the linear case. In the nonlinear one, the exact discretization is usually
impossible and an approximate discretization has to be used.
u(t)
t
k k+1
However, when using a state space in a multi-sensor problem, some problems can
be modeled with a measured input um,k . In this case, the state space is usually
written as:
xk = f (xk−1 , um,k )
(
(1.10)
yk = g(xk , uk )
This indicates that the measures um,k and yk are sampled at the same time.
In robotics, sampling can be spatial, temporal or both.
16
1 Generic problems
2
People often do an abuse of notation by keeping the same names for the matricesA and B in
continuous and discrete cases (although they are different)
17
1 Generic problems
Z
y
x
O
Y
z yM
a
(s, n, a) M n
orthonormal and
direct v
s
Navigation xM
O z
frame y
y
x
18
1 Generic problems
Horizontal plan
a
z0
n
(s, n, a)
orthonormal and s v
pitch
direct roll
z y0
O
y
x g
yaw
x0 s0
Earth gravity
1.3.2 Notations
When one manipulates a vector (denoted X for instance), he has to defined the
reference frame. A classical notation is to use a superscript like :
0
X (1.14)
which means that X is expressed in the frame R0 .
When the superscript is omitted, the frame has to be clearly defined in the text.
z
Note: Be careful not to confuse the x-coordinate with the state vector and the
y-ordinate with the vector of measurements. In practice, the confusion is easy to
avoid.
Attitude It is noted, for example with three angles, even if there are many other
representations:
φ
θ (1.16)
ψ
Where the components are the angles of roll (φ), yaw (θ) and pitch (ψ) of the
mobile relative to the local tangent coordinate system (cf figure 1.9).
19
1 Generic problems
Pose The pose is defined by the position and attitude of an object. In 2D, it is
usually represented by the position x and y and the yaw angle θ (also called heading
angle) :
x
q= y (1.17)
Linear velocities
vx
vy (1.18)
vz
Angular rate
ωx
ωy (1.19)
ωz
Acceleration
ax
ay (1.20)
az
ẋ = vx
ẏ = vy
ż = v
y
(1.22)
v̇x =0
=0
v̇y
=0
v̇
z
h iT
If X = x y z vx vy vz is the state, the evolution model is:
20
1 Generic problems
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
Ẋ = = A.X (1.23)
.X
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Planar odometric model An odometric model takes into account the fact that
wheels undergoes non-holonomic constraints, that is to say, the velocity vector to a
wheel is parallel to its longitudinal axis (in a frame tangent to the trajectory of the
vehicle):
= v. cos(θ)
ẋ
ẏ = v. sin(θ)
θ̇ = ω
h(y, x, m) = 0 (1.24)
Where y corresponds to the measurements, x to the unknown state and m denotes
the map (landmarks or beacons locations).
Often we seek an expression in the form:
y = g(x, m) (1.25)
Line of Sight
zu
Beacon
Sensor
Frame u
zb
Ru yu
u
u
yb
xu
u
xb
21
1 Generic problems
Goniometry
λ = atan2 (
u
y b , u xb )
u (1.26)
σ = arctan √u 2zb u 2
yb + xb
Pseudo-distance When the measurement wavelength is only one trip, there are
inevitable offsets between the clocks of the transmitter and receiver.
In this case, we speak of "pseudo-distance" (TOA - Time Of Arrival).
q
ρ= (x − xb )2 + (y − y b )2 + d (1.28)
Where d is the elongation due to the offsets between the clocks.
In 2D, it takes 3 measurements to determine the three unknowns (x, y, d).
GNSS pseudo-distances are typical examples of this kind of technology.
Difference of time of flight One way to remove clock offsets is to make differences
between measurements. We speak of "simple difference" (term used by GPS) or "time
difference of arrival" (Time Difference Of Arrival - TDOA ) in this case.
Let consider two time of flight measurements made with the same clock at the
same time. The offset d is the same in both cases:
q
ρ1 = (x − xb1 )2 + (y − y b1 )2 + d (1.29)
q
ρ2 = (x − xb2 )2 + (y − y b2 )2 + d (1.30)
22
1 Generic problems
q q
ρ12 = ρ2 − ρ1 = (x − xb2 )2 + (y − y b2 )2 − (x − xb1 )2 + (y − y b1 )2 (1.31)
We speak of hyperbolic resolution in this case. The focuses of the hyperbolas are
the two beacons. With 3 beacons, we obtain two equations to calculate the two
unknowns (x, y).
23
1 Generic problems
24
2 Static problems in estimation and
multi-sensor fusion
We are interested in this chapter to a class of problems in which the unknowns
are related to the measurements by a noisy observation equation generally over
determined:
y = g(x) + β
Where
25
2 Static Estimation
Telemeter 1
Telemeter 2
Best solution
Figure 2.1: Linear Least Squares example: The robot tries to localize itself on the
abscissa axis with two redundant and noisy measurements. Each tele-
metric measurement provides a different solution. Merging the two gives
a more accurate estimate of the true position.
Least Squares are a generic solution to estimate the parameter vector x knowing
the model (2.1) and the measurement vector y.
Least Squares are a powerful estimation method when the measurements are af-
fected only by noise (and when the model is well adapted to explain the data). When
there are also outliers, Least Squares have to robustified by using M-estimators or
the Ransac method. This is not discuss in this chapter.
This criterion can also be written as the Sum of Squared Residuals (SSR):
m m
J= (yj − C(j, :)x)2 = rj2
X X
j=1 j=1
Where C(j, :) represents the j-th row of matrix C and the rj are the model resid-
uals, i.e. the differences between the measures yj and their predictions.
J can be considered as a measure of the distance between the experimental data
and the model explaining the data.
Let’s start by presenting the least squares in a simple way, which is useful to
remember the expression of the solution. If the noise is neglected, Eq. (2.1) becomes:
Cx = y (2.3)
26
2 Static Estimation
C T Cx = C T y
If the matrix C T .C is invertible1 then a solution is given by:
−1
x̂ = C T C CT y (2.4)
Notes:
−1
• The matrix C T C C T is called the pseudo-inverse of C (also called Moore–
Penrose inverse).
Let us show that this is the solution to the least squares sense.
The criterion J(x) = (y−Cx) (y−Cx) of equation (2.2) is a real-valued quadratic
T
∇J = −2C T (y − Cx)
The quadratic form has a unique minimum. Let x̂ be the vector which cancels the
gradient vector:
C T (y − Cx) = 0
C T y = C T C x̂
So −1
x̂ = C T C C T .y
1
In practice, this calculation produces a good estimate only if the matrix is well conditioned.
27
2 Static Estimation
Telemeter 1
Telemeter 2
Best solution
Figure 2.2: Linear Weighted Least Squares example: The robot tries to localize itself
on the abscissa axis with two redundant and noisy measurements but one
measurement is more accurate than the other. The solution is more on
the right side compared to Fig. 2.1 since telemeter 1 is more accurate.
σ12 0 0
R = 0 ... 0
0 0 σm2
1m m
rj2
J= (yj − Cx) =
2
X X
2 2
j=1 σj j=1 σj
We see that each residual is weighted by the inverse of its standard deviation
squared3 . So, the weighted least squares solution consists in finding the parameters
x that minimize the criterion of Eq. 2.5.
In Eq. 2.3, first multiplying each side by R−1 :
R−1 Cx = R−1 y
Then by C T :
C T R−1 C.x = C T R−1 y (2.6)
2
We will come back later on these concepts
3
A measure with large noise has a smaller contribution in the calculation of the solution than a
measure with low noise
28
2 Static Estimation
If the matrix C T .R−1 .C is invertible then the solution of the weighted least squares
is given by: −1
x̂ = C T R−1 C C T R−1 y (2.7)
Demonstration:
If the noise on y is Gaussian with R as covariance then the likelihood is:
1 T
p(y|x) = η. exp(− (y − Cx) .R−1 .(y − Cx))
2
where η is a normalizing constant.
The optimal parameter vector is the one which makes maximum the likelihood of
the observations.
The maximum of likelihood is obtained by differentiating the logarithm with respect
to x (because the logarithm is monotonous):
1 T
J = ln (p(y|x)) = ln(η) − (y − Cx) .R−1 .(y − Cx)
2
The gradient of this quadratic form is (cf appendix [Link] on page 42):
1
∇J = − (−2) C T R−1 (y − Cx)
2
The maximum of likelihood is sought by searching the point x̂ where the gradient
is zero:
C T R−1 (y − C x̂) = 0
C T R−1 y = C T R−1 C x̂
−1
x̂ = C T R−1 C C T R−1 y
z = C T R−1 y
z = Mx
x̂ = (M )−1 z (2.8)
29
2 Static Estimation
2.1.5 Robustification
The methods presented before are sensitive to outliers (measurements with large
errors).
There exists two kinds of classical methods to improve least squares in this context:
• RANSAC (Random sample consensus) [1] which was initialy proposed to solve
the Location Determination Problem (LDP), where the goal is to determine
the points in the space that project onto an image with landmarks of known
locations. It is a non-deterministic algorithm in the sense that it produces a
reasonable result only with a certain probability, with this probability increas-
ing as more iterations are allowed.
f(x)
x(i+1)
1 x0(i)
X X
30
2 Static Estimation
Let find the point x(i+1) where the tangent intersects the x-axis as shown in Figure
2.3.
′−1
x(i+1) − x(i) = −f x(i) f x(i) (2.10)
′−1
x(i+1) = x(i) − f x(i) f x(i) (2.11)
If we denote dx(i) = x(i+1) −x(i) , the calculation is stopped when dx(i) ≤ Threshold.
We can also consider other stop tests as
• the maximum number of iterations
• a test on the value of the function f x(i) to see if it is close to zero.
It should be noted that is not guaranteed to converge as shown in Figure 2.4.
f(x)
Finally, one can always appreciate at the end of treatment if an acceptable solution
has been found.
Vectorial case
→
−
The Newton-Raphson method also works in the case where f (x) = 0 is a vector
function, i.e. that x is a vector:
f1 (x)
x1
x=
. . . and f (x) = . . .
(2.12)
xn fn (x)
′
In this case, f x(i) is a Jacobian matrix4 and it will be denoted with brackets
h ′
i
x(i) .
f
We calculate the partial derivatives with respect to each component and each
term is evaluated in point x0 :
∂f1 (x(i) ) ∂f1 (x(i) )
...
(i)
h ′
i ∂f x ∂x1 ∂xn
f x(i) = = ... (2.13)
∂x
∂fn (x(i) ) ∂fn (x(i) )
∂x1
... ∂xn
4
It can be noted that each row of the Jacobian matrix is the transpose of the gradient vector ∇f
31
2 Static Estimation
• The stop condition has to be changed. For example, it may be considered that
the solution has been reached when dx(i) ≤ Threshold.
y = g(x) (2.15)
y = g(x) + β (2.18)
f1 (x1 , . . . , xn )
x1
x = ... ... m>n (2.19)
xn fm (x1 , . . . , xn )
32
2 Static Estimation
which can be interpreted like this: “Compute the residuals dy (i) of the current
solution and improve the solution in the state space by the increment dx(i) ”.
Notes
• Equation 2.26 is always valid even when there are exactly as many measure-
ments as unknowns. Indeed, the pseudo-inverse of an invertible matrix is the
inverse of the matrix. In this case, the method works like the Newton-Raphson
method.
• The Gauss-Newton method solves in fact an unconstrained non-linear opti-
mization problem: to find the state x such as the residuals (the difference
between the measurements and the predicted measurement knowing the cur-
rent solution and the observation model) are minimum. This is a particular
“gradient descent method” until having reach the minimum of the cost.
• Other techniques follow the “steepest descent” direction. The Levenberg-
Marquardt (LM) method [18] is very popular as it uses a search direction
that is a cross between the Gauss-Newton direction and the steepest descent
direction. The LM method is able to find a solution even if it is started far
from a minimum. It is the method that is used by the Fsolve Matlab function
33
2 Static Estimation
x = fsolve(fun,x0)
%starts at x0 and tries to solve the equations fun(x) = 0.
i
i
i
i
Y
q
i
i
Figure 2.5: The robot in the process of measuring the azimuth angle of a beacon
λ3
34
2 Static Estimation
λ = g (X, M )
M denotes the map that contains the coordinates of the beacons.
To solve it, we put it in the form:
λ − g (X, M ) = f (X) = 0
%Beacons locations
xb=[0; 10;10;0 ]; yb=[0; 0 ;10;10];
%real pose (x,y,heading) of the robot
xr=[6;6;pi/4];
%Measurement generation with noise
lbd=atan2(yb-xr(2),xb-xr(1))-xr(3)+randn(length(xb),1)*1/180*pi;
%Initial guess
x=[2;3;pi/2];
%Gauss Newton iteration
for iter=1:6,
H=jacob(x,xb,yb);%Jacobian
xnew=x+H\dy(x,lbd,xb,yb);%left division (pseudo-inverse)
if (norm(x-xnew)<1e-4),break,end;
x=xnew;
end;
%Residuals computation
function out=dy(x,lbd,xb,yb)
out=lbd-(atan2(yb-x(2),xb-x(1))-x(3));
end
%Jacobian computation
function H=jacob(x,xb,yb)
for i=1:length(xb),
H(i,:)=jacob_line(x,xb(i),yb(i));
end;
end
function line=jacob_line(x,xb,yb)
line=[(yb-x(2))/((xb-x(1))^2+(yb-x(2))^2),...
(x(1)-xb)/((xb-x(1))^2+(yb-x(2))^2),-1];
end
Figure 2.6: Matlab script that solves the problem in simulation. This algorithm
works if there are at least as many measurements as unknowns. In par-
ticular, if there are exactly as many measurements as unknowns, it im-
plements a Newton-Raphson method (and not a Gauss-Newton method).
35
2 Static Estimation
Initializing the program with x=[2;3;pi/2], Figure 2.7 shows the convergence of
the method in 6 iterations.
12
10
-2
-2 0 2 4 6 8 10 12
Figure 2.7: Solving the problem of the robot (the real pose is red while the successive
estimates are in green).
2.5e+006
2.0e+006
1.5e+006
1.0e+006
5.0e+005
0.0e+000
-5.0e+005
-5.0e+006 0.0e+000 5.0e+006 1.0e+007 1.5e+007 2.0e+007 2.5e+007
Finally, we note that the program works well with four beacons, which corresponds
to an overdetermined problem (Figure 2.9).
36
2 Static Estimation
12
10
-2
-2 0 2 4 6 8 10 12
We can use this simulation program to run 1000 trials from the same initial esti-
mate but each simulation has different measurement noises. The result is obtained
in Figure 2.10 on which we can see an inaccuracy area that is characteristic of an
ellipse. We will come back on this concept later in this course.
Figure 2.10: Result of 1000 executions of the solver with each time a different noise.
37
2 Static Estimation
Real case In practice, neither the satellite nor the receiver are perfectly synchro-
nized with the GPS time: they both have an offset dtu and dts with respect to the
GPS time.
Notations: s = satellite i ; u = receiver (user).
• tu (t) = t + dtu (t) (time in the time scale of the satellite)
• ts (t) = t + dts (t) (neglecting relativistic effects)
We note
1. ts (te ) the date on which the sequence has been issued in the time scale of the
satellite i,
2. tu (tr ) the date on which the sequence was received in the time scale of the
receiver.
The receiver matches the two sequences to obtain a measurement of the time of
flight, denoted △tm ("m" means measured).
△tm = tu (tr ) − ts (te )
Since tu (tr ) = tr + dtu (tr ) and ts (te ) = te + dts (te )
△tm = tr − te + dtu (tr ) − dts (te )
It is assumed that the wave signals propagate at the speed of light (denoted by
c).
The pseudo-range is denoted ρ (in meters) between the satellite and the receiver
is given by the relationship:
ρ = c.△tm
= c(tr − te ) + [Link] (tr ) − [Link] (te )
= R + [Link] (tr ) − [Link] (te )
where R is the geometric range between the satellite and the receiver.
38
2 Static Estimation
Effect of the ionosphere I Between 50 and a few hundred kilometers above, the
ionosphere is a high layer of the atmosphere ionized by the action of solar radiation.
It depends on the latitude, solar activity, time of year, day and night.
When the signal wave crosses this medium, everything happens as if the mea-
sured distance (in pseudo-range measure) was longer than the true geometric range
receiver-satellite. This is due to the fact that the electromagnetic waves passing
through the medium are delayed.
The effect on the measurement is an elongation I that may vary from 0 to 50 m.
Effect of the troposphereT Between the ground and 8-17 kilometers above the
troposphere is the lowest layer of the atmosphere.
It depends on the temperature, pressure, humidity and the elevation of the satel-
lite, but not in frequency. One has to use models to reduce it.
Signal delays are due to two phenomena:
• The path of the waves passing through this medium is curved path length is
increased,
Relativistic effects Rel Relativistic effects are due to the fact that there is a
difference in the gravitational field and especially a big difference in speed between
the satellite and the receiver. This results in an expansion of time and frequency
offset. Thus, will be modified:
39
2 Static Estimation
Noise measurements b The signal from the satellite being highly attenuated,
the receiver is forced to increase. Unfortunately the noise is also amplified. It is
considered that the noise of the measurement error causes a minimum of 1% of the
wavelength of the signal on which the measurement is made; for example, the C/A
code of wave length being of 300m this induces an error of 1 to 3 meters. This
noise affects the measurement of the time delay and therefore the calculation of the
pseudo-range.
Complete expression of the code measurement Taking into account the various
degradation, we obtained
Navigation message: GPS data The data message is transmitted (on L1 and L2)
at a rate of 50 bits/sec and provides information such as the health of the satellite,
its identification, ephemeris (orbit), its clock correction ionospheric correction ...
The complete message, 1500 bits long, is transmitted in 30 seconds but is frag-
mented into 5 portions of 300 bits long. Each portion contains 10 words of 30 bits
each.
The first two words of each section are identical; They contain general information
such as the number of satellite, its condition and the number of the GPS week.
Portion 1 shows the parameters of the satellite clock.
Portions 2 and 3 provide the satellite ephemeris containing the precise orbit of
the satellite, the clock correction data and ionospheric propagation.
Portion 4 provides correction settings ionospheric and tropospheric corrections.
Portion 5 provides satellite almanac. Almanacs contain less information than the
satellite ephemeris but give information on the other satellites. It is for this reason
that the entire message (1500 bit 30 sec) is repeated 25 times with different almanacs
(nevertheless, the 1-3 portions remain unchanged). Transmission of all the almanacs
lasts 25 * 30sec = 12.5 min.
40
2 Static Estimation
ρ = R + [Link] (tr )
Suppose that at a given moment, m satellites are visible and it is assumed m>4.
We proceed at a reception time noted tr . The satellites are at different distances
and thus the sending instants te,i of their C/A codes are different from each other.
Because the satellites broadcast orbits parameters to rebuild their position, we de-
note [xi (te,i ), yi (te,i ), zi (te,i )] T their coordinates at the emission times (and they are
assumed to be known without error).
By noting Xtr = [x(tr ), y(tr ), z(tr ), d(tr )] T an d ρtr = [ρ1 (tr ), ..., ρm (tr )] T , ob-
tained in vector form:
ρtr = g(Xtr , M )
where M contains the positions of the satellites at their emission time expressed
in the ECEF frame at the reception time.
With m >4, we are led to solve a nonlinear redundant system. This is a problem
of multi-sensor static fusion that we known how to solve.
41
2 Static Estimation
Figure 2.11: Surface of function z = 10x1 exp(−x21 − x22 ) − 1 and vector field of its
gradient.
42
2 Static Estimation
∇f (x) = 2.M.x
Example
2 1
" #" #
h i x1
f (x) = x1 x2 = 2x21 + 2x1 x2 + x22
1 1 x2
4 2 4x1 2x2
" #" # " #
x1
∇f (x) = =
2 2 x2 2x1 2x2
The matrix C T .M.C is still real, symmetric and positive definite, so,
(y T M.C.x)T = xT .C T .M.y
6
If f (x) = xT a is a linear form then its gradient vector is ∇f = a
43
3 Dynamic state estimation for
linear systems
One addresses a problem of state estimation, as soon as the system is dynamic, that
is to say that one has a model of the evolution of the state vector.
A state estimator is also called a state observer.
yk = [Link]
with dim(x)=n and dim(y)=m.
44
3 Dynamic State Estimation
u(t) y(t)
System
with state x(t)
x(t)
State Observer
Figure 3.1: State observation of a dynamical system. It can be noted that the ob-
server has two inputs.
yk = [Link]
We propose a dynamic observer of the type:
x(t)
xˆ (t )
45
3 Dynamic State Estimation
• It is not possible to give any confidence indicator associated with the estimate.
However, in many applications, confidence indicators are very important.
46
3 Dynamic State Estimation
E(a.x + c) = aE(x) + c
since p(x)dx = 1.
R
S
Variance
The variance is also called mean square deviation or central moment of order two:
Px = E((x − mx )2 )
It is easily shown that Px = E(x2 ) − E(x)2
Standard deviation
σx2 = Px
It characterizes the dispersion around the mean value.
47
3 Dynamic State Estimation
2. Two 6-sided dices (E(x)=E(y)=3,5 and the average product of all possible
combinations gives 3,52 ).
Random vectors
We generalize the dimension n, the concepts of the preceding paragraph.
Its mean is the mean vector of the components:
h iT
E(x) = mx = mx1 mx2 . . . mxn
We call covariance matrix2 :
Px = E[(x − mx )(x − mx )T ]
Px1 x1 Px1 x2 ...
Px = Px2 x1 Px2 x2 ...
... . . . P xn xn
Px1 Px1 x2 . . .
Px = Px1 x2 Px2 . . .
... . . . P xn
Note: xT .x is a scalar product, but [Link] is a matrix (n.n).
The Pxi xj are the covariances between the components of x.
Px is square and symmetric.
1
Strictly speaking, this coefficient should have been called covariance coefficient.
2
also known as variance-covariance matrix.
48
3 Dynamic State Estimation
Cross-covariance matrix
The covariance matrix of a vector reflects in particular the correlations between
components of this vector. The cross-covariance matrix of two vectors reflects the
correlations between the components of the two vectors.
Let be x and y two vectors not necessarily of the same size:
h iT h iT
x = x1 x2 . . . xn and y = y1 y2 . . . yp
The cross-covariance matrix is:
... . . . P xn yp
Pxy est (n.p). It is not square (so neither symmetric).
Pxy = Pyx
T
Mean
mz =mx +my
Covariance matrix
Pz =Px +Py +Pxy +Pyx
Where Pxy and Pyx are square cross-covariance matrices here because x and y are
of the same size.
Proof:
Pz =E{(x + y − mx − my ).(x + y − mx − my )T }
= E{(x − mx + y − my ).(x − mx + y − my )T }
By developing:
Pz =E{(x − mx ).(x − mx )T }+E{(x − mx ).(y − my )T }
+E{(y − my ).(x − mx )T }+ E{(y − my ).(y − my )T }
= Px +Py +Pxy +Pyx
Mean
mz = mx − my
49
3 Dynamic State Estimation
Covariance matrix
Pz = Px + Py − Pxy − Pyx
Proof:
Pz =E{(x − y − mx + my ).(x − y − mx + my )T }
= E{(x − mx − (y − my )).(x − mx − (y − my ))T }
=E{(x − mx ).(x − mx )T }-E{(x − mx ).(y − my )T }
-E{(y − my ).(x − mx )T }+ E{(y − my ).(y − my )T }
= Pz =Px +Py -Pxy -Pyx
Pz = Px + P y
Mean
my = [Link] + b
Covariance matrix
Py = [Link] .M T
Proof:
Py =E{y − my ).(y − my )T }
= E{(M.x + b − [Link] − b).(M.x + b − [Link] − b)T }
= E{M.(x − mx ).(x − mx )T .M T }
= M .E{(x − mx ).(x − mx )T }.M T
Mean
mz =[Link] + [Link]
Covariance matrix
Pz = [Link] .AT + [Link] .B T
50
3 Dynamic State Estimation
2 2
1 .5 1 .5
1 1
0 .5 0 .5
0 0
- 0 .5 -0 .5
-1 -1
- 1 .5 -1 .5
-2 -2
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
t t
The auto-correlation function Ψxx characterizes the temporal aspects (slow vari-
ations, fast ...). It is defined as:
[Link] Stationarity
By definition, x(t) is stationary if its spatial and temporal characteristics do not
depend on time:
1. E[x(t)]=cste
This is the steady state, that is to say that we "forgot" initial conditions.
The figure below shows two signals that are obviously non-stationary because
for one, the variance increases with time and the other has a correlation function
depending on the time, since his "nervousness" increases.
51
3 Dynamic State Estimation
200 2 .5
2
150
1 .5
100 1
0 .5
50
0
0 -0 .5
-1
-5 0
-1 .5
-1 0 0 -2
0 10 20 30 40 50 60 70 80 09 0 1100 0 20 30 40 50 60 70 80 90 100
t t
[Link] Ergodicity
An ergodic signal has its temporal moments that are identical to its statistical
moments which means, in other words, that a realization of an ergodic signal of
infinite duration contains the same information as an infinite number of realizations
of finite duration.
Consider for example a discrete signal xk . Under assumption of ergodicity, its sta-
tistical average can be calculated by computing the temporal mean and the variance
of a single infinitely long realization by:
lim 1X n
( )
mx = E(xk ) = xk
n→∞ n k=0
lim 1X n
( )
V ar(xk ) = (xk − mx )2
n→∞ n k=0
The discrete auto-correlation is given by:
lim 1 n−h
( )
Ψxx (h) = (xk − mx ) · (xk+h − mx )
X
n→∞ n k=0
In practice, the sequence is not of infinite size. In this case, we calculate estimates3 :
1X n
m̂x = xk
n k=0
1 n−h
Ψ̂xx (h) = (xk − m̂x ) · (xk+h − m̂x ) f or 0 < h < n − 1
X
n − h k=0
The auto-correlation h<0 is deduced from the positive part by symmetry.
52
3 Dynamic State Estimation
We have:
E[wk .wl ] = 0 if k̸=l
= q if k=l
4
The Dirac delta is a real function which is zero everywhere except at the origin, where it is
infinite: (
+∞, x = 0
δ(x) =
0, x ̸= 0
R∞
and which is also constrained to satisfy the identity −∞ δ(x) dx = 1.
R∞
It has also the property −∞ f (x)δ(x) dx = f (0)
53
3 Dynamic State Estimation
(x − mx )T P −1 (x − mx ) = k 2
1
h i
Z mx +kσ (x−mx )2
−
Pr = √ ·e 2σ 2
mx −kσ 2π · σ
In this case, for a given value k, we have:
1
Pr = − √ + 2Erf(k)
2π
with Erf(z) = exp(−t2 )dt
Rz
√2
π 0
54
3 Dynamic State Estimation
1
" #
σy2 −ρσx σy
P −1
= 2 2 (3.2)
σx σy (1 − ρ2 ) −ρσx σy σx2
The probability density function is then expressed as:
1 1 (x − mx )2 2ρ(x − mx )(y − my ) (y − my )2
( " #)
p(x, y) = √ exp − − +
2πσx σy 1 − ρ2 2(1 − ρ2 ) σx2 σx σy σy2
55
3 Dynamic State Estimation
Pr k
40% 1
87% 2
99% 3
99.97% 4
Table 3.1: Special values in 2D. Note that in 1D, a 1-sigma domain corresponds to
a probability of 68% which is significantly different to the 2D case.
It can be noticed on Fig. 3.8 that the evolution of k versus Pr is quite linear
up to 99% but for higher probabilities it becomes highly exponential. For high
probabilities, a small estimation error on the Gaussian will propagate strongly. In
other words, no Gaussian should be used in this case.
5.5
4.5
k value
3.5
X 0.9889
Y 3.001
3
2.5
2
0.95 0.96 0.97 0.98 0.99 1
Probability
For each value of k the contour of the probability ellipse is written in the form:
(x − mx )2 2ρ(x − mx )(y − my ) (y − my )2
− + = k2 (3.4)
σx2 (1 − ρ2 ) σx σy (1 − ρ2 ) σy2 (1 − ρ2 )
Figure 3.9 indicates particular values that allows to see how the ellipse changes
with respect to the correlation coefficient ρ.
y
kx
ky
ky 1
2
ky
my
kx
mx x
kx 1 2
56
3 Dynamic State Estimation
yk = [Link] + βk
Where dim(xk )=n dim(yk )=m and dim(uk )=p.
Noises αk (model noise) and βk (observation noise) are supposed centered which
means that the equations of the state space are on average accurate (no bias).
E(αk ) = 0 E(βk ) = 0
Then it is assumed that their respective covariance matrices Q and R are known
(and constant to ease equations).
var(αk ) = Q var(βk ) = R
57
3 Dynamic State Estimation
More they are assumed to be white. Finally, we assume that they are uncorre-
lated7 :
E(αk .βkT ) = 0
The problem is to find a good estimate of the state xk given observations yk from
the initial time to the instant l. The estimate of xk is denoted x̂k|l that is the
estimate of xk knowing everything that happened until the instant l.
The covariance matrix of the estimation error will be noted:
T
Pk|l = E x̂k|l − xk · x̂k|l − xk
1. Smoothing l>k,
2. Filtering l = k,
3. Prediction l<k.
7
or independent because we stop at the second order.
58
3 Dynamic State Estimation
k k+1 t
x̂ k / k x̂ k 1 / k 1
In practice, this is impossible because the computer must 1) recover the observa-
tions, 2) make processing, 3) provide a result.
Thus, the prediction step is done in anticipation for the next sampling instant.
The delay of the estimate is thus minimized.
acquisition
prediction
estimation
output
k k+1 t
x̂ k / k
59
3 Dynamic State Estimation
Note: n o
We have not assumed here that E ek|k−1 = 0, i.e. an unbiased prediction.
x̂ = M ym + b (3.8)
Where M and b have to be determined.
Figure 3.12 displays how the problem can be illustrated.
8
Generally speaking, any expectation of a white noise with errors or estimates made at the
previous sampling time will be zero (this property will be used many times thereafter).
9
We will see that the cross-covariance Pxy is given by Pxy = Px C T
60
3 Dynamic State Estimation
Px
x2 y2 Py
mx
^x my
ym Observation
x1 y1
Figure 3.12: Graphic illustration of the different steps used in linear estimation
Unbiased estimate
Let seek first an estimate with zero-mean error (called unbiased):
E(x̂ − x) = [Link] + b − mx = 0
b = mx − [Link]
So, equation 3.8 becomes:
x̂ = M ym + mx − [Link] = mx + M (ym − my )
M = Pxy .Py−1
M = Pxy .Py−1 + L
where L is a real matrix of any value.
61
3 Dynamic State Estimation
ŷk|k −1 = C x̂k|k −1
Let us compute the optimal linear estimate of the state using Eq. 3.9:
with
62
3 Dynamic State Estimation
Pk|k-1
x2 y2 Py
^xk|k-1
y^k|k-1
x^k|k
Pk|k
yk 2) Observation
x1 y1
Since yk = Cxk + βk :
T
Pxy = E xk − x̂k|k −1 · Cxk + βk − C x̂k|k −1
T
=E −ek|k−1 · −Cek|k −1 + βk
n o n o
= E ek|k −1 · eTk|k −1 · C T − E ek|k −1 · βkT
Since βk is white:
n o
Pxy = E ek|k −1 · eTk|k −1 · C T
= Pk|k −1 C T
Look at now at the covariance matrix Py .
n o
Py = E (y − my ).(y − my )T
n o
= E (yk − C x̂k|k −1 ).(yk − C x̂k|k −1 )T
n o
= E (Cxk + βk − C x̂k|k −1 ).(Cxk + βk − C x̂k|k −1 )T
n o
= E (−Cek|k −1 + βk ).(−Cek|k −1 + βk )T
Since βk is white:
n o n o
Py = C.E ek|k −1 · eTk|k −1 · C T + E βk .βkT (3.12)
and so
63
3 Dynamic State Estimation
This expression clearly shows that this is the covariance matrix of the innovation.
The Kalman gain is therefore:
−1
K = Pk|k −1 C T [Link]|k −1 .C T + R (3.14)
K = Pxy .Py−1
By taking the transpose
K T = Py−1 .Pxy
T
= Py−1 .Pyx
So
10
Another demo is given in Appendix 3.6.7 on page 68 starting from the Joseph’s form
64
3 Dynamic State Estimation
Notes:
1. The Joseph’s form (Eq.3.15) proves that Pk|k remains positive definite because
it represents the sum of positive definite matrices
2. The last expression (Eq. 3.17) indicates that trace(Pk|k )< trace(Pk|k−1 ) and
therefore the estimation step increases confidence.
3. The Joseph’s form may seem unnecessarily complicated, but is numerically
well conditioned. In addition, it is valid for any “estimator/predictor” observer
whatever its gain. The other forms are only valid for the Kalman filter.
Pk+1|k = A · Pk|k · AT + Q
yk = [Link] + βk
The state recursively estimated with the following algorithm particularly well
suited to real time implementation.
%Update stage
x̂ = x̂ + K · (y − C · x̂)
P = (I − KC) · P · (I − KC)T + K · R · K T %Joseph’s form
65
3 Dynamic State Estimation
3.6.6 Comments
• This estimation method bears the name of Kalman because he was the first to
found the expression of the optimal gain11 . Note that to calculate this term
one must compute the covariance matrix of the estimation error.
• A discrete Kalman filter implies the calculation of two steps during the same
sampling period: an estimation step and a prediction step.
• The expression Ax̂k|k + [Link] is the best prior prediction of x̂k+1|k , that is to
say, not taking into account observation yk+1 . This is consistent with common
sense: in the absence of additional information (namely observations yk+1 ),
it is natural to make the prediction follow the certain part of the evolution
model.
• The correction term K yk − C · x̂k|k −1 reflects the influence of the difference
between the observation yk and "the predicted observation" C · x̂k|k −1 . From
the difference thus obtained, a linear correction is developed, based on the
optimum gain matrix K.
• The expression of the optimal gain K can also be subject to simple consid-
erations: if one has great confidence in previous estimates and if the current
observation is considered doubtful, K must be small; conversely, if the above
estimates are unreliable and if the current observation is considered correct,
K should be high.
• If the matrices of the system and the noises covariances are constant, then the
gainK converges towards a constant. In this case, it can be calculated offline
and implement in an asymptotic filter. There is no matrix to calculate online.
11
that is to say, here, the gain that minimizes the variance of the estimation error.
66
3 Dynamic State Estimation
Algorithm 3.2 Sequential Kalman filter with two uncorrelated observation errors
x̂ = x"0 P = P0 #%init
R1 0
R=
0 R2
Loop
h i
y1 y2 ←Get_observations(); %sensor data
%Do two estimation steps sequentially
%First update
−1
K1 = P · C1T · C1 · P · C1T + R1
x̂ = x̂ + K1 · (y1 − C1 · x̂)
%x̂ on the right hand side is the previous prediction
%x̂ on the left hand side is a new estimate
P = (I − K1 C1 ) · P · (I − K1 C1 )T + K1 · R1 · K1T
%Second update
−1
K2 = P · C2T · C2 · P · C2T + R2
x̂ = x̂ + K2 · (y2 − C2 · x̂)
%x̂ on the right hand side is the previous estimate
P = (I − K2 C2 ) · P · (I − K2 C2 )T + K2 · R2 · K2T
%Provide the estimate x̂ and the P variance
%Time update for the next step
x̂ = A · x̂ + B · u %u is known
P = A · P · AT + Q
End Loop
Furthermore, it is shown that result of the fusion does not depend on the order
in which the observations are used12 .
12
It is quite easy to demonstrate since every use of an observation is optimal
67
3 Dynamic State Estimation
Pk|k = Pk|k −1 − KCPk|k −1 − Pk|k −1 C T K T + K · CPk|k −1 C T + R · K T
Yet −1
K = Pk|k−1 C T CPk|k −1 C T + R
−1 T −1
Therefore K = T
CPk|k −1 C + R
T T
CPk|k −1 = CPk|k −1 C + R
T T T T
CPk|k−1
Since Pk+1|k and R are covariance matrices that are symmetric, we have:
−1 = Pk|k −1 and R = R
T T
Pk|k
So −1
K T = CPk|k −1 C T + R CPk|k −1
KSK T = P C T S −1 SS −1 CP = P C T S −1 CP
Therefore
Pk|k = P − KCP
68
3 Dynamic State Estimation
(A − λ1 )ūx + B ūy = 0
(
Bux + (C − λ1 )ūy = 0
−(A−λ1 )
By choosing ux = 1 ⇒ uy = B
= −B
q (C−λ1 )
For normalization divided by norm = u2x + u2y
1
" #
ux
u=
norm uy
The angle of the axis associated with ⃗u is denoted by tan(φ) = −(A−λ B
1)
2 2
In its own frame, the ellipse is written as x + yb2 = 1 and we have λ1 ·x2 +λ2 ·y 2 = k 2
q 2 a2 q
Lengths of the two semi-axes: a = λk 1 b = λk 2
2
x = a cos(θ)
(
Then with the equations , for θ ∈ [0, 2π], we can represent the
y = b sin(θ)
ellipse in its own coordinate system.
To get it in the reference frame, it suffices to rotate by φ.
69
3 Dynamic State Estimation
70
4 Non linear systems
Here we are interested in observing the state of nonlinear systems.
71
4 Non linear systems
Therefore, in practice it is often limited to the second order, forgetting the mo-
ments of order greater than two. Transformations then become approximate.
x = mx + △x
One can note that P△x = Px .
If △x is "small" with respect to the non-linearity then to the first order we have:
" # " #
∂T ∂T
y = T (mx ) + (x − mx ) + ... = T (mx ) + .△x + ....
∂x mx
∂x mx
h i
where ∂T
∂x mx
is the Jacobian matrix of T at point mx .
∂T1 (mx ) ∂T1 (mx )
h i ∂x1
... ∂xn
∂T
= is a p.n matrix.
∂x mx ... ... ...
∂Tp (mx ) ∂Tp (mx )
∂x1
... ∂xn
Mean
my = T (mx )
72
4 Non linear systems
h i h i
Since my = E T (mx ) + ∂T
∂x mx
· ∆x = T (mx ) + ∂T
∂x mx
.E {∆x} and ∆x is
centered (E {∆x} = 0).
The linear transformation is applied to a random vector, which gives the covari-
ance matrix:
" # " #T
∂T ∂T
Py = .Px .
∂x mx
∂x mx
Note: This method requires relatively small deviations from the mean, which
means that, if an element of Px is "large", then Py will be a rough estimate.
4.2.2 Examples
[Link] Localization uncertainty from pseudo-distances
We saw previously (cf section [Link]) that if we concatenate the pseudo-range mea-
surements in a vector y = (ρ1 , ..., ρm )T , the unknown state x = (x, y, z, d)T relates
to measures by a nonlinear observation model:
y = g(x)
We can solve this system by the Newton’s method that we have already seen.
Let x̂ be this estimate.
Suppose that the covariance of the measures Py is known. We seek Px .
Apply the extended transformation:
" # " #T
∂g ∂g
Py = .Px .
∂x x̂
∂x x̂
h i
Note H = ∂g
∂x x̂
and multiply on the right by H:
73
4 Non linear systems
Py H = HPx H T H
If H T H is invertible then
−1
Py H H T H = HPx
The procedure is similar on the left:
−1 −1
HT H H T Py H H T H = Px
If it is assumed that the pseudo-range errors are uncorrelated with each other
and statistically identical, the Py matrix is a diagonal matrix whose diagonal is σ 2
everywhere.
Py = σ 2 Im
Then it comes:
−1 −1 −1
Px = σ 2 H T H H T Im H H T H = σ2 H T H (4.1)
−1
The matrix H T H therefore indicates how measurement inaccuracy is trans-
ferred to the state x. It is homogeneous to a covariance matrix.
The trace of a covariance matrix generally reflects inaccuracy (it is a measure of
the volume of the uncertainty ellipsoid).
We call Global Dilution Of Precision:
q
GDOP = trace (H T H)−1
The GDOP therefore reflects how the inaccuracy of measurements reports on the
position and time estimates (x, y, z, d) by neglecting the cross-correlations between
the measurement noises. It reflects the effect of the geometrical configuration.
Similarly, we define the PDOP as inaccuracy on position (x, y, z), the HDOP as
inaccuracy on 2D position (x, y) in the tangent plane to the Earth, the TDOP as
inaccuracy on the clock drift, and VDOP as inaccuracy on speed.
Py = σ 2 .Im
By using Eq. 4.1:
−1 σ2
Px = σ 2 H T H = σ 2 .m−1 =
m
If the variance of the noise on y is unknown (which can occur frequently in prac-
tice), an (unbiased) estimate of its variance is given by
1 X m
σ̂ 2 = (yi − x̂)2
m − 1 i=1
74
4 Non linear systems
−1
with x̂ = H T H H T y the least-squares estimated value.
So :
i=1 (yi
Pm
− x̂)2
Px =
m(m − 1)
E β.β = Py .
T
The offset dx(i) between the current estimate and the real value is defined by:
x = x̂(i) + dx(i)
Therefore, we have:
−1
dx̂(i) = H T Py−1 H H T Py−1 [Link](i) + β
−1 −1
dx̂(i) = H T Py−1 H H T Py−1 Hdx(i) + H T Py−1 H H T Py−1 β
−1
dx̂(i) = dx(i) + H T Py−1 H H T Py−1 β
The estimation error of the new estimate is given by:
e = x̂ − x = x̂(i) + dx̂(i) − x̂(i) + dx(i) = dx̂(i) − dx(i)
Therefore:
−1
e = H T Py−1 H H T Py−1 β
By definition, Px = E [Link]
( T )
−1 −1
Px = E H T
Py−1 H H T
Py−1 β. H T
Py−1 H H T
Py−1 β
−1 n o −1 T
Px = H T Py−1 H H T Py−1 E ββ T . H T Py−1 H H T Py−1
75
4 Non linear systems
−1 −1
Px = H T
Py−1 H H T
Py−1 Py Py−1 H H T
Py−1 H
since Py is symmetric.
Some simplifications occur. Let consider them one by one:
−1 −1
Px = H T
Py−1 H H T
Py−1 H H T
Py−1 H
−1 −1
Px = H T Py−1 H H T Py−1 H H T Py−1 H
−1
Px = H T Py−1 H
which demonstrates Eq. (4.3).
y = T (x)
where T (.) is a non-linear transformation that can be explicit (square, integral,...)
or implicit (min, max,...).
The unscented transformation algorithm is based on the idea that "it is easier to
approximate the transformation of a Gaussian probability density by points than to
approximate the non-linear transformation".
Let be a set of N points {xi }i=1,...,N , called “sigma points”, created from the mean
mx and the covariance Px . At each point xi , we associate a weight wi . There is a
good sampling condition because the points and weights must be chosen so that the
mean and variance of the points are respectively equal to mx and Px .
The good sampling condition is therefore verified if the two following conditions
are verified:
N
w i x i = mx
X
i=1
N T
wi xi − mx xi − mx = Px
X
i=1
76
4 Non linear systems
2. Estimate the mean of y using the transformed points and associated weights:
N
my = wi y i
X
i=1
N T
Py = wi y i − my y i − my
X
i=1
Sigma points xi
Covariance
Mean
my=T(mx)
y=T(x) T yi=T(xi)
T T
Py Px
x x
Covariance
Covariance
Covariance
my
Mean my=f(mx)
Figure 4.4: Comparison of the extended (center) and unscented (right) transforma-
tions. A 2x2 covariance matrix is represented by an ellipse.
For i=1,..,n√
xi = mx + n.M
√ (:, i) wi = 2n
1
End
M · M T = Px
M (:, i) denotes the ith column of matrix M . The calculation of this matrix can
be done in an efficient numerical way with Cholesky’s factorization. For example,
with Matlab, we just have to do:
77
4 Non linear systems
x0 = mx w0 = w0
For i=1,..,nq
1−w0
xi = mx + 1−w
n
0 .M (:, i) wi = 2n
0
xi+n = mx − (:, i) = 1−w
q
n i+n
1−w0
.M w 2n
End
This sampling is widely used in practice and generalizes the previous one with w0 =
0. See Fig. 4.5
2.5 6
2
4
1.5
2
1
0
0.5
−2
0
−0.5 −4
−1 −6
−1.5 −1 −0.5 0 0.5 1 1.5 2 2.5 3 3.5 −8 −6 −4 −2 0 2 4 6 8 10
Figure 4.5: Sigmas points calculated with the 2n+1 points method: w0 = 0 on the
left and w0 = 0, 9 on the right.
Here is a Matlab function that calculates sigma points (be careful, this code is
not optimized and written in an pedagogical form):
Here is a more optimized version for Matlab because the for loop is eliminated. This
program is less easy to read.
78
4 Non linear systems
x0 = mx w0 = w0
[V,D] = eig(P);%Eigenvectors and eigenvalues matrices
For i=1,..,n q 0
xi = mx + 1−w D (i, i).V (:, i) wi = 1−w
q
n
0. 2n
q
1−w0
xi+n = mx − D (i, i).V (:, i) wi+n =
q
n
1−w0
. 2n
End
Where V (:, i) is the ith eigenvector and D (i, i) is its eigenvalue which represents
the variance along this direction, and so the square-root has to be taken.
This choice for the sigma points has two advantages :
• The sampling is along the main axes of the covariance which is well conditioned
(Fig 4.6),
Sigma points
-1
-2 -1 0 1 2 3 4
Figure 4.6: Sigmas points calculated with the 2n+1 points method along the prin-
cipal components with w0 = 0, 2.
79
4 Non linear systems
xk+1 = f (xk , uk ) + αk
(
(4.4)
yk = g (xk ) + βk
The idea is to come back, after a linearization to a first order, to the linear filter
described in chapter 3.
Linearization can be done around a predefined reference path: in this case we get
the Linearized Kalman Filter 1
Linearization can also be done around the previous predicted or estimated values
(Extended Kalman Filter EKF2 ).
The second solution is the most widely used because it can be used even if the
path is unknown.
zk = C k xk + βk
1
for example, in the case of a rocket, the path is known in advance.
2
The first applications were for the Apollo mission (1961 - 1962).
80
4 Non linear systems
ek|k = x̂k|k − xk
= x̂k|k−1 + K yk − g x̂k|k−1 − xk
= x̂k|k−1 + K g (xk ) + βk − g x̂k|k−1 − xk
≈ x̂k|k−1 − xk + K g x̂k|k−1 + Ck xk − x̂k|k−1 + βk − g x̂k|k−1
≈ x̂k|k−1 − xk + K −Ck x̂k|k−1 − xk + βk
= (I − KCk ) ek|k−1 + Kβk
So
[Link] Prediction
x̂k+1|k = Ak x̂k|k + ǔk
= Ak x̂k|k + f x̂k|k , uk − Ak x̂k|k
= f x̂k|k , uk
So we can forget ǔk which was only used to state the problem.
ek+1|k = x̂k+1|k
− xk+1
= f x̂k|k , uk − (f (xk , uk ) + αk )
≈ f x̂k|k , uk − f x̂k|k , uk + Ak . xk − x̂k|k − αk
≈ Ak ek|k − αk
So
81
4 Non linear systems
%Cartesian-polar transformation
syms x1 x2; %definition of symbolic objects
% function definition
f = [x1*cos(x2); x1*sin(x2)];
%Jacobian
jacob= [diff(f(1),x1) diff(f(1),x2);
diff(f(2),x1) diff(f(2),x2)]
xk+1 = f (xk , uk ) + αk
(
yk = g (xk ) + βk
The state is recursively observed with the following algorithm particularly well
suited to real time implementation.
%Initialization
x̂ = xh0 P = iP0
C = ∂x ∂g
(x̂)
−1
K = P · CT · C · P · CT + R
Sampled loop
%Sensor data
y←Get_observation()
%Update stage
x̂ = x̂ + K · (y − g (x̂))
P = (I − KC) · P · (I − KC)T + K · R · K T
%Provide the estimate x̂ and the estimated variance
%of the estimation error P to client applications
C = ∂x (x̂)
∂g
−1
K = P · CT · C · P · CT + R
End Loop
82
4 Non linear systems
Step 1 (initialization): Set i = 0 and choose the estimate x̂ik = x̂k|k−1 (the super-
script i denotes the number of iteration) for the linearization.
Step 2 (observation update iterations): Compute the Jacobian matrix at the best
state estimate available, the Kalman gain, and the next iteration of the state
estimate as
h i
• Jacobian matrix : Cki = ∂g
∂x
(x̂ik )
−1
• Kalman gain Kki = Pk|k −1 Cki Cki Pk|k −1 Cki + R
T T
n o
• x̂i+1
k = x̂k|k−1 + Kki yk − g (x̂ik ) − Cki x̂k|k−1 − x̂ik
• x̂k|k = x̂i+1
k
T
• Pk|k = (I − Kki Cki ) Pk|k −1 (I − Kki Cki ) + Kki RKki
T
When there is no iteration, the IEKF is an EKF. Indeed, since x̂k|k−1 = x̂0k , we
have:
n o n o
x̂k|k = x̂k|k−1 + Kki yk − g x̂0k = x̂k|k−1 + Kki yk − g x̂k|k−1
In step 2 when the solution x̂ik evolves, the term −Cki x̂k|k−1 − x̂ik shows that
the optimization problem takes into account the prediction. Therefore, the IEKF
is not a Maximum Likelihood (ML) estimator but a Maximum A Posteriori (MAP)
estimator.
Please note that like any Gauss Newton method, the convergence of the iteration
method is not guaranteed.
83
4 Non linear systems
%Initialization
x̂ = x0 P = P0
Sampled loop
%Sensor data
y←Get_observation()
%Update stage
xi = x̂ %x̂ is the prediction
bool = True
While bool
h doi
C = ∂x ∂g
(xi )
−1
K = P · CT · C · P · CT + R
xi+1 = x̂ + K · (y − g (xi ) − C (x̂ − xi ))
bool=(norm(xi+1 − xi ) >Threshold)
xi = xi+1
End While
x̂ = xi+1
P = (I − KC) · P · (I − KC)T + K · R · K T
%Provide the estimate x̂ and the estimated variance
%of the estimation error P to client applications
%nexth step i
A = ∂f ∂x
(x̂, u)
x̂ = f (x̂, u) %u known from the control program
P = A · P · AT + Q
End Loop
84
4 Non linear systems
4.6.1 Update
The Kalman gain is given by the same formula K = Pxy Py−1 . We use sigma points
to compute Py−1 and Pxy .
i=1
85
4 Non linear systems
N T
Py = wi y i − ŷk y i − ŷk +R (4.6)
X
i=1
As the noise βk is white and uncorrelated with the prediction, we can remove it
from the computation:
T
Pxy = E xk − x̂k|k −1 · g(xk ) − g(x̂k|k −1 )
n o
Pxy = E xk − x̂k|k −1 · (g(xk ) − ŷk )T
So the cross-covariance matrix can be computed using the sigma points of the
predicted state and the ones of the predicted observation:
N T
Pxy = wi xi − x̂k|k−1 y i − ŷk (4.7)
X
i=1
[Link] Update
We can compute the Kalman gain:
Please note that we use here the third form (P = P − [Link] .K T ) which is nice in
this problem since we don’t manipulate any Jacobian matrix.
86
4 Non linear systems
Px
Py
x2 y2
mx
my
x
y Observation
4.6.2 Prediction
After having done the update, we have an estimate and a covariance matrix which
allows to compute new sigma points.
We pass the sigma points through the evolution model:
For i = 1..N, xi = f xi
and so
N
x̂k+1|k = w i xi (4.11)
X
i=1
We compute their variance and add the variance of the model error:
N T
Pk+1|k = wi xi − x̂ xi − x̂ +Q (4.12)
X
i=1
Px
x2 x2
mx
x1 Instant: tk+1 x1
Instant: tk
87
4 Non linear systems
%Initialization
x̂ = x0 P = P0
Sampled loop
%----- Update-------------
%Sampling of the points
[xi , wi , N ]=sigma_points(x̂, P )
%Instanciation of the points with the observation model
For i = 1..N , y i = g (xi ) End
%Prediction of the observation
ŷ = N i i
P
i=1 w y
%Covariance matrix of the predicted observation
T
Py = N i=1 w (y − ŷ) (y − ŷ) + R
i i i
P
%Cross-covariance matrix
T
Pxy = N i=1 w (x − x̂) (y − ŷ)
i i i
P
End Loop
88
5 Bayesian filtering for nonlinear
systems
5.1 Introduction
In the linear case (with a linear state space representation) with white Gaussian
noises, it is sufficient to estimate sequentially the mean of the state and the covari-
ance of the estimation error. In this case, the optimal solution is the Kalman filter.
If the state equations of the system are nonlinear, then the probability density that
characterizes the state does not remain a Gaussian, even if the noises are Gaussian.
We should therefore consider all the statistical moments and not just the mean and
covariance. Finally, if the noises are not Gaussian and the system is non linear, we
have to estimate the probability density function (pdf ) as a whole.
Bayesian filtering is a technique that allows the propagation of probability densi-
ties according to the predictor / estimator mechanism initialized with a prior infor-
mation denoted p(x0 ). In general, there is no analytical solution. Several numerical
approaches are good approximations.
p(x)
support S
89
5 Bayesian filtering
p(x, y)
p(x|y)=
ˆ
p(y)
This can be written as,
p(y|x)p(x)
p(x |y ) = (5.1)
p(y)
The marginal distribution p(y) can be seen as a function that normalizes p(x |y )
(such that its integral over the support equals one).
p(y) can also be rewritten as:
Z
p(y) = p(y|x)p(x)dx
p(y|x)p(x)
p(x |y ) = R
p(y|x)p(x)dx
Eq 5.1 can be rewritten:
p(y|x, z)p(x|z)
p(x|y, z) =
p(y|z)
• p(x) is the prior distribution and indicates what values of x might be expected
before having an observation,
90
5 Bayesian filtering
• p(y|x) is the conditional distribution and serves the role of a sensor model
when we do estimation.
• Conversely, once the sensor model exists, observations (numbers not distribu-
tions) are made:
y = ym (“m” as “Measured”). This is a fixed value.
From this, we want to infer the state x.
p(y = ym |x) is now a distribution in x. This distribution is known as the
Likelihood Function.
y =x+β
A commonly used probabilistic model for such an observation is a Normal (Gaus-
sian) distribution with mean x and a variance σ 2 as [6]:
1 (y − x)2
p(y|x) = η exp(− ) (5.2)
2 σ2
It should be clear that this is a simple function of both y and x.
If we know the true value of the state, x = xr , then the distribution is a function of
y only; describing the probability of observing a particular value of range (Normally
distributed around the true range x with variance σ 2 ).
Conversely, if we make a specific observation, y = ym , then the distribution is
a function of x only; describing the probability of the true range value (Normally
distributed around the range observation ym with variance σ 2 ). In this case, the
distribution is the Likelihood Function.
Now assume that we have some prior belief about the true state x encoded in a
Gaussian prior as
1 (x − xp )2
p(x) = ηp exp(− )
2 σp2
This is a function of a single variable x (with xp fixed). Bayes theorem can be
directly applied to combine this prior information with information from a sensor,
modeled by 5.2. First, an observation (technically, an experimental realization), ym ,
is made and instantiated in Equation 5.2. This is the sensor model:
1 (ym − x)2
p(y = ym |x) = η exp(− )
2 σ2
91
5 Bayesian filtering
Then the prior and sensor model are multiplied together to produce a posterior
distribution (which is a function of x only):
1 (ym − x)2 1 (x − xp )2
p(x|y = ym ) = η2 exp(− ) exp(− )
2 σ2 2 σp2
η2 is a normalizing constant that doesn’t depend on x.
The product of two Gaussians is a Gaussian (Fig. 5.2):
1 (x − x)2
p(x|y = ym ) = η2 exp(− )
2 σ2
The values x and σ 2 are easy to find.
0.05
likelihood
0.045 prior
posterior
0.04
0.035
0.03
0.025
0.02
0.015
0.01
0.005
0
0 1 2 3 4 5 6 7 8 9 10
Figure 5.2: Data fusion of two Gaussians. It can be seen that the result is less
uncertain.
p(x)
support S
92
5 Bayesian filtering
i=1
where
• S is the number of elements xi of the support, d
• δ() isRthe Dirac delta function such that δ(x − a) = 0 for every x ̸= a and such
that δ(x)dx = 1,
• and the probabilities (or masses) ω i = P r(x = xi )3 of the components comply
with the following conditions:
ω i = 1 et ω i > 0 ∨ xi ∈ S
X
i
It can be noted that the identifier of a discrete element is an exponent, not to be
confused with indexes that indicate a temporal sampling as xk .
In practice, the distribution is represented by a vector:
p(y|x).p(x)
p(x |y ) = P
p(y|x).p(x)
x
It can be written with a normalization term η:
p(x |y ) = η.p(y|x).p(x)
1
η=P (5.3)
p(y|x).p(x)
x
Equation (5.3) shows that the normalization term η can be calculated once every
p(y|x).p(x) has been calculated to make the distribution sum to one.
Please note that with discrete distributions, the product of the Bayes formula
is an element-wise product (term by term) of two vectors. Sometimes it is clearly
stated by using the symbol ⊗ (element-wise product).
p(x) =
X
p(x, y)
y
p(x, y) = p(x|y).p(y)
again with an element-wise product.
2
Attention: this is a spatial discretization of the support S (not a time discretization)
3
P r is used for “Probability”
93
5 Bayesian filtering
The conditional distribution p(y|x) is obtained such that every column sums to
1. Please note that it remains a 2D matrix.
p(y|x) x=1 x=2 x=3
y=1 0.5 0.33 0
y=2 0.5 0.5 0.5
y=3 0 0.166 0.5
94
5 Bayesian filtering
x2
x1
Figure 5.4: Estimated pose of the vehicle with respect to the map
For the current situation, we have the following models described by following
likelihood matrices p(y|x).
Since the heading is close to road 2:
x1 x2
y1 0.1 0.9
Since the distance is almost the same with the two roads:
x1 x2
y2 0.45 0.55
Every row is a Likelihood Function.
Suppose we have no prior information (first map-matching), that is P r(x = x1 ) =
0.5 and P r(x = x2 ) = 0.5.
So, the prior distribution is the vector
95
5 Bayesian filtering
p(x |y ) = ηp(y|x).p(x)
η being a normalization constant.
By using the element-wise product ⊗ to make that clear, we have:
Suppose now that, from a previous stage, we knew that the vehicle was more
likely on road x2 with the prior knowledge P r(x = x1 ) = 0.3 and P r(x = x2 ) = 0.7.
This is a sequential map-matching.
Let us consider the second criterion. Note that it is in accordance with the first
one but provides little information.
96
5 Bayesian filtering
• Measurement update
Consider the non-linear system represented by the following discrete time equations:
xk+1 = f (xk , uk ) + αk
(
(5.4)
yk = g (xk ) + βk
where αk and βk represent the model and observation noises with distribution pα
and pβ respectively. They are supposed additive, white and independent. Here, the
input uk is known.
Based on these hypotheses, the system is said to be “Markov”. The Markov
hypothesis states that any knowledge about the system is contained in the current
state xk .
p(y|x).p(x)
p(x|y) =
p(y)
Bayes’ theorem allows to move from a prior distribution p(x) to a posterior p(x|y)
using the likelihood p(y|x) of the observations.
Considering all the measures y1:k , we have:
97
5 Bayesian filtering
4
called MMSE - Minimum Mean-Square Error
5
Known as Chapman-Kolmogorov equation
98
5 Bayesian filtering
i=1
where:
N
ωki = 1
X
i=1
In a grid filter, the center of each cell contains a Dirac delta. The grid is handled
by nxn table. In 2D, it is a matrix. The elements of the grid contains the values ωki .
Consider now the data fusion problem of two sensors that are fixed in the envi-
ronment and that observe a common space to localize a target that is fixed.
We have the prior knowledge p(x, y) shown in Fig. 5.6.
99
5 Bayesian filtering
The posterior distribution having made this first observation is shown in figure
5.8and is computed from the point-wise product of prior and likelihood matrices :
100
5 Bayesian filtering
The resulting matrix is normalized such that the sum of all its elements sum-up
to one.
It can be seen (Fig 5.8) that the distribution defining target location is now
approximately restrained to a line along the detected bearing.
A second sensor (sensor 2) now takes observations of the target from a location x =
0, y = 50. Figure 5.9 shows the target likelihood p(z 2 |x, y) following an observation
z 2 by this sensor. It can be seen that this sensor (like sensor 1) has high bearing
resolution, but almost no range resolution. However, because the sensor is located
at a different site, we would expect that the combination of bearing information
from the two sensors would provide accurate location data.
101
5 Bayesian filtering
1), we obtain the posterior p(x, y|z 1 , z 2 ) shown in figure 5.9 which indicates that the
probability mass is now highly concentrated around a single target location.
Observation Update
To obtain the posterior, we use Bayes’ rule to update the weights of the cells ac-
cording to their measurement likelihoods as we did before.
102
5 Bayesian filtering
Prediction
The state of the system is changing over time.
We use the evolution model to make the grid evolve.
Using Eq. (5.13) in Eq. (5.12), we get:
N
Z !
p (xk+1 |y1:k ) = p (xk+1 |xk ) i
xik )
X
ωk|k .δ(xk − dxk
i=1
The mass in cell i is the sum of the mass of all cells that move into it with respect
to their probability thanks to the evolution model.
Denote
N
i
= j
ωk|k .p xik+1 xjk
X
ωk+1|k
j=1
In practice, to efficiently update the grid upon robot motions, one typically as-
sumes a bounded Gaussian model for the motion uncertainty [24]. The update is
then done by shifting the data in the grid according to the measured motion (cf
figure 5.11). In a second step, the grid is then convolved using a Gaussian Kernel
(cf figure 5.13) to take into account the uncertainty on the knowledge of the motion
(cf figure 5.12). Indeed, the probability density of the sum of two independent real
random variables is the convolution product of the probability densities of these two
variables.
The evolution model can be given by another grid containing estimates of the
speed of every occupancy cell (this technique is called Bayesian Occupancy Filter -
BOF) [5].
7
this is the MMSE estimate
103
5 Bayesian filtering
Figure 5.11: Grid uncertainty after having applied the motion of the robot.
Figure 5.12: Grid uncertainty after convolution with the Gaussian kernel. It can be
noted that the uncertainty is increased.
104
5 Bayesian filtering
• The prediction itself needs many computation since all the cells that change
have to be evaluated with a convolution product.
In practice, one prefers to use alternative methods such that the particle filter.
105
5 Bayesian filtering
5.5.1 Principle
The main idea of particle filtering is to approximate p (xk |y1:k ) by a finite set of
N
particles with associated weights {xik , ωki }i=1 . The weight of each particle reflects
the probability that the particle is at a relevant position of the state space. This
approach is called importance sampling.
Sequential Monte Carlo methods allow an implementation of a Bayesian filter
through numerical approximations. This is the Particle Filter. Discrete samples are
obtained by simulation to approximate a probability distribution that we can not
calculate analytically. The greater the number of particles, the better the approxi-
mation. With the evolution of computer technology, these filters have become very
popular and are applied in robotics applications, such as positioning problems [7].
For instance, Z
x̂k = xk .p (xk ) dxk
N
If it is possible to generate samples {xi }i=1 according to p (x), then a Monte Carlo
approximation of the integral is given by:
1 XN
E (h (x)) ≈ h xi
N i=1
Imagine that we cannot generate samples from p (x) but there is another distri-
bution q (x) from which we can generate samples.
The integral in this case is
Z
p (x)
E (h (x)) = h (x) q (x) dx
q (x)
1 XN p (xi )
E (h (x)) ≈ h xi
N i=1 q (xi )
Let denote
p (xi )
ω =i
q (xi )
106
5 Bayesian filtering
1 XN
E (h (x)) ≈ h xi ω i
N i=1
Example By Monte Carlo integration, we try to calculate the mean and variance
of a normal distribution with mean m = 5 and standard deviation σ = 1, 5.
e− 2 ( )
1 x−m 2
p(x) = √1
σ 2π
σ
Imagine that we only have a uniform random number generator (which in addition
leads to very simple expressions as we shall see).
For example, generate 100 samples xi on a fairly wide support (it is better to have
a too large than a too small support).
Calculate the mean (5.7):
Z
p (x)
m= x q (x) dx
q (x)
q (x) being constant, we have:
1Z
m= xp (x) q (x) dx
η
where η = S1 is the inverse of the length S of the support of the uniform law.
We then calculate the value of each sample by the function of interest (which is
here the probability density p (x)).
Drawing N samples according to q, it is achieved to calculate the mean of p (x)
by a Monte Carlo method:
xi p (xi )
PN
i=1
m ≈ S.
N
0.30
0.25
0.20
0.15
0.10
0.05
0.00
-2 0 2 4 6 8 10 12
107
5 Bayesian filtering
0.30
0.25
0.20
0.15
0.10
0.05
0.00
-2 0 2 4 6 8 10 12
With 1000 samples, we get: m c = 5.0121, what is better and perfectly illustrates
the fact that as the number of samples increases, the numerical calculation by Monte
Carlo is better.
Table 5.1: Scilab program. The instrumental generator is uniform with a support of
length 10
i=1
Let us sample the particles with a random generator q (x). We need to modify
the weights accordingly:
p (xik |yk )
ωki =
q (xik |yk )
108
5 Bayesian filtering
Yet
q xi0:k |y1:k = q xi0:k−1 , xik |y1:k = q xi0:k−1 |y1:k · q xik xi0:k−1 , y1:k
As we use a causal instrumental generator (the past doesn’t depend on the present)
and yk has to be removed:
q xi0:k−1 |y1:k = q xi0:k−1 |y1:k−1
and so:
p (y1:k |xi0:k ) p (xi0:k )
ωki =
q xi0:k−1 |y1:k−1 · q xik xik−1 , yk
Multiplying the numerator and the denominator by p y1:k−1 xi0:k−1 p xi0:k−1 :
p y1:k−1 xi0:k−1 p xi0:k−1 p (y1:k |xi0:k ) p (xi0:k ) 1
ωki = · ·
q xi0:k−1 |y1:k−1 p y1:k−1 xi0:k−1 p xi0:k−1 q xik xik−1 , yk
p xi0:k = p xik xi0:k−1 .p xi0:k−1
p (yk |y1:k−1 , xi0:k ) .p y1:k−1 xi0:k−1 .p xik xi0:k−1 .p xi0:k−1 1
ωki = ωk−1
i
· ·
p y1:k−1 xi0:k−1 p xi0:k−1 q xk xik−1 , yk
i
Simplifications appear:
p (yk |y1:k−1 , xi0:k ) .p xik xi0:k−1
ωki = ωk−1
i
·
q xik xik−1 , yk
109
5 Bayesian filtering
p yk y1:k−1 , xi0:k = p yk xik
Finally, we obtain the following expression:
p (yk |xik ) p xik xik−1
ωki = ωk−1
i
· (5.14)
q xik xik−1 , yk
The random generator q xik xik−1 , yk can be chosen to compute samples using
the previous state and the current measurements.
In other words, the particles are simply drawn by the prediction model8 without
using the current measurement.
It is very popular since it leads to a simple formulation
ωki = ωk−1
i
· p yk xik (5.16)
Thus, updating the weight of the particles simply consists in multiplying the
weight of each particle by the likelihood.
The Bootstrap Particle Filter is not the more powerful technique, but is very easy
to implement.
ω ik = ω ik| · pβ yk − g xik|k−1 i = 1, . . . , N
The likelihood of each particle is evaluated individually.
We normalize the weights:
ωi
ω̃ki = P k i
ωk
Estimates of the state vector and of the covariance matrix are given by:
x̂k|k =
PN
i=1 ω̃ki · xik
T
Pk|k =
PN i i i
i=1 ω̃k · xk − x̂k|k · xk − x̂k|k
8
That is to say, the evolution model of the state and the model noise
110
5 Bayesian filtering
%Initialization
Generate N particles xi using the prior distribution
i.e. distribute them and give them a weight ω i
Sampled loop
y←Get_measure() %sensor data
%Update the weight of each particle according to its likelihood
ω i = ω i · p β y − g xi i = 1, . . . , N
i
%Normalize the weights ω i = Pω ωi
%Estimate the state and cov and provide the result
x̂ = N i
i=1 ω · x
i
P
T
P = N i=1 ω · (x − x̂) · (x − x̂)
i i i
P
αi ← M yRandomGenerator(N, pα )
%Add them to the particles passed into the evolution model
xi = f xi + αi
End Loop
111
5 Bayesian filtering
prediction
Likelihood
Update
Resampling
%Initialization
Generate N particles xi using the prior distribution
i.e. distribute them and give them a weight ω i
Sampled loop
y←Get_measure() %sensor data
%Update the weight of each particle according to its likelihood
%Normalize the weights
%Estimate the state and cov and provide the result
Resample the particles set
%Prediction
%Draw randomly N samples α according to pα
%Add them to the particles passed into the evolution model
End Loop
Table 5.3: SIR particle filter with a resampling done at every step
112
5 Bayesian filtering
Initialization
Resampling
Time
• The number of effective particles is maximized when all the weights are equal.
In this case, Nef f = N .
• It is minimum when only a weight is not zero. In this case, the weight of this
particle is 1 and Nef f = 1.
113
5 Bayesian filtering
%Initialization
Generate N particles xi using the prior distribution
i.e. distribute them and give them a weight ω i
Sampled loop
y←Get_measure() %sensor data
%Update the weight of each particle according to its likelihood
%Normalize the weights
%Estimate the state and cov and provide the result
If Nef f ≤ T h Then Resample the particles set
%Prediction
%Draw randomly N samples α according to pα
%Add them to the particles passed into the evolution model
End Loop
Table 5.4: SIR particle filter with a resampling done when necessary.
There are many particle filtering enhancements, the most important are:
1. One can adapt the number of particles as a function of the complexity of the
problem (KLD-sampling).
2. If the state space contains contains linear parts (in evolution or observation),
one may proceed to do some factorizations (Rao-blackwellized particle filter).
3. One can improve the resampling and fight against its impoverishment with
MCMC (Markov Chain Monte Carlo) methods. The best known are Gibbs
and Metropolis-Hasting samplings [17].
4. You can change the random drawing law q (xk |x0:k−1 , y1:k ) for which takes
into account the current measurements. A simple and effective technique is
to modify the bootstrap filter by drawing several random particles for every
particle (typically between 3 and 10). The particle with the highest likelihood
is kept. This way, the drawing incorporates the current measure. This en-
hancement allows you to run a particle filter when the observation noise is
low. It also reduces the number of particles.
114
6 Frames transformation with
associated uncertainties
6.1 Introduction
Localizing a robot means knowing its position in a given frame. Since we use direct
orthonormal frames, each frame is completely defined by its pose, which gives the
position (2D or 3D) of the origin and the orientation (2D or 3D) of the frame. This
chapter is inspired from Elwan Héry’s PhD Thesis [8].
The operators ⊕ and ⊖ introduced by Smith, Self and Cheeseman [23] for frame
transformations are very efficient tools. These notations make it possible to lighten
the equations, by manipulating the transformations in frames as easily as the compo-
sition of the vectors in a Cartesian frame. In this document, we are only interested
in 2D poses characterized by vectors of dimension three, containing a Cartesian
position and a heading angle.
The pose k qi describing the translation and rotation to apply to the Rk frame to
transform it into the Ri frame is :
k
xi
k
qi = (6.1)
k
yi
k
θi
k
qi represents also frame Ri in frame Rk , the heading angle of the abscissa axis of
Ri being k θi .
In addition, transformations have uncertainties; they are probabilistic with covari-
ance matrices. The propagation of these uncertainties during transformations can
use first order approximation of the equations that are non-linear due to rotations.
These error propagation mechanisms are only valid for small errors with respect to
non-linearities.
6.2 Notations
The pose q = (x y θ)T represents the position p = (x y)T and the orientation θ of a
robot. It is important to express each of these quantities in a given reference frame.
In case several robots are present, it is also useful to be able to differentiate the data
of the different robots. We use indices and exponents to solve these problems.
Table 6.1 represents the different parts of a given pose.
Table 6.2 shows the notations of the indices and exponents used for any given
data z . The index i at the bottom right represents the robot, linked to the data
z. The exponent in the upper left corner indicates the frame in which the data z is
expressed. Thus a given index i can refer to the pose or the frame. ẑ represents the
estimate of z, z ∗ its ground truth. The covariance matrix of z is expressed as Pz and
the cross-covariance matrix between two vectors z1 and z2 is expressed as Pz1 ,z2 .
115
6 Frames transformation with associated uncertainties
Figure 6.1: Transformations of frame. The curved arrow k qi represents the transla-
tion and rotation to be applied to the Rk frame to transform it into the
Ri frame. The curvature of the arrow indicates the sign of the rotation
.
By combining tables 6.1 and 6.2, we can define any element of the state for any
robot in a given reference frame. For example, i qj refers to the pose of robot j in
the frame i.
It can be noted that the indices and exponents "j" are linked in a simple way.
The concepts of (direct orthonormal) frames, poses and frame transformations
contain the same information. By considering the poses as frame transformation
116
6 Frames transformation with associated uncertainties
functions, we can then see the operator ⊕ as the operator ◦ of function composition
as well:
k
qi =k qj ⊕ j qi (6.3)
k
qi () =k qj j
qi ()
=k qj ◦ j qi () (6.4)
Note that the operation to be applied to the right term depends on the left term.
The operator ⊕ is not commutative but is associative like the function composi-
tion.
In order to propagate the uncertainty represented by a covariance matrix, a first-
order approximation can be made:
!
Pk qj Pk qj ,j qi
Pk qi ≈ J⊕ J⊕T (6.6)
Pj qi ,k qj Pj qi
The cross-covariance sub-matrix Pk qj ,j qi is the symmetric matrix of the sub-matrix
Pj qi ,k qj and are often taken null in practice if this assumption holds.
The Jacobian matrix J⊕ is defined by :
117
6 Frames transformation with associated uncertainties
∂ k qi ∂ k q j ⊕j qi ∂ k qj ⊕j qi
J⊕ = k j = = (6.7)
∂ ( q j , qi ) ∂ (k qj , j qi ) ∂ (k xj ,k yj , k θj , j xi , j yi , j θi )
1 0 −j xi sin θj −j yi cos cos 0
k k k k
θj θj −sin θj
=
0 1 xi cos θj −j yi sin sin cos 0
j k k k k
θj θj θj
0 0 1 0 0 1
By calculating the pose k qi before the Jacobian, the latter can then be expressed
directly from the new coordinates without recalculating some sine and cosine. We
then obtain the original formula of Smith, Self and Cheeseman [23]:
1 0 − cos 0
k
yi − k yj k
θj −sin k
θj
J⊕ = (6.8)
0 1 sin cos 0
k
xi − k xj k
θj k
θj
0 0 1 0 0 1
= xi sin (j θi ) − j yi cos (j θi )
j
−j θi
−j xi cos (−j θi ) + j yi sin (−j θi )
−j θi
cos (−j θi ) −sin (−j θi ) 0
= sin (−j θi ) cos (−j θi ) 0 −j qi (6.10)
0 0 1
By considering the poses as functions for changing frames, the operator ⊖ is
equivalent to inverting this function:
i
qj = ⊖j qi (6.11)
i
qj () =j qi−1 () (6.12)
In the same way as for the operator ⊕, by applying a first-order approximation,
we can propagate the covariance matrix:
Pi qj ≈ J⊖ Pj qi J⊖T (6.13)
with
−cos (j θi ) −sin (j θi ) xi sin (j θi ) − j yi cos (j θi ) j
∂ qj ∂ (⊖ qi )
i j
J⊖ = j = = sin (j θi ) −cos (j θi ) j
xi cos (j θi ) + j yi sin (j θi )
∂ qi ∂ j qi
0 0 −1
(6.14)
This expression can be simplified from the coordinates of qj :
i
−cos (j θi ) −sin (j θi ) i yj
0 0 −1
118
6 Frames transformation with associated uncertainties
Property
We have:
j
qi = ⊖i qj = ⊖ ⊖ j qi (6.16)
Demonstration
By propagating the uncertainty of the covariance matrix Pj qi twice:
sin (i θj )
J⊖′ = −cos (i θj ) −j xi
(6.18)
0 0 −1
−cos (j θi ) sin (j θi ) j
yi
= −sin ( θi ) −cos ( θi ) − xi
j j j
0 0 −1
By developing
c2 + s2 cs − sc −i yj c − i xj s − j yi
J⊖′ J ⊖ = sc − cs s2 c2
−i yj s + i xj c +j xi (6.19)
0 0 1
J⊖′ J ⊖ = 0 1 0 (6.22)
0 0 1
As
1 0 0
T
J⊖T J⊖′T = J⊖′ J ⊖ = 0 1 0
(6.23)
0 0 1
We have
Pj qi = J⊖′ J⊖ Pj qi J⊖T J⊖′T = Pj qi (6.24)
119
6 Frames transformation with associated uncertainties
By convention we note
k
qi ⊕ ⊖j qi = k qi ⊖ j qi (6.26)
So,
k
qj = k qi ⊖ j qi (6.27)
Now, let us start from:
k
qi =k qj ⊕ j qi (6.28)
we can write
k
qi ⊖ j qi =k qj ⊕ j qi ⊖ j qi (6.29)
k
qi ⊖ j qi =k qj (6.30)
120
6 Frames transformation with associated uncertainties
j
qi =j qk ⊕ k qi
= ⊖k qj ⊕ k qi (6.32)
By developing, we obtain:
cos −k θj 0
−sin −k θj
k k
j
qi = (6.33)
sin − θj cos −k θj 0
− qj ⊕ qi
k
0 0 1
cos −k θj 0
−sin −k θj
= k
sin − θj cos −k θj 0
− qj
k
0 0 1
cos −k θj 0
−sin −k θj
+ k
sin − θj cos −k θj 0
qi
k
0 0 1
cos sin 0
k k
θj θj
= k
qi − k qj
cos 0
k k
−sin θj θj
0 0 1
xi − k xj cos θj + yi − k yj sin
k k k k
θj
=
xi − k xj sin θj + k yi − k yj cos
.
k k k
− θj
k
θi − k θj
By convention we will note:
⊖k qj ⊕k qi = ⊖k qj ⊕k qi , (6.34)
which allows for elegant manipulations.
For example, starting from the first equation (6.2)
k
qi =k qj ⊕ j qi , (6.35)
we write
⊖k q j ⊕ k qi = ⊖k q j ⊕k q j ⊕ j qi , (6.36)
we have the same result after simplifications:
⊖k qj ⊕ k qi =j qi . (6.37)
The covariance matrix is then obtained:
! !
Pj qk Pj qk ,k qi J⊖ Pk qj J⊖T Pk qj ,k qi J⊖T
Pj qi ≈ J⊕ J⊕T ≈ J⊕ J⊕T . (6.38)
Pj qk ,k qi Pk qi J⊖ Pk qj ,k qi Pk qi
Smith and al. [23] showed that it is faster to calculate these new covariance
matrices sequentially: estimate Pi qj and i qj before estimating Pk qj ; or Pj qk and j qk
before Pj qi . Indeed, expressing Jacobian matrices from the initially known data
complicates their expressions.
121
6 Frames transformation with associated uncertainties
k
pi =k qj ⊕j pi
k
xj + j xi cos k
θj −j yi sin k
θj
=
k
yj + j xi sin k
θj +j yi cos k
θj
cos k
θj −sin k
θj
=k pj + j pi (6.39)
sin k
θj cos k
θj
Note that only the right term can be a position since a pose is required to make the
frame transformation. By considering the poses as functions for changing frames,
this new operation is equivalent to apply the function defined by this pose to the
position:
k
pi =k qj ⊕j pi , (6.40)
k
pi =k qj j
pi . (6.41)
The operator ⊖ does not exist for positions. A transformation of reference frame
is not possible with a position. It is not possible to determine i pj from j pi only, the
relative orientation j θi is necessary.
The covariance matrix can then be expressed
!
Pk qj Pk qj ,j pi
Pk pi ≈ J⊕ J⊕T , (6.42)
Pj qi ,k pj Pj p i
6.5 Overview
Table (6.3) summarizes the usual operations commonly used in practice.
122
6 Frames transformation with associated uncertainties
∂ (k qj ,j qi )
k
0 1 xi − k xj sin θj cos k θj 0
0 0 1 0 0 1
k
xj + j xi cos k θj −j yi sin k θj
⊕ with position k
pi =k qj ⊕j pi k
yj + j xi sin k θj +j yi cos k θj
∂ (k qj ⊕j pi )
1 0 − k yi − k yj cos k θj −sin k θj
J⊕ ∂ (k qj ,j pi ) k
0 1 xi − k xj sin k θj cos k θ
j j
j j
! j
− xi cos θi − yi sin θi
⊖ i
qj = ⊖j qi j j
xi sin
j
θi j
− yi cos
θi
−j θi
∂ (⊖j qi )
!
−cos j θi −sin j
θi i
yj
J⊖ ∂ j qi
j
sin
θi −cos j
θi
−i xj
0 0 −1
f
ql Rl
Rf
R0
Figure 6.2: Cooperative localization with frame transformations. The following car
is able to localize the leader vehicle in its body frame (f ql ).
2 7
Figure 6.3: Frames and poses representing transformations in frames.
123
6 Frames transformation with associated uncertainties
(a) Propagation of uncertainty from the (b) Inversion of the pose i qj = ⊖j qi repre-
kq kq
pose j to the pose i by integrating sented by the green ellipse and cone.
the uncertainty of the transformation of
pose k qi = k qj ⊕ j qi . The green cloud
represents the uncertainty of the rela-
tive position returned to the true refer-
ence point Rj .
(c) Propagation of uncertainty from the (d) Uncertainty of the relative pose esti-
kq kq mated from the two absolute
pose i to the pose j by integrat- poses using
ing the uncertainty of the transforma- the operation qi = ⊖ qj ⊕ k qi .
j k
tion of pose j qi through the operation
k q = k q ⊕ ⊖j q . The point clouds
j i i
represent the distributions of poses ap-
proximated by normal distributions il-
lustrated by ellipses and cones of uncer-
tainty.
Figure 6.4: The point clouds represent the distributions of the poses approximated by
normal distributions illustrated by ellipses and cones of 95% uncertainty.
The elements associated with the poses k qi , k qj , j qi and i qj are represented
respectively in red, blue, green and purple. The relative poses j qi and i qj
k
are directly represented in the
k
124frames associated with the poses qj and
qi .
6 Frames transformation with associated uncertainties
Figures 6.4a, 6.4b, 6.4c and 6.4d present the two elementary operations k qi =k
qj ⊕ j qi (Fig. 6.4a) and i qj = ⊖j qi (Fig. 6.4b) as well as two combinations of these
two operations k qj = k qi ⊕(⊖j qi ) (Fig. 6.4c) and j qi = ⊖k qj ⊕ k qi (Fig. 6.4d). Each
figure shows the distributions of the input positions with their average poses as well
as their ellipses and uncertainty cones. These distributions are represented by 10,000
positions with standard deviations of 0.316 m along the abscissa and ordinate axis.
The orientation of the distribution at a standard deviation of 16.9°. Each operation
is applied to the input means and their uncertainties to determine the average of
the result of this operation with its uncertainty. The uncertainty in position is
illustrated by an ellipse of uncertainty. However, by applying the operation to a
random sample of input distributions, a banana distribution is obtained due to the
non-linearity of the operation. Thus, the uncertainty ellipse of the result does not
correctly represent the final distribution. We can see that the banana distribution
of the operation k qj = k qi ⊕ (⊖j qi ) is more pronounced than those of the other
operations. This result is due to the fact that the final position k pj depends on
the two input orientations k θi and j θi as can be seen in the equation (6.25). This
operation is therefore more sensitive to non-linearities. These problems of banana
distribution are observable and very significant when the errors of orientation and
inter-distances are significant.
To reduce these non-linearity problems, the unscented transformation [27] with
sigma points often determines a Gaussian that better represents the true final dis-
tribution that is no longer a Gaussian.
125
7 Multi-Sensor Data Fusion
7.1 Introduction
In this chapter, we present methods for merging random vectors in a Gaussian linear
framework (which is a special case of stochastic estimation up to the second order).
An adaptation of these concepts to the non-linear case is immediate via an extended
or an unscented approach.
Then, we will focus on data fusion and introduce consistency checks so valuable
in practice to tune filters or to verify proper operation. Consistency tests are also
useful before doing the multi-sensor fusion, since they can be used to either reject
outliers or do basic data association.
x = x1 + K (x2 − x1 ) (7.2)
P = (I − K) P1 (7.3)
Please note that from now on :
• an observation (x2 , P2 )
126
7 Multi-Sensor Fusion
σ22 σ12
x= x 1 + x2
σ12 + σ22 σ12 + σ22
σ12 σ22
σ2 =
σ12 + σ22
In some books, the formulas that are often presented are as follows.
Consider the equation (7.5) and take its inverse1 :
−1
P −1 = P2 (P1 + P2 )−1 P1 = P1−1 (P1 + P2 ) P2−1 (7.6)
= I + P1−1 P2 P2−1 = P2−1 + P1−1
The inverse of a covariance matrix, is an “information matrix”. So, when merging
two states, we sum their information to get the information of the result.
By multiplying with P −1 on the left, Eq. (7.4) can written as:
P −1 x = P1−1 (P1 + P2 ) P2−1 P2 (P1 + P2 )−1 x1 + P2−1 (P1 + P2 ) P1−1 P1 (P1 + P2 )−1 x2
= P1−1 x1 + P2−1 x2
P −1 x̂ is an information vector. So, the information vector of the result is the sum
of the two information vectors to be fused.
These are the two steps of the fusion process:
127
7 Multi-Sensor Fusion
1. With formula (7.8), one can see directly that the fusion is commutative (by
reversing the role of each estimate in the fusion step, the result remains the
same).
2. In terms of computations, Eq. (7.8) is less efficient than using Eq. (7.4) and
Eq. (7.5) since its requires the inversion of 3 matrices instead of only one
which is (P1 + P2 )−1 .
P −1 = n −1P
P i=1 Pi (7.9)
x = P. n −1
i=1 Pi xi
x2 = Cx1 + β (7.10)
Here, P2 =var(β) = R.
If the measurement noise is uncorrelated with the prediction error, we have:
P −1 = P1−1 + C T P2−1 C
(7.11)
x = x1 + P C T P2−1 (x2 − Cx1 )
128
7 Multi-Sensor Fusion
P = (I − KC)P1
Which is the well-known Kalman expression of the update.
We can write:
−1
I = CP1 C T + P2 CP1 C T + P2
−1 −1
⇐⇒ I − CP1 C T + P2 CP1 C T = CP1 C T + P2 P2
Therefore:
−1
PC T
P2−1 = P1 C T
CP1 C + P2
T
P2 P2−1
−1
= P1 C T CP1 C T + P2
=K
Please note that this Kalman gain expression is different from the ones we have
seen before in this course.
xk+1 = f (xk ) + αk
(
yk = g (xk ) + βk
y1
where yk = ...
ym
129
7 Multi-Sensor Fusion
[Link] Example
Let consider a car equipped with a tachometer, a gyroscope and a GPS receiver.
GPS
Bus CAN
M
k
vk
M k
yk
W xk x
Modeling
ẋ = v · cos(ψ)
ẏ = v · sin(ψ)
ψ̇ = ω
130
7 Multi-Sensor Fusion
Discretization
xk+1 −xk
Equations are non-linear. We make an approximate discretization: ẋk = Te
We get
xk+1 = xk + T [Link] · cos(ψk )
yk+1 = yk + T [Link] · sin(ψk )
ψk+1 = ψk + T e.ωk
State space
Propose a state vector X = [x, y, ψ, v, ω]T
An evolution model can be given by supposing the speeds have slow variation:
The model noises are particularly important here. They allow in particular the
evolution of {vk , ωk }.
An observation model is:
xgps,k = xk
gps,k = yk
y
vtachy,k = vk
ωgyro,k = ωk
xgps,k y1,k
ygps,k y2,k
= = Yk
vtachy,k y3,k
ωgyro,k y4,k
We get:
1 0 0 0 0
0 1 0 0 0
Yk = · Xk
+ βk = C · xk + βk
0 0 0 1 0
0 0 0 0 1
Finally, a nonlinear stochastic state representation is obtained with a non-linear
evolution model and a linear observation one.
Xk+1 = f (Xk ) + αk
(
Yk = C · Xk + βk
Observability study
In an observability study, the noise is neglected.
{x, y, v, ω} are directly observed. So, they are observable.
The only variable not directly observed is the heading ψ.
Let an equation of the model xk+1 = xk + T [Link] · cos(ψk )
Yet, ψk+1 = ψk + T e.ωk ⇒ ψk = ψk+1 − T e.ωk
131
7 Multi-Sensor Fusion
!
xk − xk−1
ψk = arccos + T e.ωk−1
T [Link]−1
So, ψk is a function of other parameters already observed. Therefore, it is observ-
able except if the speed is zero (degeneration).
Observer
We have to make an extended Kalman filter because of the non-linearity of the
evolution model. Therefore, we need to calculate the Jacobian of f for the calculation
of the covariance matrix in the prediction step.
1 0 −T e · vk · sin(ψk ) T e · cos(ψk ) 0
0 1 T e · vk · cos(ψk ) T e · sin(ψk ) 0
h i
= 0 0 1 0 to evaluate at X̂k/k
∂f
∂X
Te
0 0 0 1 0
0 0 0 0 1
We discretize the evolution model in order to verify the Shannon condition and
so that the sampling times are multiples of T e (or rather a good approximation of
multiples of T e).
xk+1 = f (xk ) + αk
y1,j = g1 (x(t0 + j.T e) + β1,j
=
yp,i = gp (x(t0 + i.T e) + βp,i
Remind that the f functions are different in the discrete and continuous state
spaces.
If we assume that the observation noises are independent (no correlation), then
in each period
1. We use available measures to make estimation steps,
2. We provided the observation of the state
3. We calculate the prediction with the model for the next step.
It may be noted that there may be no measure available at a given time. In this
case, the observer operates in "open loop" using only its evolution model.
Conversely, several measures can appear in the same period. Under assumption
of independence of noises, measurements can be processed in separate estimation
steps.
132
7 Multi-Sensor Fusion
1. Unbiased: E [e] = 0
The estimation error e of the estimate is effectively null.
h i
2. Px = E e · eT
The estimated covariance Px is effectively equal to the real covariance of the
error.
h i
In practice, it is observed that the observer is often too optimistic i.e. Px < E e · eT .
It may diverge. It is preferable that it be rather pessimistic. In addition, the
estimated matrix is often used to describe the uncertainty and is compared h to ia
threshold. If we want a conservative observer, rather we seek to have Px > E e · eT .
In practice, there are two ways to study the consistency:
i=1
133
7 Multi-Sensor Fusion
(x − mx )T P −1 (x − mx ) ∼ χ2 (n)
This results from the following property.
If x ∼ Nn (mx , P ) then we can find a matrix B such that x = mx + B · u where
u ∼ Nn (0, I) is centered and reduced. It is shown that B has full rank, and so we
can write u = B −1 . (x − mx ). In addition, we can note that B · B T = P .
(x − mx )T P −1 (x − mx )
−1
= (x − mx )T B · B T (x − mx )
−1 T −1
= (x − mx ) (B ) (B) (x − mx )
T
= uT u = ni=1 u2i
P
[Link] Principle
It is calculated for all samples:
2
Hypotheses of stationarity and ergodicity
134
7 Multi-Sensor Fusion
2. Compute (x̂k − xref,k )T · Pk−1 · (x̂k − xref,k ) for all the samples and look at
the percentage of samples that exceed a calculated threshold (fractile) corre-
sponding to a degree n of a Chi2 law χ2 (n, 1 − α) (α=5% for instance). If
the percentage is not consistent with α then the filter is not consistent: either
pessimistic or components of the vector do not follow a normal distribution.
Let us focus on the 2D position estimated by the filter. We consider now only the
2D position components of the state vector in the working frame.
The normalized horizontal positioning error (HPE) squared e2 is defined by :
!T !
ex ex
e =
2 −1
PHP E (7.13)
ey ey
!
σx2 σxy 2
where PHP E = and σx , σy and σxy are estimated by the filter.
σxy σy2
2
ex = x̂ − xref and ey = ŷ − yref , with (xref , yref ) the ground truth of the vehicle
horizontal position and (x̂, ŷ) the estimated position.
If the model assumptions and the tuning of the filter are correct, then equation
(7.13) follows a χ2 distribution with two degrees of freedom (denoted χ2 (2) in the
following).
In order to study the consistency of the HPE, one usually looks at the percentage
of samples exceeding a determined threshold given by a χ2 (2) distribution.
!T !
ex ex
−1
PHP E > k2 (7.14)
ey ey
where k 2 is a value
! linked to the chosen risk.
ex q
Let ue = / e2x + e2y be the unit vector supporting the HPE (see Figure
ey
7.4).
Equation (7.14) can be rewritten as:
e2x + e2y ueT PHP
−1
E ue > k
2
1
s
q
e2x + e2y >k −1 (7.15)
ueT PHP E ue
135
7 Multi-Sensor Fusion
Let us define σHP E as the standard deviation along the HPE vector:
1
s
σHP E = −1
ueT PHP E ue
Figure 7.4 illustrates the definition of kσHP E .
A common choice in robotics is to choose a consistency risk at 10−2 (1%). Ac-
cording to a χ2 (2) distribution, k 2 = 9.21. In this case, the corresponding bound
of the 2D estimated position is 3.035σHP E , with σHP E being estimated in real-time
by the filter. Therefore, a consistency failure happens when the real error is beyond
this 3.035σHP E bound, which means
q
e2x + e2y > 3.035σHP E
Calculate σHP E is useful for displaying integrity diagrams where the 2D position
error is plotted on the x-axis and 3.035σHP E on the y-axis for a consistency risk of
1%.
364.4
364.3
364.2
364.1
ex
North (m)
364
(x, y)
363.9
kσHPE ey
363.8
363.7
(xref, yref)
363.6
363.5
363.4
−436.8 −436.6 −436.4 −436.2 −436 −435.8 −435.6
East (m)
Figure 7.4: (x̂, ŷ) is the estimated position. (xref , yref ) is the ground truth of the
vehicle horizontal position. Here, the reference is located outside of the
confidence domain.
which has to follow a Chi2 law with m degrees of freedom (m is the size of the
observation vector).
136
7 Multi-Sensor Fusion
The reasoning is the same with except that we evaluate the consistency of the
observations with the model.
Px
x2
mx
x1
Figure 7.5: Even if x1 is closer to mx its Mahalanobis distance is greater than that
of x2 . x2 has therefore a greater probability to follow the distribution
(mx , Px )
Given two points x and y in Rn , the Mahalanobis distance between them with
respect to the distribution with mean mx and covariance matrix Px is
q
D(x, y) = (x − y)T Px−1 (x − y) (7.17)
It is therefore also a measure of dissimilarity between two random vectors of the
same distribution.
137
7 Multi-Sensor Fusion
7.5.2 Rejection
The Mahalanobis distance is often used to determine multivariate outliers.
A classical rejection mechanism is to evaluate the consistency of the predicted
measure ŷk|k−1 with the current one yk . In other words, we have to evaluate the
consistency of the innovation.
Consider the decision variable:
T −1
D2 = ŷk|k−1 − yk · Ck Pk|k −1 CkT + R · ŷk|k−1 − yk (7.18)
where Ck Pk|k −1 CkT is the covariance of the predicted measure ŷk|k−1 .
In practice, the decision stage is simply a thresholding of the distance D. The
threshold can be chosen as a function of a false alarm probability given by the inverse
function of the Chi2 3 .
Let compute the distance D given by Eq. (7.18) and apply the following algorithm:
Tracking example
Let two observations (or detected objects) y1 and y2 with covariances R1 and R2
and one seeks the one that is the most consistent with a prediction ŷ = C x̂ with a
covariance P .
Assuming that the error probability distributions of ei and e are Gaussian, then
the innovation µi = yi − ŷ is too. We can write the likelihood of µi in the form:
1 1 T −1
p(yi |x) = q .e− 2 µi Si µi
(7.19)
(2π)n det(S i)
with
Si = Ri + P
The most likely association is the one that maximizes p(yi |x) since, from a statis-
tical point of view, it is the one that best matches in average.
3
Function "chi2inv" in Matlab
138
7 Multi-Sensor Fusion
Since the first term is a constant, maximizing p(yi |x) is equivalent to minimizing
the distance Υi :
139
8 Kalman Filter with Covariance
Intersection
8.1 Introduction
In many practical cases, noises and/or estimation errors are not uncorrelated. In
this case, if we assume that they are uncorrelated, the data fusion (obtained for
example with a Kalman filter) is not optimal. The estimates are affected by errors
and, even worse, the covariance matrices are often underestimated and the result is
not consistent.
We are going to study in this chapter a covariance intersection technique that can
be combined with Kalman filtering.
P −1 = n −1
P
P i=1 Pi (8.1)
x = P. n −1
i=1 Pi xi
The assumption that the estimation errors are uncorrelated can often not be met,
especially when performing data fusion in a distributed system where cycles can
we be led to re-merge an already integrated estimate in the fusion process. The
estimation errors are then correlated. Doing data fusion with KF updates is not
appropriate and leads to inconsistent estimates in practice.
One solution is to use the method called “Covariance Intersection” (CI) [13] which
calculates a covariance that remains consistent.
The estimate and its covariance are obtained by the CI update:
Since 0 < ω < 1, the resulting information matrix is obtained by a convex combi-
nation (i.e. a linear combination where all coefficients are non-negative and sum to
1).
In general, ω is computed to minimize the trace or the determinant of the resulting
covariance matrix P .
140
8 KF with Covariance Intersection
5
input 1
4 input 2
optimal CI
3 KF
CI with non optimal
2
-1
-2
-3
-4
-5
-4 -3 -2 -1 0 1 2 3 4
Figure 8.1: Illustration of the CI fusion of the blue estimate with the green one.
The two estimates are equal for illustration. Only, their covariances are
different. Results are displayed for different ω (in black) and ω = 0.50
for optimal value (in red). Kalman update in cyan.
2.5
input 1
2 input 2
optimal CI
1.5 KF
CI with non optimal
1
0.5
-0.5
-1
-1.5
-2
-2.5
-4 -3 -2 -1 0 1 2 3 4
Figure 8.2: Illustration of the CI fusion of the blue estimate with the green one.
Results are displayed for different ω (in black) and ω = 0.50 for optimal
value (in red) which is equal to the green one. Kalman update in cyan.
141
8 KF with Covariance Intersection
1. If the two uncertainty ellipsoids have the same volume (i.e. det(P1 ) = det(P2 )1 ),
then ω1 = ω2 ,
det(P2 )
ω1 = (8.11)
det(P1 ) + det(P2 )
det(P1 )
ω2 = (8.12)
det(P1 ) + det(P2 )
We can check that the weights respect the constraints 0 < ω1 < 1 and 0 < ω2 < 1.
Since P1 and P2 are covariance matrices (positive-definite), we have det(P1 ) > 0
and det(P2 ) > 0. Therefore, 0 < ω1 and 0 < ω2 .
Since det(P1 ) + det(P2 ) > det(P2 ) :
det(P2 )
ω1 = <1
det(P1 ) + det(P2 )
.
1
In his paper, Wolfgang Niehsen used the “trace” instead of the “determinant”
142
8 KF with Covariance Intersection
5
input 1
4 input 2
optimal CI
3 Fast CI
-1
-2
-3
-4
-5
-4 -3 -2 -1 0 1 2 3 4
Figure 8.3: CI and fast CI applied to the blue and green estimates. The results are
very close.
x2 = Cx1 + β
Here, P2 =var(β)(= R).
Please note that we now place ourselves in a very general case that varies between
few observations or many redundant observations.
P −1 = P1−1 + C T P2−1 C
If the measurement noise has an unknown correlation with the prediction, we can
compute the covariance matrix P of the update with the optimal ω:
P −1 − (1 − ω) C T P2−1 C = ωP1−1
⇐⇒ P P −1 − (1 − ω) P C T P2−1 C = P ωP1−1
⇐⇒ P P −1 − (1 − ω) P C T P2−1 C = ωP P1−1
143
8 KF with Covariance Intersection
⇐⇒ x = ωP P1−1 x1 + (1 − ω) P C T P2−1 x2
Using Eq. 8.14:
⇐⇒ x = 1 − (1 − ω) P C T P2−1 C x1 + (1 − ω) P C T P2−1 x2
Kω = (1 − ω) P C T P2−1
In short, the update phase can be written as, once ω has been computed for
instance by minimization of the first equation:
= ωP1−1 + (1 − ω) C T P2−1 C
−1
P
Kω = (1 − ω) P C T P2−1 (8.15)
x = x1 + Kω (x2 − Cx1 )
−1 −1
P = ωP1−1 + (1 − ω) C T
P2−1 C = I− 1
P CT
ω 1
1
ω
CP1 C T + 1
P
1−ω 2
C 1
P
ω 1
(8.16)
From now on, let’s assume that ω ̸= 1 and ω ̸= 0.
We know that
Kω = (1 − ω) P C T P2−1
−1
⇐⇒ Kω = (1 − ω) ωP1−1 + (1 − ω) C T P2−1 C C T P2−1
Take the transpose of P :
)T
1 1 1 1
(" −1 #
PT = I − P1 C T CP1 C T + P2 C P1
ω ω 1−ω ω
144
8 KF with Covariance Intersection
1 1 1 1
" −1 #
⇐⇒ P = P = P1 I − C T
T
CP1 C T + P2 C P1
ω ω 1−ω ω
Since covariance matrices are symmetric.
The gain becomes :
1 1 1 1
" −1 #
Kω = (1 − ω) P1 I − C T CP1 C T + P2 C P1 C T P2−1
ω ω 1−ω ω
1 1 1 1
" −1 #
⇐⇒ Kω = P1 C T I − CP1 C T + P2 C P1 C T (1 − ω) P2−1
ω ω 1−ω ω
−1
By changing I into ω1 CP1 C T + 1−ω
1
P2 . 1
ω
CP1 C T + 1
P
1−ω 2
, we get after sim-
plification a new expression of the gain:
1 1 1 −1
K ω = P1 C T CP1 C T + P2 (8.17)
ω ω 1−ω
The update of the covariance matrix can be directly computed once the gain is
known.
Eq. 8.16 can be rewritten:
−1
P = I− 1
P CT
ω 1
1
ω
CP1 C T + 1
P
1−ω 2
C 1
P
ω 1
P = [I − Kω C] ω1 P1 (8.18)
In short, an update step can be written, once ω has been computed by minimiza-
tion:
−1
K ω
= ω1 P1 C T C ω1 P1 C T + 1
P
1−ω 2
The Joseph’s form can be computed for a more stable implementation [9]:
1 1
P = (I − Kω C) P1 (I − Kω C)T + Kω P2 KωT
ω 1−ω
We find the same expression as the classic Kalman filter but with and .
1
P1 =⇒ P1
ω
1
P2 =⇒ P2
1−ω
145
8 KF with Covariance Intersection
1 1
P = (I − Kω C) P1 (I − Kω C)T + Kω P2 KωT (8.20)
ω 1−ω
1 1 1
= (I − Kω C) P1 − (I − Kω C) P1 C T KωT + Kω P2 KωT
ω ω 1−ω
1 1 1 1
= (I − Kω C) P1 − P1 C Kω + Kω C P1 C +
T T T
P2 KωT
ω ω ω 1−ω
Let denote: PY,ω = C 1
P
ω 1
CT + 1
P
1−ω 2
1 1
P = (I − Kω C) P1 − P1 C T KωT + Kω PY,ω KωT
ω ω
1 1 1
= (I − Kω C) P1 − P1 H T KωT + P1 H T −1
PY,ω
T
P
Y,ω Kω
ω ω ω
1
= (I − Kω C) P1
ω
146
8 KF with Covariance Intersection
e = ei + ed (8.21)
P = Pi + Pd (8.22)
6
Pi
Pd
4 P=Pi+Pd
-2
-4
-6
-5 0 5
The distinction of a dependent and independent part is also done for the model
and observation covariance matrices Q and R.
R = P2,d + P2,i
Suppose we know the covariance matrices P1,d and P1,i of the prediction errors.
The update is given by:
147
8 KF with Covariance Intersection
x = x1 + K(x2 − Cx1 ) %
new estimate with ω ̸= 1 and ω =
̸ 0
P = [I − KC] P1 %
new cov of the estimate
Pi = (I − KC) P1,i (I − KC)T + KP2,i K %
cov of the independ error
T
Pd = P − Pi %
cov of the depend error
(8.23)
The proof is given in [16] but intuitively by replacing P1,d =⇒ ω P1,d and P2,d =⇒
1
1
P , we get the result.
1−ω 2,d
ω is computed with
P = [I − KC] P1 (8.24)
−1
P = I − P1 C T CP1 C T + P2 C P1 (8.25)
1 1 1 1
" −1 #
P (ω) = I − P1,d + P1,i C T C P1,d + P1,i C T + P2,d + P2,i C P1,d + P1,i
ω ω 1−ω ω
(8.26)
P1,d = APd AT + Qd
P1,i = APi AT + Qi
148
Bibliography
[1] Martin A., Fischler, and Robert C. Bolles. Random sample consensus: A
paradigm for model fitting with applications to image analysis and automated
cartography. In Proceedings of the Comm. ACM., pages 381–395, June 1981.
[4] Zhe Chen. Bayesian filtering: From kalman filters to particle filters, and beyond.
Technical report, McMaster University, 2003.
[5] Christophe Coué, Cédric Pradalier, Christian Laugier, Thierry Fraichard, and
Pierre Bessiere. Bayesian Occupancy Filtering for Multitarget Tracking: an
Automotive Application. International Journal of Robotics Research, 25(1):19–
30, January 2006.
[6] Hugh Durrant-Whyte. Multi Sensor Data Fusion. The University of Sydney
NSW 2006. 2001.
[9] Elwan Héry, Philippe Xu, and Philippe Bonnifait. Consistent decentralized
cooperative localization for autonomous vehicles using LiDAR, GNSS, and HD
maps. Journal of Field Robotics, 38(4):552–571, 2021.
[10] Huber Peter J. Robust Statistics (2nd ed). Handbook of Multisensor Data
Fusion: Theory and Practice. John Wiley and Sons Inc, 2009.
[13] S. Julier and J. K. Uhlmann. General decentralized data fusion with covariance
intersection, Chapter 14. Handbook of Multisensor Data Fusion: Theory and
Practice. CRC Press, Taylor Francis, Boca Raton FL USA, 2001.
149
Bibliography
[14] Simon J. Julier and Jeffrey K. Uhlmann. A new extension of the kalman filter
to nonlinear systems. In In Int. Symp. Aerospace/Defense Sensing, Simul. and
Controls, pages 182–193, 1997.
[15] Hao Li. Cooperative Perception : Application in the Context of Outdoor Intel-
ligent Vehicle Systems. PhD thesis, Ecole Nationale Supérieure des Mines de
Paris, 2012.
[16] Hao Li, Fawzi Nashashibi, and Ming Yang. Split covariance intersection fil-
ter: Theory and its application to vehicle localization. IEEE Transactions on
Intelligent Transportation Systems, 14(4):1860–1871, 2013.
[17] Martin E. Liggins and Kuo-Chu Chang. Introduction to Particle Filtering: the
next stage in tracking, chap 9. Handbook of Multisensor Data Fusion: Theory
and Practice. CRC Press, Taylor Francis, Boca Raton FL USA, 2001.
[19] Peter S. Maybeck. Stochastic models, estimation, and control, volume 141 of
Mathematics in Science and Engineering. 1979.
[21] B. Ristic, S. Arulampalam, and N. Gordon. Beyond the Kalman Filter. Particle
Filters for Tracking Applications. Artech House. 2004.
[22] Nando de Freitas Rudolph van der Merwe, Arnaud Doucet and Eric Wan. The
unscented particle filter, cambridge university department of engineering,. In
Technical report CUED/F-INFENG/TR 380, 2000.
[24] Sebastian Thrun, Wolfram Burgard, and Dieter Fox. Probabilistic Robotics.
The MIT Press, 2005.
150