0% found this document useful (0 votes)
82 views3 pages

Slamcode

This document describes running lidar SLAM on a set of scans to build a map of an environment. It initializes a slamAlg object, adds the initial 10 scans, and visualizes the resulting map and pose graph. It then loops through the remaining scans, visualizing the first detected loop closure. Finally, it builds and visualizes the full map and trajectory using the optimized poses from slamAlg.

Uploaded by

FALAK FATIMA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views3 pages

Slamcode

This document describes running lidar SLAM on a set of scans to build a map of an environment. It initializes a slamAlg object, adds the initial 10 scans, and visualizes the resulting map and pose graph. It then loops through the remaining scans, visualizing the first detected loop closure. Finally, it builds and visualizes the full map and trajectory using the optimized poses from slamAlg.

Uploaded by

FALAK FATIMA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

load('offlineSlamData.

mat');
maxLidarRange = 8;
mapResolution = 20;
slamAlg = lidarSLAM(mapResolution, maxLidarRange);
slamAlg.LoopClosureThreshold = 210;
slamAlg.LoopClosureSearchRadius = 8;
for i=1:10
[isScanAccepted, loopClosureInfo, optimizationInfo] = addScan(slamAlg,
scans{i});
if isScanAccepted
fprintf('Added scan %d \n', i);
end
end
figure;
show(slamAlg);
title({'Map of the Environment','Pose Graph for Initial 10 Scans'});
firstTimeLCDetected = false;

figure;
for i=10:length(scans)
[isScanAccepted, loopClosureInfo, optimizationInfo] = addScan(slamAlg,
scans{i});
if ~isScanAccepted
continue;
end
% visualize the first detected loop closure, if you want to see the
% complete map building process, remove the if condition below
if optimizationInfo.IsPerformed && ~firstTimeLCDetected
show(slamAlg, 'Poses', 'off');
hold on;
show(slamAlg.PoseGraph);
hold off;
firstTimeLCDetected = true;
drawnow
end
end
title('First loop closure');
openExample('nav/OfflineSLAMExample')
openExample('nav/OfflineSLAMExample')

figure
show(slamAlg);
title({'Final Built Map of the Environment', 'Trajectory of the Robot'});
[scans, optimizedPoses] = scansAndPoses(slamAlg);
map = buildMap(scans, optimizedPoses, mapResolution, maxLidarRange);
figure;
show(map);
hold on
show(slamAlg.PoseGraph, 'IDs', 'off');
hold off
title('Occupancy Grid Map Built Using Lidar SLAM');

You might also like