Clear Filters
Clear Filters

Robot Navigation matchscan() is not working

1 view (last 30 days)
I tried to implement a matchscan() variant to see the transformations between two scans from RPLidarA1
So, I read the data from two scan dumps from the lidar - e2_1.txt and e2_2.txt
I convert them into lidar_scan objects
I try to matchscan() to see the transformation, and it results the vector [0,0,0], and I cannot figure out why
% varianta cu scan-urile din laborator
fileID = fopen('C:\Users\C\Desktop\e2_1.txt','r');
formatSpec = '%f %f %f';
sizeA = [3 Inf];
A = fscanf(fileID,formatSpec,sizeA);
fclose(fileID);
A=A';
A(:,3)=[];
% B inmagazineaza unghiurile in radiani
B(:)=A(:,1)*2*pi()/360;
B=B';
C(:)=A(:,2)
% C=C'
scan_initial=lidarScan(C,B);
fileID = fopen('C:\Users\C\Desktop\e2_2.txt','r');
formatSpec = '%f %f %f';
sizeA = [3 Inf];
A2 = fscanf(fileID,formatSpec,sizeA);
fclose(fileID);
A2=A2';
A2(:,3)=[];
% B inmagazineaza unghiurile in radiani
B2(:)=A2(:,1)*2*pi()/360;
B2=B2';
C2(:)=A2(:,2)
% C=C'
scan_final=lidarScan(C2,B2);
referenceScan = scan_initial;
currentScan = scan_final;
currScanCart = currentScan.Cartesian;
refScanCart = referenceScan.Cartesian;
figure
plot(refScanCart(:,1),refScanCart(:,2),'k.');
hold on
plot(currScanCart(:,1),currScanCart(:,2),'r.');
legend('Reference laser scan','Current laser scan','Location','NorthWest');
transform = matchScans(currentScan,referenceScan);
transScan = transformScan(currentScan,transform);
figure
plot(refScanCart(:,1),refScanCart(:,2),'k.');
hold on
transScanCart = transScan.Cartesian;
plot(transScanCart(:,1),transScanCart(:,2),'r.');
legend('Reference laser scan','Transformed current laser scan','Location','NorthWest');

Answers (1)

Akshai Manchana
Akshai Manchana on 27 Mar 2023
Hi Cristian,
I quickly tried reproducing the issue. I observed that the maximum range present in the current scan is close to 5000. This seemed higher than common lidars with 5-100 meters range. According to the lidarSan documentation the range data is expected to be in meters.
From the matchScans documentation there is an important tunable parameter "CellSize" that is dependent of input scan range and environment. The default value of this is 1 meter. According to the documentation this parameter can heavily affect the accuracy of scan registration. Neither small nor large cell sizes are recommended. The default value of 1 meter seemed very small compared to the range data (5000 meters) and I tried values between 50-500 in R2023a. I observed a better registration visually after tuning this parameter.
transform = matchScans(currentScan,referenceScan,CellSize=50)
transScan = transformScan(currentScan,transform);
figure;
plot(currentScan);
hold on;
plot(referenceScan);
plot(transScan);
legend('Current laser scan','Reference laser scan','Transformed current laser scan','Location','northeastoutside');
Regards,
Akshai

Categories

Find more on Food Sciences in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!