show(slamObj) plots all the scans
added to the input lidarSLAM object overlaid with the lidar poses in its underlying
pose graph.
show(slamObj,Name,Value) specifies
options using Name,Value pair arguments. For example,
"Poses","off" turns off display of the underlying pose
graph in slamObj.
axes = show(___) returns
the axes handle that the lidar SLAM data is plotted to using any of the previous
syntaxes.
Use a lidarSLAM object to iteratively add and compare lidar scans and build an optimized pose graph of the robot trajectory. To get an occupancy map from the associated poses and scans, use the buildMap function.
Load Data and Set Up SLAM Algorithm
Load a cell array of lidarScan objects. The lidar scans were collected in a parking garage on a Husky® robot from ClearPath Robotics®. Typically, lidar scans are taken at a high frequency and each scan is not needed for SLAM. Therefore, down sample the scans by selecting only every 40th scan.
To set up the SLAM algorithm, specify the lidar range, map resolution, loop closure threshold, and search radius. Tune these parameters for your specific robot and environment. Create the lidarSLAM object with these parameters.
Using a for loop, add scans to the SLAM object. The object uses scan matching to compare each added scan to previously added ones. To improve the map, the object optimizes the pose graph whenever it detects a loop closure. Every 10 scans, display the stored poses and scans.
for i = 1:numel(scans)
addScan(slamObj,scans{i});
if rem(i,10) == 0
show(slamObj);
endend
View Occupancy Map
After adding all the scans to the SLAM object, build an occupancyMap map by calling buildMap with the scans and poses. Use the same map resolution and max range you used with the SLAM object.
Lidar SLAM object, specified as a lidarSLAM object. The object contains the SLAM algorithm
parameters, sensor data, and underlying pose graph used to build the
map.
Name-Value Pair Arguments
Specify optional
comma-separated pairs of Name,Value arguments. Name is
the argument name and Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN.
Example: "Poses","off"
'Parent' — Axes used to plot pose graph Axes object | UIAxes object
Axes used to plot the pose graph, specified as the comma-separated
pair consisting of "Parent" and either an
Axes or UIAxes object. See
axes or uiaxes.