Create object for storing 2-D lidar scan
lidarScan object contains data for a single 2-D lidar
(light detection and ranging) scan. The lidar scan is a laser scan for a 2-D plane with
Ranges) measured from the sensor to obstacles in the
environment at specific angles (
Angles). Use this laser scan object
as an input to other robotics algorithms such as
matchScans (Navigation Toolbox),
controllerVFH (Navigation Toolbox), or
monteCarloLocalization (Navigation Toolbox).
scan = lidarScan(
lidarScan object from the
represent the data collected from a lidar sensor. The
angles inputs are
vectors of the same length and are set directly to the
scan = lidarScan(
lidarScan object using the input Cartesian
coordinates as an n-by-2 matrix. The
Cartesian property is set directly from this
Ranges— Range readings from lidar in meters
Range readings from lidar, specified as a vector in meters. This vector
is the same length as
Angles, and the vector elements
are measured in meters.
Angles— Angle of readings from lidar in radians
Angle of range readings from lidar, specified as a vector. This vector is
the same length as
Ranges, and the vector elements are
measured in radians. Angles are measured counter-clockwise around the
Cartesian— Cartesian coordinates of lidar readings in meters
Cartesian coordinates of lidar readings, returned as an
y] matrix. In the lidar coordinate frame, positive
x is forward and positive y is to
Count— Number of lidar readings
Number of lidar readings, returned as a scalar. This scalar is also equal
to the length of the
Angles vectors or the number of rows in
Specify lidar data as vectors of ranges and angles. These values include readings outside of the sensors range.
x = linspace(-2,2); ranges = abs((1.5).*x.^2 + 5); ranges(45:55) = 3.5; angles = linspace(-pi/2,pi/2,numel(ranges));
Create a lidar scan by specifying the ranges and angles. Plot all points of the lidar scan.
scan = lidarScan(ranges,angles); plot(scan)
Remove invalid points based on a specified minimum and maximum range.
minRange = 0.1; maxRange = 7; scan2 = removeInvalidData(scan,'RangeLimits',[minRange maxRange]); hold on plot(scan2) legend('All Points','Valid Points')
lidarScan object. Specify the ranges and angles as vectors.
refRanges = 5*ones(1,300); refAngles = linspace(-pi/2,pi/2,300); refScan = lidarScan(refRanges,refAngles);
Translate the laser scan by an
[x y] offset of
transformedScan = transformScan(refScan,[0.5 0.2 0]);
Rotate the laser scan by 20 degrees.
rotateScan = transformScan(refScan,[0,0,deg2rad(20)]);
Usage notes and limitations:
Lidar scans require a limited size in code generation. The lidar scans are limited to 4000 points (range and angles) as a maximum.