-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSim.m
86 lines (80 loc) · 2.48 KB
/
Sim.m
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function [Time, Energy, lmat, vmat, maxLongA, maxLatA, currentDrag, mpower] = Sim(data, param)
type=cell2mat(data.type);
len=data.len;
rad=data.rad;
maxLongA=zeros(1,length(type));
maxLatA=zeros(1,length(type));
currentDrag = zeros(1,length(type));
mpower=currentDrag;
%Reverse
p=length(type);
vmat=(length(type));
lmat=(length(type));
vrev = inf(p ,max(len)*10);
U = 0;
lt=0;
Energy=0;
for p=1:length(type)
if(type(p)=='S' || type(p)=='s')
[V, lapTime, maxLong, en,current] = accSim(U, len(p), vrev, param, "Reverse", false, Energy);
U = V(len(p)*10);
vrev(p, 1: length(V)) = V;
end
if(type(p)=='R' || type(p)=='r')
[V, lapTime, maxLat, maxLong,Energy, current] = corneringSim(len(p), rad(p), U, vrev, param, "Reverse", false, Energy);
U = V(end);
vrev(p, 1:length(V)) = V;
end
if(type(p)=='L' || type(p)=='l')
[V, lapTime, maxLatA, maxLong, Energy, current] = corneringSim(len(p), rad(p), U, vrev, param, "Reverse", false, Energy);
U = V(end);
vrev(p, 1:length(V)) = V;
end
end
%Forward
U = 0;
Tlen=0;
for p=1:length(type)
if(type(p)=='s')
[V, lapTime, maxLong, Energy, current, mpower(p)] = accSim(U, len(p), vrev(p,:), param, "Forward", false, Energy);
U= V(len(p)*10);
maxLongA=maxLong;
maxLatA(p)=0;
lmat(p)=Tlen;
vmat(p)=U;
currentDrag(p)=current;
end
if(type(p)=='r' || type(p)=='l')
[V, lapTime, maxLat, maxLong,Energy,current,mpower(p)] = corneringSim(len(p), rad(p), U, vrev(p,:), param, "Forward", false,Energy);
U = V(end);
lmat(p)=Tlen;
vmat(p)=U;
maxLongA(p)=maxLong;
maxLatA(p)=maxLat;
currentDrag(p)=current;
end
if(type(p)=='S')
[V, lapTime, maxLong, Energy, current,mpower(p)] = accSim(U, len(p), vrev(p,:), param, "Forward", true, Energy);
U= V(len(p)*10);
vmat(p)=U;
lmat(p)=Tlen;
lt=lt+lapTime;
maxLongA(p)=maxLong;
maxLatA(p)=0;
currentDrag(p)=current;
end
if(type(p)=='R' || type(p)=='L')
[V, lapTime, maxLat, maxLong,Energy,current,mpower(p)] = corneringSim(len(p), rad(p), U, vrev(p,:), param, "Forward", true,Energy);
U= V(len(p)*10);
vmat(p)=U;
lt=lt+lapTime;
vmat(p)=U;
lmat(p)=Tlen;
maxLatA(p)=maxLat;
maxLongA(p)=maxLong;
currentDrag(p)=current;
end
Tlen=Tlen+len(p);
end
Energy = (Energy*2.77778e-7);
Time = lt;