-
Notifications
You must be signed in to change notification settings - Fork 36
/
QuadSimulink.asv
69 lines (52 loc) · 1.67 KB
/
QuadSimulink.asv
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
%-----------------------------------------------------------------------%
% %
% This script simulates quadrotor dynamics and implements a control % %
% algrotihm using the Simulnk Block Diagram file QuadrotorSimulink.mdl %
% Developed by: Wil Selby %
% %
% %
%-----------------------------------------------------------------------%
%% Initialize Workspace
clear all;
% close all;
clc;
global Quad;
%% Initialize the plot
% init_plot;
% plot_quad_model;
%% Initialize Variables
quad_variables;
%% Run Simulation
SimOut = sim('QuadrotorSimulink');
%% Run The Simulation Loop
for S = SimOut(1): 3*SimOut(2): size(SimOut,1)
%% Plot the Quadrotor's Position
if(mod(S,3)==0)
plot_quad
% campos([A.X+2 A.Y+2 A.Z+2])
% camtarget([A.X A.Y A.Z])
% camroll(0);
drawnow
end
end
%% Plot Data
figure();
plot(SimOut,X_out.signals.values)
hold on;
plot(SimOut,X_desired.signals.values);
title('X');
figure();
plot(SimOut,Y_out.signals.values)
hold on;
plot(SimOut,Y_desired.signals.values);
title('Y');
figure();
plot(SimOut,Z_out.signals.values)
hold on;
plot(SimOut,Z_desired.signals.values);
title('Z');
figure();
plot(SimOut,Psi_out.signals.values)
hold on;
plot(SimOut,Psi_desired.signals.values);
title('Psi');