-
Notifications
You must be signed in to change notification settings - Fork 17
/
plot_profile.m
182 lines (163 loc) · 5.79 KB
/
plot_profile.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
% Generates the figures in the paper
% Run temporal_opt.m and speed_iter.m first
switch scenario
case 'Overtake'
figure(1);clf;hold on
subplot(511);hold on;
yaxis = path(1,1:nstep);
lanebd = 2;
alongmax = 2.5;
plot(path(1,[1,nstep]),[lanebd lanebd],'--k')
plot(path(1,:),path(2,:),'k','LineWidth',2)
axis([path(1,1) path(1,nstep) -2 6])
title('Path')
%ylabel('m')
box on
subplot(512);hold on;
plot(yaxis,curv*100,'k','LineWidth',2)
axis([path(1,1) path(1,nstep) -0.06*100 0.06*100])
title('Curvature')
box on
subplot(513);hold on;
for k=1:size(iter,2)
plot(yaxis,[v0 iter{k}.speed],'color',[1-k/size(iter,2),1-k/size(iter,2),1-k/size(iter,2)],'LineWidth',1)
end
plot(yaxis,[v0 speed],'k','LineWidth',2)
plot(yaxis([1,nstep]),[vref vref],'--k')
axis([yaxis(1) yaxis(nstep) 7 12])
title('The Speed Profile')
%ylabel('m/s')
box on
subplot(514)
hold on
plot(yaxis(1:nstep-1),acc_long,'k','LineWidth',2)
plot(yaxis(1:nstep-1),acc_lat,'-.k','LineWidth',2)
plot(yaxis([1,nstep-1]),[alongmax alongmax],'--b')
plot(yaxis([1,nstep-1]),-[alongmax alongmax],'--b')
%legend('Longitudinal','Lateral','Limits')
axis([yaxis(1) yaxis(nstep) -3 3 ])
title('The Acceleration Profile')
box on
%ylabel('m/s^2')
subplot(515)
hold on
plot(yaxis(1:nstep-1),j_long,'k','LineWidth',2)
plot(yaxis(1:nstep-1),j_lat,'-.k','LineWidth',2)
axis([yaxis(1) yaxis(nstep) -4 4 ])
title('The Jerk Profile')
%legend('Longitudinal','Lateral')
%ylabel('m/s^3')
case 'CurvRoad'
figure(1);clf;hold on
subplot(221);hold on;
yaxis = 0:delta:(nstep-1)*delta;
lanebd = 2;
alongmax = 2.5;
plot(yaxis,curv,'k','LineWidth',2)
%plot(path(1,[1,nstep]),[lanebd lanebd],'--k')
axis([yaxis(1) yaxis(end) 0 0.06])
title('Curvature')
%ylabel('1/m')
box on
subplot(223);hold on;
for k=1:size(iter,2)
plot(yaxis,[v0 iter{k}.speed],'color',[1-k/size(iter,2),1-k/size(iter,2),1-k/size(iter,2)],'LineWidth',1)
end
plot(yaxis,[v0 speed],'k','LineWidth',2)
%plot(yaxis([1,nstep]),[vref vref],'k')
%legend('Ref','Iter 1', 'Iter 2','Iter 3','Iter 4','Iter 5')
axis([yaxis(1) yaxis(nstep) 7 12])
title('The Speed Profile')
%ylabel('m/s')
%xlabel('Distance along the path (m)')
box on
subplot(222)
hold on
plot(yaxis(1:nstep-1),acc_long,'k','LineWidth',2)
plot(yaxis(1:nstep-1),acc_lat,'-.k','LineWidth',2)
plot(yaxis([1,nstep-1]),[alongmax alongmax],'--b')
plot(yaxis([1,nstep-1]),-[alongmax alongmax],'--b')
%legend('Longitudinal','Lateral','Limits')
axis([yaxis(1) yaxis(nstep-1) -3 3 ])
title('The Acceleration Profile')
box on
%ylabel('m/s^2')
subplot(224)
hold on
plot(yaxis(1:nstep-1),j_long,'k','LineWidth',2)
plot(yaxis(1:nstep-1),j_lat,'-.k','LineWidth',2)
axis([yaxis(1) yaxis(nstep-1) -3 3 ])
title('The Jerk Profile')
%legend('Longitudinal','Lateral')
%ylabel('m/s^3')
case 'Intersec'
figure(1);clf;hold on
subplot(221);hold on;
yaxis = 0:delta:(nstep-1)*delta;
%yaxis = 0:nstep-1;
plot(yaxis,curv,'k','LineWidth',2)
%plot(path(1,[1,nstep]),[lanebd lanebd],'--k')
axis([yaxis(1) yaxis(end) -0.2 0])
title('Curvature')
box on
subplot(223);hold on;
for k=1:size(iter,2)
plot(yaxis,[v0 iter{k}.speed],'color',[1-k/size(iter,2),1-k/size(iter,2),1-k/size(iter,2)],'LineWidth',1)
end
plot(yaxis,[v0 speed],'k','LineWidth',2)
plot(yaxis([1,nstep]),[vref vref],'k')
axis([yaxis(1) yaxis(nstep) 0 6])
title('The Speed Profile')
%ylabel('m/s')
box on
subplot(222)
hold on
plot(yaxis(1:nstep-1),acc_long,'k','LineWidth',2)
plot(yaxis(1:nstep-1),acc_lat,'-.k','LineWidth',2)
plot(yaxis([1,nstep-1]),[alongmax alongmax],'--b')
plot(yaxis([1,nstep-1]),-[alongmax alongmax],'--b')
%legend('Longitudinal','Lateral','Limits')
axis([yaxis(1) yaxis(nstep-1) -3 3 ])
title('The Acceleration Profile')
box on
%ylabel('m/s^2')
subplot(224)
hold on
plot(yaxis(1:nstep-1),j_long,'k','LineWidth',2)
plot(yaxis(1:nstep-1),j_lat,'-.k','LineWidth',2)
axis([yaxis(1) yaxis(nstep-1) -3 5 ])
title('The Jerk Profile')
%legend('Longitudinal','Lateral')
%ylabel('m/s^3')
end
switch scenario
case 'Overtake'
xlabel('Distance along the lane (m)')
case 'CurvRoad'
%xlabel('Distance along the path (m)')
case 'Intersec'
%xlabel('Distance along the path (m)')
end
box on
%%
figure(2);hold on
%constraint_gen;
Accum = tril(ones(nstep,nstep-1),-1);
title('The Time Stamp')
switch scenario
case 'Overtake'
ylabel('Distance along the path (m)')
plot(Accum*reft,0:delta:(nstep-1)*delta,'-ok','LineWidth',2,'MarkerSize',3);
case 'CurvRoad'
ylabel('Distance along the path (m)')
plot(Accum*reft,yaxis,'-ok','LineWidth',2,'MarkerSize',3);
case 'Intersec'
ylabel('Distance along the path (m)')
plot(Accum*reft,yaxis,'-ok','LineWidth',2,'MarkerSize',3);
end
xlabel('T(s)')
axis([0 8 yaxis(1) yaxis(end)+delta])
box on
%%
% figure(22);hold on
% plot(yaxis(1:nstep-1),reft,'-*','LineWidth',3);