clc;clear;load("offlineSlamData.mat")%% Run SLAM algo, Construct optimized map and plot trajectory of the robotmaxLidarRange=5;mapResolution=50;slamAlg=lidarSLAM(mapResolution,maxLidarRange);slamAlg.LoopClosureThreshold=210;slamAlg.LoopClosureSearchRadius=8;%% Initialize videomyVideo=VideoWriter('SLAMalgo');%open video filemyVideo.FrameRate=10;%can adjust this, 5 - 10 works well for meopen(myVideo)%% Observe the map building process with initial 10 scansfori=1:70[isScanAccepted,loopClosureInfo,optimizationInfo]=addScan(slamAlg,scans{i});show(slamAlg);ifisScanAcceptedfprintf('Added scan %d \n',i);drawnow%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%frame=getframe(gcf);%get framewriteVideo(myVideo,frame);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%endend% figure;% show(slamAlg)title({'Map of the environment','Pose graph for initial 70 scans'})close(myVideo)