-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadTrack.m
More file actions
35 lines (31 loc) · 880 Bytes
/
readTrack.m
File metadata and controls
35 lines (31 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function path = readTrack()
%READTRACK Read raceway model file into arrays.
% OUTPUTS:
% x - (Nx1) world-frame x-coordinate
% y - (Nx1) world-frame y-coordinate
% th - (Nx1) world-frame heading (rad)
% k - (Nx1) track curvature
% s - (Nx1) track arclength
% n - (Nx1) track half-width
%
fname = 'track.csv';
delimiter = ','; startRow = 2;
formatSpec = '%f%f%f%f%f%[^\n\r]';
fileID = fopen(fname,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, ...
'HeaderLines' ,startRow-1, 'ReturnOnError', false);
fclose(fileID);
% Track parameters
x = dataArray{:, 1};
y = dataArray{:, 2};
th = dataArray{:, 3};
k = dataArray{:, 4};
s = dataArray{:, 5};
n = 15*ones(size(s));
%Create path structure
path.s_m = s;
path.k_1pm = k;
path.psi_rad = th;
path.posE_m = x;
path.posN_m = y
end