···277277 % % A lower score means it is less likely to be selected for the next generation...
278278 % % The weight is never zero.
279279 % end
280280-281281-280280+282281 weights = ones(length(x),1);
283282284283 for i = 1 : length(x)
285284 z_actual = z;
286285 z_pred = s.h(x(i,:)');
287286 z_diff = z_actual - z_pred;
288288- weights(i) = exp(-0.5 * z_diff ^ 2 * L);
287287+ weights(i) = exp(-0.5 * z_diff' * L * z_diff) + weights(i);
288288+ % Equation from:
289289+ % Robotics, Vision & Control, Chap 6,
290290+ % Peter Corke,
291291+ % Springer 2011
289292 end
290293 end
291294
···11% demo08_squareWorldMCL
22% Demo generic Monte Carlo Localization
33+path(path,'threedee')
3444-path(path,'threedee')
55+log = 'log-boxworld.txt'
5667%% Create a map
78A = [
···1920%% and a robot with noisy odometry
2021V=diag([0.01, 0.1*pi/180].^2)
2122veh=Differential(V, 'x0', [-20, -3, 0])
2222-veh.add_driver(DeterministicPath('log-1423005664.txt'));
2323+veh.add_driver(DeterministicPath(log));
23242425%% and then a sensor with noisy readings
2526W=0.05^2;
2626-sensor = RangeSensor(veh,map, W,'log-1423005664.txt')
2727+sensor = RangeSensor(veh,map, W,log)
27282829%% define two covariances for random noise Q and L (hmmm!)
2930% For Q, use the uncertainly estimates from A2!
3030-Q = diag([0.01,0.01,0.1*pi/180].^2);
3131-L = diag(0.1);
3131+Q = 25 .* diag([0.01,0.01,0.1*pi/180].^2);
3232+L = 25 .* diag(0.1);
32333334%% Finally, construct ParticleFilter
3435pf = GenericParticleFilter(veh, sensor, Q, L, 200);
+6-4
Assignment_3/code/matlab/script02_SensorModel.m
···22% Demo generic Monte Carlo Localization
33path(path,'threedee')
4455+log = 'log-boxworld.txt'
66+57%% Create a map
68A = [
79 0, 0, 15.5, 11.5
···1820%% and a robot with noisy odometry
1921V=diag([0.01, 0.1*pi/180].^2)
2022veh=Differential(V, 'x0', [-20, -3, 0])
2121-veh.add_driver(DeterministicPath('log-1423005664.txt'));
2323+veh.add_driver(DeterministicPath(log));
22242325%% and then a sensor with noisy readings
2426W=0.05^2;
2525-sensor = RangeSensor(veh,map, W,'log-1423005664.txt')
2727+sensor = RangeSensor(veh,map, W, log)
26282729%% define two covariances for random noise Q and L (hmmm!)
2830% For Q, use the uncertainly estimates from A2!
2929-Q = diag([0.01,0.01,0.1*pi/180].^2);
3030-L = diag(0.1);
3131+Q = 25 .* diag([0.01,0.01,0.1*pi/180].^2);
3232+L = 25 .* diag(0.1);
31333234%% Finally, construct ParticleFilter
3335pf = GenericParticleFilter(veh, sensor, Q, L, 200);