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
scan = lidarScan(ranges,angles)
scan = lidarScan(cart)
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
Range readings from lidar, specified as a vector. This vector is the same
Angles, and the vector elements are measured
Angles— Angle of readings from lidar
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
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')
Create a reference lidar scan using
lidarScan. Specify ranges and angles as vectors.
refRanges = 5*ones(1,300); refAngles = linspace(-pi/2,pi/2,300); refScan = lidarScan(refRanges,refAngles);
transformScan function, generate a second lidar scan at an
x,y offset of
currScan = transformScan(refScan,[0.5 0.2 0]);
Match the reference scan and the second scan to estimate the pose difference between them.
pose = matchScans(currScan,refScan);
transformScan function to align the scans by transforming the second scan into the frame of the first scan using the relative pose difference. Plot both the original scans and the aligned scans.
currScan2 = transformScan(currScan,pose); subplot(2,1,1); hold on plot(currScan) plot(refScan) title('Original Scans') hold off subplot(2,1,2); hold on plot(currScan2) plot(refScan) title('Aligned Scans') xlim([0 5]) hold off
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.