Professional Documents
Culture Documents
• Introduction
• Sensors
• Devices to get information from the real world
• Motion Model
Departamento de Ingeniería
de Sistemas y Automática
• If I would have:
• A map of the environment
• A number of sensor measurements
• I could:
• Estimate my pose
Departamento de Ingeniería
de Sistemas y Automática
• In a variety of situations:
• Position tracking.I approximately know where I am.
• Global localization. No idea where I am.
• Kidnapped robot problem. I am completely wrong
about the position I think I am.
“Using sensory information to locate the robot in its environment is the most
fundamental problem to providing a mobile robot with autonomous
capabilities.” [Cox ’91]
Localization Problem
• Metric/Geometric maps
Based on geometric data coming from the sensors, mainly stored in the
Departamento de Ingeniería
• Metric/Geometric maps
The simplest metric map is a set of landmarks located at known
positions:
Departamento de Ingeniería
de Sistemas y Automática
𝑙1 = {𝑥1 , 𝑦1 } 𝑙2 = {𝑥2 , 𝑦2 }
𝑑1 𝑑2
Locating the set of
landmarks helps in
𝑑3 estimating the robot
pose.
𝑙3 = {𝑥3 , 𝑦3 }
Localization Problem
• Topological maps
Based on graphs where nodes represents locations and arcs the
connectivity between them.
Departamento de Ingeniería
de Sistemas y Automática
• Hybrid maps
Combination of geometric and topological maps. Commonly used in
robotics.
Localization Problem
• Hybrid maps
Departamento de Ingeniería
de Sistemas y Automática
Problem:
Given a vector of measurements 𝑧 related to the robot pose 𝑥 by
the linear observation model:
𝑧 = 𝐻𝑥
We want to find the “best” pose 𝑥ො
Departamento de Ingeniería
Direct solution:
de Sistemas y Automática
𝑥 = 𝐻 −1 𝑧 Only if 𝐻 is invertible… 𝐻
is square with det(𝐻) ≠ 0
General solution:
find the 𝑥 closest to the ideal, i.e. minimizing the error 𝑒 = 𝐻𝑥 − 𝑧
Solution:
𝑥ො = arg min[ 𝐻𝑥 − 𝑧 𝑇 (𝐻𝑥 − 𝑧)]
𝑥
2
𝐻𝑥 − 𝑧 = 𝑥 𝑇 𝐻𝑇 𝐻𝑥 − 𝑥 𝑇 𝐻𝑇 𝑧 − 𝑧𝐻𝑥 + 𝑧 𝑇 𝑧
Departamento de Ingeniería
de Sistemas y Automática
2
𝛿 𝐻𝑥 − 𝑧
= 2𝐻𝑇 𝐻𝑥 − 2𝐻𝑇 𝑧 = 0
𝛿𝑥
𝑥 = 𝐻𝑇 𝐻 −1 𝐻 𝑇 𝑧
Pseudo-inverse of H
Localization Problem
Least Squares Positioning
Example Robot moving in 1D:
Robot moves on a line with odometric errors. It can measure the
distance to a number of landmarks (3 in this case).
Departamento de Ingeniería
de Sistemas y Automática
landmarks
Red: odometry
Green: estimation
Blue: ground truth
Localization Problem
Least Squares Positioning
Example Robot moving in 1D:
clear all, close all
nLandmarks = 3;
Map(1)=10;Map(2)=20;Map(3)=30;
% Initialization
sigma_sensor = 0.05^2; %variance of the range measurement noise per meter
z = zeros(nLandmarks,1); %All the observations equals zero
z_aux = zeros(nLandmarks,1); %All the observations equals zero
Departamento de Ingeniería
de Sistemas y Automática
% Robot parameters
SigmaX = 0.05; %1D -> The robot only moves along X axis
inc_x=1; %The robot always move 10 cm. at each step, but affected by noise
xTrue = 0; %True unkown position, includes motion errors
xEst = 0; %Position estimated by the LSE method
xOdom = 0; % Position given by odometry where the robot thinks he is located
after applying motion
% commands without noise.
%initial graphics
figure(1); hold on; grid off;% axis equal;
plot(Map(1,:),0,'sm','LineWidth',2);hold on;
loop=1;
num_loops=25;
Localization Problem
Least Squares Positioning
Example Robot moving in 1D:
while loop<num_loops
%%%% Moving the robot a fixed amount
u=inc_x; % simple motion command, just for unifying nomenclature
noise=sqrt(SigmaX)*randn(1,1);
unoise=u+noise; % Here the composition of poses is just a sum
xTrue=xTrue+unoise; %Idem for this composition; xOdom=tcomp(xOdom,unoise);
xOdom=xOdom+u; %Without noise this is the
Departamento de Ingeniería
for kk = 1: nLandmarks
Delta = Map(1,kk)-xTrue;
z(kk) = Delta + (sqrt(sigma_sensor)*randn(1,1)); % Noisy Observation
z_aux(kk)=Map(1,kk)-z(kk); %%% z_aux = l_i - z_i ; z_aux=H*x_true
end
plot(xOdom,0,'r.'); plot(xTrue,0,'bo');
%%% Linear model, solution is closed-based (observation affected by noise, but
such a noise is not considered in the equation. This will be done in the
weighted LSE).
xEst=inv(H'*H)*H'*z_aux
plot(xEst,0,'g.')
pause
loop=loop+1;
end
Localization Problem
Least Squares Positioning
𝑧 = 𝐻𝑥 + 𝑤, 𝑤 = [𝐻𝑥 − 𝑧]~𝑁(0, 𝜎 2 )
Departamento de Ingeniería
de Sistemas y Automática
𝑧~𝑁(𝐻𝑥, 𝜎 2 )
𝑧~𝑁(𝐻𝑥, 𝑅)
1
𝑝 𝑧 𝑥 = 𝐾 ∙ exp − [ 𝐻𝑥 − 𝑧 𝑇 𝑅−1 (𝐻𝑥 − 𝑧)]
2
Departamento de Ingeniería
de Sistemas y Automática
2
𝑥ො = arg min ℎ 𝑥 − 𝑧
𝑥
2
We seek a vector 𝛿, such that x1 = x0 + 𝛿 and minimize ℎ 𝑥1 − 𝑧
Localization Problem
Least Squares Positioning
ℎ 𝑥1 = ℎ 𝑥0 + 𝛿 = ℎ 𝑥0 + 𝛻Hx 0 𝛿
Jacobian of the sensor model
n: d.o.f. of the pose
Departamento de Ingeniería
m: # observations
de Sistemas y Automática
2 2 2
ℎ 𝑥1 − 𝑧 = ℎ 𝑥0 + 𝛻𝐻𝑥 0 𝛿 − 𝑧 = 𝛻𝐻𝑥 0 𝛿 − (𝑧 − ℎ 𝑥0 )
A 𝑥 B
−1
𝛿= 𝛻𝐻𝑥 0 𝛻𝐻𝑥 0 𝛻𝐻𝑥 𝑇0 [𝑧
𝑇
− ℎ 𝑥0 ]
Localization Problem
Least Squares Positioning
−1
𝛿 = 𝛻𝐻𝑥 𝑇0 𝛻𝐻𝑥 0 𝛻𝐻𝑥 𝑇0 [𝑧 − ℎ 𝑥0 ]
3. Set 𝑥ො = 𝑥ො + 𝛿
2
4. If ℎ 𝑥ො − 𝑧 > 𝜖 then goto 1
−1
For weighted sensor measurements: 𝛿 = 𝛻𝐻𝑥 𝑇 R−1 𝛻𝐻𝑥 𝛻𝐻𝑥 𝑇0 𝑅−1 [𝑧 − ℎ 𝑥0 ]
0 0
Localization Problem
Least Squares Positioning
1
Observation model: 𝑧𝑖 = ℎ𝑖 𝑝 = 𝑝𝑖 − 𝑝 = Δ𝑥𝑖2 + Δ𝑦𝑖2 2
𝑧1 𝑑1 𝑝1 − 𝑝 𝑥1 − 𝑥 2 + 𝑦1 − 𝑦 2 1/2
𝑧 = ℎ 𝑝 = 𝑧2 = 𝑑2 = 𝑝2 − 𝑝 = 𝑥2 − 𝑥 2 + 𝑦2 − 𝑦 2 1/2
𝑧3 𝑑3 𝑝3 − 𝑝 𝑥3 − 𝑥 2 + 𝑦3 − 𝑦 2 1/2
Localization Problem
Least Squares Positioning
𝑥1 − 𝑥 2 + 𝑦1 − 𝑦 2 1/2
ℎ 𝑝 = 𝑥2 − 𝑥 2 + 𝑦2 − 𝑦 2 1/2
𝑥3 − 𝑥 2 + 𝑦3 − 𝑦 2 1/2
Departamento de Ingeniería
𝜕 2 2 1/2
1
𝑥 −𝑥 + 𝑦𝑖 − 𝑦 =− (𝑥 − 𝑥)
𝜕𝑥 𝑖 𝑑𝑖 𝑖
𝜕 2 2 1/2
1
𝑥 −𝑥 + 𝑦𝑖 − 𝑦 = − (𝑦𝑖 − 𝑦)
𝜕𝑦 𝑖 𝑑𝑖
𝜕 2 2 1/2
𝑥 −𝑥 + 𝑦𝑖 − 𝑦 =0
𝜕𝜃 𝑖
Localization Problem
Least Squares Positioning
𝑑3 𝑑3
de Sistemas y Automática
%initial graphics
figure(1); hold on; grid off; axis equal;
plot(Map(1,:),Map(2,:),'sm','LineWidth',2);hold on;
loop=0;
num_loops=100;
while loop<num_loops
circles.
Errors in localization. Top) difference between the ground truth position and
the one estimated by LSE. Bottom) Difference between the odometry
position and the ground truth,
Localization Problem
Particle Filter
Problem:
Given a set of landmarks and a set of probable poses of the robot
(particles). We want to estimate the “best” pose 𝑥ො
The idea is to simulate the sensor reading from each particle and compare it
with the actual measurement (affected by noise).
Particles with a coherent observation will have a high weight. Those with a
large discrepancy, will have a low weight.
Localization Problem
Particle Filter
Weight Computation:
2
𝑧2
Motion model + 𝑧5
5 5 𝑙1
4 perturbation
2 4 𝑧4 𝑧
1
3
𝑧1 𝑧3
Starting sample set 1
3
Ground-truth pose
Departamento de Ingeniería
de Sistemas y Automática
That is, particles with a 𝑧𝑖 closer to 𝑧 will better represent the actual pose of
the robot. So we define the “innovation”, i.e., the importance of each
particle as:
𝐼𝑛𝑛𝑜𝑣𝑖 = 𝑧 − 𝑧𝑖
𝑇
𝑊 𝑖 = exp −0.5 ∗ 𝑧 − 𝑧𝑖 ∗ Σ𝑠−1 ∗ 𝑧 − 𝑧𝑖 +𝜖
Departamento de Ingeniería
de Sistemas y Automática
Motion model +
5 perturbation 5
2 4 4
1
3
Particles #4 and #1 have the highest weight, while #3 and #2 have a low
weight.
Now we give a new motion step but selecting randomly from the set of
particles according to their weight. Those with a high weight have higher
probability to survive.
Localization Problem
Particle Filter
Update (reselection):
2
2
5
Motion model +
Motion model + 4
5 5 perturbation
4 perturbation 4
2 4
1
3
1
Starting sample set 1
3
Ground-truth pose
Departamento de Ingeniería
de Sistemas y Automática
The process continues by computing the weights again for the new set of
particles. In the long term particles that better represent the robot pose will
survive, while the rest will “die”.
The robot pose estimation can be computed as the average of all the particles or
taking the one with the highest weight
Localization Problem
Particle Filter
Update (reselection):
How can I implement the randomly selection of particles according to their
weights?
%%% Let samples be a vector of 3xn_samples [x,y,phi]
%%% Let W be a vector 1xn_samples of the weights of each particle
# particles
Localization Problem
Particle Filter
Update (reselection):
%%%Interpolate the values randomly selected: options nearest and
extrap are needed to avoid values out of range. iNext are the indexes
of the chosen particles
iNext=interp1(CDF,1:n_samples,iSelect,'nearest','extrap');
[0.8,0.85]
Particle #21 selected
[0.25,0.26]
Particle #5 selected
# particles
Localization Problem
Conclusions