forked from mamariomiamo/min_snap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotTrajectory1axis.m
50 lines (48 loc) · 1.08 KB
/
plotTrajectory1axis.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
function [f, x, vx, ax, t] = plotTrajectory1axis(n_order, k_segment, time_vector, p_x, waypts, fig_index, fig_name)
f = figure(fig_index);
sgtitle(fig_name);
subplot(3,1,3);
subplot(3,1,1);
time = plot_time(time_vector);
plot(time,waypts,'*r');
hold on;
% subplot(3,1,1);
% plot(time_vector,waypts(1,:),'b--');
% each column of p is the coefficient vector for one segment
x = [];
vx = [];
ax = [];
y = [];
t = [];
for i=1:k_segment
for t_tick=0:0.01:time_vector(i)
x = [x poly_evaluate(0, t_tick, n_order) * p_x(:,i)];
vx = [vx poly_evaluate(1, t_tick, n_order) * p_x(:,i)];
ax = [ax poly_evaluate(2, t_tick, n_order) * p_x(:,i)];
t = [t t_tick+time(i)];
end
end
% t_segment=time_vector(1):0.01:time_vector(k_segment+1);
subplot(3,1,1);
plot(t,x,'r')
title("Position")
% figure(2)
% hold on;
for i=1:k_segment
xline(time(i),'k--');
end
subplot(3,1,2);
plot(t,vx,'r')
title("Velocity")
% figure(3)
% hold on;
for i=1:k_segment
xline(time(i),'k--');
end
subplot(3,1,3);
plot(t,ax,'r')
title("Acceleration")
for i=1:k_segment
xline(time(i),'k--');
end
end