function [scan,raw] = load3Dscan(n,basename,extension) % loads a scan set stored according to the Osnabrueck formatting % n: number of scans % basename: common name file name (excluding the counter) % extension: common extension % returns a matrix with 4 rows and n*361 columns, one per detected point. For each point % it stores its x,y,z coordinates in meters and the intensity value % example: load3Dscan(471,"scan","dat"); scan = zeros(4,n*361); raw = zeros(4,n*361); point = 1; for i = 1:n progress(i, n); fname = sprintf('%s%d.%s',basename,i,extension); fid = fopen(fname); fseek(fid,54,'bof'); % skips useless header angle = fscanf(fid,'%f',1); % fprintf('Reading file %s angle = %f deg \n',fname, angle); angle = deg2rad(angle); % this is a rotation about the y axis, assuming x is forward and z is upwards for row = 1:361 x = fscanf(fid,'%f',1); y = fscanf(fid,'%f',1); z = 0; range = fscanf(fid,'%f',1); intensity = fscanf(fid,'%f',1); %% not used if range > 800 continue; end raw(:,point) = [x,y,range,intensity]'; p = 0.01 * rot_x(-angle) * [x;y;z] ; scan(:,point) = [p; intensity*0.001]; point = point + 1; end fclose(fid); end