setParticles(mcl,particles)
sets the particle poses and sets the weights of each particle to 1/n,
where n is the number of particles in the mcl object
at the current timestep.
setParticles(mcl,particles,weights)
specifies the poses and weights to set to each of the specified particles.
Call the reset method to initialize the mcl. The monteCarloLocalization object must be initialized using the step or reset methods first before you can use the setParticles function.
reset(mcl);
Load particle states and weights to use to set the particles in the monteCarloLocalization object.
Create lidar scan data. Create 300 range with measured values of 10 meters. Set the middle values to 2 meters to represent an obstacle. Create corresponding angles for the range readings and set the angle range to be -pi/2 to pi/2 radians.
Estimation particles, specified as an n-by-3 matrix, where each
row corresponds to the position and orientation of a single particle [x y
theta]. n is the total number of particles to set and
must be equal to the number of particles in mcl. Use the output
particle poses and weights from getParticles to determine the number of particles at the current timestep
and set particle poses and weights.
weights — Weights of particles n-element column vector
Weights of particles, returned as a n-element column vector. Each
row corresponds to the weight of the particle in the matching row of
particles. These weights are used in the final estimate of the
pose of the vehicle. n is the total number of weights to set and must
be equal to the number of particles in mcl. Use the output particle
poses and weights from getParticles to determine the number of
particles at the current timestep and set particle poses and weights.
Extended Capabilities
C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.