Main Content


Create likelihood field range sensor model

Since R2019b


The likelihoodFieldSensor object creates a likelihood field sensor model object for range sensors. This object contains specific sensor model parameters. You can use this object to specify the model parameters in a monteCarloLocalization object.




lf = likelihoodFieldSensorModel creates a likelihood field sensor model object for range sensors.


expand all

Occupancy grid representing the map, specified as a binaryOccupancyMap object. This object represents the environment of the vehicle as a grid with binary values indicating obstacles as true (1) and free locations as false (0).

Pose of the range sensor relative to the coordinate frame of the vehicle, specified as a three-element vector, [x y theta].

Minimum and maximum range of sensor, specified as a two-element vector in meters.

Number of beams used for likelihood computation, specified as a scalar. The computation efficiency can be improved by specifying a smaller number of beams than the actual number available from the sensor.

Standard deviation for measurement noise, specified as a scalar.

Weight for probability of random measurement, specified as a scalar. This scalar is the probability that the measurement is not accurate due to random interference.

Weight for probability of expected measurement, specified as a scalar. The weight is the probability of getting a correct range measurement within the noise limits specified in MeasurementNoise property.

Maximum distance to find nearest obstacles, specified as a scalar in meters.


collapse all

Create a monteCarloLocalization object. Set the UseLidarScan property to true.

mcl = monteCarloLocalization;
mcl.UseLidarScan = true;

Create a likelihoodFieldSensorModel object for a range sensor. Assign the sensor model with an occupancy grid map to the monteCarloLocalization object.

sm = likelihoodFieldSensorModel;
p = zeros(200,200);
sm.Map = occupancyMap(p,20);
mcl.SensorModel = sm;

Create a sample laser scan data.

ranges = 10*ones(1,300);
ranges(1,130:170) = 1.0;
angles = linspace(-pi/2,pi/2,300);
odometryPose = [0 0 0];

Create a lidarScan object by specifying the ranges and angles.

scan = lidarScan(ranges,angles);

Estimate vehicle pose and covariance.

[isUpdated,estimatedPose,covariance] = mcl(odometryPose,scan)
isUpdated = logical

estimatedPose = 1×3

    0.0350   -0.0126    0.0280

covariance = 3×3

    0.9946   -0.0012         0
   -0.0012    0.9677         0
         0         0    0.9548


If you change your sensor model after using it with the monteCarloLocalization object, call the release function on that object beforehand. For example:

mcl = monteCarloLocalization; 
[isUpdated,pose,covariance] = mcl(ranges,angles); 
mcl.SensorModel.NumBeams = 120;

Version History

Introduced in R2019b