www.gusucode.com > robotics 案例源码程序 matlab代码 > robotics/GetParticlesFromMonteCarloLocalizationAlgorithmExample.m

    %% Get Particles from Monte Carlo Localization Algorithm
% Get particles from the particle filter
% used in the Monte Carlo Localization object.

%%
% Create a map and a Monte Carlo localization object.
map = robotics.BinaryOccupancyGrid(10,10,20);
mcl = robotics.MonteCarloLocalization(map);
%%
% Create robot data for the range sensor and pose.
ranges = 10*ones(1,300);
ranges(1,130:170) = 1.0;
angles = linspace(-pi/2,pi/2,300);
odometryPose = [0 0 0];
%%
% Initialize particles using |step|.
[isUpdated,estimatedPose,covariance] = step(mcl,odometryPose,ranges,angles);

%%
% Get particles from the updated object.
[particles,weights] = getParticles(mcl);