forked from AbhiS0612/3dof_vehicle_sim
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplot_controls_3DOF.m
67 lines (64 loc) · 1.95 KB
/
plot_controls_3DOF.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
function [] = plot_controls_3DOF(t,u,net,t_max)
%%plot_controls_3DOF(t,u,net,t_max) plot the net forces and torques acting
%%along the 3 degrees of freedom. Can be used in fully actuated or
%%underactuated case.
%
% Created: Abhi Shah
%
% Inputs: t time series data
% u time series of contorls. Can be for fully actuated or
% underactuated, plotting, and to plot net contorls or
% individual thruster forces
% net flag variable, 1 to plot net forces, 0 to plot individual
% thrust forces
% t_max max permitted thrust force
%
%%
if(net==1) %plot net forces - same for FA and UA cases.
subplot(211)
plot(t, u(:,1:2))
title 'Net Forces in Body L-Frame'
legend('$f_x$','$f_y$');
xlabel 'time (s)';
ylabel 'force (N)';
grid minor;
subplot(212)
plot(t, u(:,3))
title 'Control Torgue in Body L-Frame'
xlabel 'time (s)';
ylabel 'torque (Nm)';
grid minor;
else %plot individuals thrust forces
n_thrusters = length(u(1,:));
if(n_thrusters == 2) %underactuated case
plot(t, u(:,1:2))
hold on;
plot(t, t_max*ones(length(t)), '--r');
plot(t, -1*t_max*ones(length(t)), '--r');
hold off;
title 'Individual thruster forces'
legend('$u_1$','$u_2$', '$u_{max}$');
xlabel 'time (s)';
ylabel 'force (N)';
grid minor;
else %fully actuated case
subplot(211)
plot(t, u(:,1:2))
hold on;
plot(t, t_max*ones(length(t)), '--r');
plot(t, -1*t_max*ones(length(t)), '--r');
hold off;
title 'Individual thruster forces'
legend('$u_1$','$u_2$', '$u_{max}$');
xlabel 'time (s)';
ylabel 'force (N)';
grid minor;
subplot(212)
plot(t, u(:,3))
title 'Individual thruster torque'
xlabel 'time (s)';
ylabel 'torque (Nm)';
grid minor;
end
end
end