How to get a cell array with lidarScan data for addScan?

2 views (last 30 days)
Hello,
But on Mathworks they have a cell array with the lidarScan data and I have a lidarScan array. How do I change this to cell array?
% piece of code from Mathworks
% load garage_fl1_southend.mat scans
% scans = scans(1:40:end);
% my code
T = readtable('lidar_scan.csv');
for j=2:62
ranges = T{j,9:1088}; % T ist my table with all the given information
% from the LiDAR. So I have measured ranges for every timestamp for every 0.25 step of the 270
% degrees
angles = linspace(-135,135,numel(ranges));
scan(1,j-1) = lidarScan(ranges,angles); % output lidarScan array
end
maxRange = 19.2; % meters
resolution = 10; % cells per meter
slamObj = lidarSLAM(resolution,maxRange);
slamObj.LoopClosureThreshold = 360;
slamObj.LoopClosureSearchRadius = 8;
for i = 1:numel(scans)
addScan(slamObj,scans{i}); % Error here
if rem(i,10) == 0
show(slamObj);
end
end
Brace indexing is not supported for variables of this type.
Error in addScan(slamObj,scans{i});

Accepted Answer

Garmit Pant
Garmit Pant on 4 Jul 2022
Hello Blondi
It is my understanding that you want to add LIDAR scans from your data to LIDAR SLAM maps.
You are facing an error because you are using an array in the form of 'scan' but trying to access it using cell array operations.
The error you are facing can be tackled by storing the LIDAR scan data into a cell array. You can create an empty cell array and store the LIDAR scans in it and then use the code given in the example. I have made some changes to the part of your code where you are reading the LIDAR scans and you can find them below.
T = readtable('lidar_scan.csv');
scan = {}
for j=2:62
ranges = T{j,9:1088}; % T ist my table with all the given information
% from the LiDAR. So I have measured ranges for every timestamp for every 0.25 step of the 270
% degrees
angles = linspace(-135,135,numel(ranges));
scan{j-1} = lidarScan(ranges,angles); % output lidarScan array
end
I hope thid would help you. You can further read about the addScan function here: https://www.mathworks.com/help/nav/ref/lidarslam.addscan.html

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by