-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_bag_flow_engine.m
101 lines (85 loc) · 1.89 KB
/
run_bag_flow_engine.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
mass_flow = 1;
p = BagFlowEnginePlant;
v = FlowEngineVisualizer(p);
time_span = [0, 0.1];
%time_span = [0, 1.4290667];
%time_span = [0, 1.78];
%time_span = [0, 10];
%time_span = [0, 5];
n = 5;
%find region of attraction
ROA = 0;
%[c, V] = hoverLQR(p, ROA);
%sys = feedback(p, c);
tic;
%xtraj = simulate(sys, time_span);
xtraj = simulate(p, time_span);
toc;
%output plots
figure(35)
Nt = 201;
t = linspace(time_span(1), time_span(2), Nt);
xtraj_num = xtraj.eval(t);
%subplot(5, 1, 1)
subplot(4, 1, 1)
hold on
plot(t, 100*xtraj_num(1, :))
plot(time_span, [0, 0] + p.x0(1)*100, '--k')
hold off
title('$$z$$', 'interpreter', 'latex')
legend('z')
ylabel('heave (cm)')
%subplot(5, 1, 2)
subplot(4, 1, 2)
hold on
plot(t, 100*xtraj_num(2, :))
plot(time_span, [0, 0], '--k')
hold off
title('$$\dot{z}$$', 'interpreter', 'latex')
legend('dz')
ylabel('vertical speed (cm/s)')
%subplot(5, 1, 3)
subplot(4, 1, 3)
hold on
plot(t, xtraj_num(3, :)/1000)
plot(time_span, [0, 0] + p.x0(3)/1000, '--k')
hold off
title('$$p$$', 'interpreter', 'latex')
xlabel('time')
ylabel('bagpressure (kPa)')
%ylabel('force (N)')
legend('p')
subplot(4, 1, 4)
hold on
plot(t, xtraj_num(3, :)/1000)
plot(time_span, [0, 0] + p.x0(3)/1000, '--k')
hold off
title('$$p$$', 'interpreter', 'latex')
xlabel('time')
ylabel('pressure (kPa)')
%ylabel('force (N)')
legend('p')
%subplot(5, 1, 4)
% utraj_num = c.D*xtraj_num;
% utraj_shift = utraj_num + p.u0;
% hold on
% plot(t, utraj_shift)
% plot(time_span, [0, 0] + p.u0, '--k')
% hold off
% title('$$\dot{m_{in}} (u)$$', 'interpreter', 'latex')
% xlabel('time')
% ylabel('mass flow rate (kg/s)')
% legend('u')
%subplot(5, 1, 5)
% xtraj_0 = xtraj_num - p.x0;
% Vtime = dot(xtraj_0, V.S*xtraj_0);
% hold on
% plot(t, Vtime);
% plot(time_span, [0, 0], '--k')
% hold off
% title('$$V(x)$$', 'interpreter', 'latex')
% xlabel('time')
% ylabel('Lyapunov Energy')
% legend('V(x)')
%
% v.playback(xtraj);