summaryrefslogtreecommitdiffstats
path: root/midterm.m
diff options
context:
space:
mode:
Diffstat (limited to 'midterm.m')
-rw-r--r--midterm.m68
1 files changed, 52 insertions, 16 deletions
diff --git a/midterm.m b/midterm.m
index 8f8e5e1..eca35bc 100644
--- a/midterm.m
+++ b/midterm.m
@@ -3,39 +3,75 @@
%% ------------------------------------------------------------------------
% Clear environment and generate parameters
-clear; clc; close all;
+clear; clc; close all; s = tf('s');
params = uav_params();
%% ------------------------------------------------------------------------
-% Create nominal plant and controller
+% Create nominal plant
% Generate nominal model
model = uav_model(params);
-ctrl = uav_ctrl_nominal(params, model);
-% Model dimensions
-nx = model.linear.Nx;
+%% ------------------------------------------------------------------------
+% Define performance requirements
-% Open loop path
-L = model.linear.StateSpace * ctrl.K;
+alpha_max = params.actuators.ServoAbsMaxAngleDeg * pi / 180;
+W_Palpha = tf(alpha_max,1);
-% Closed loop path under unitary negative gain
-G = feedback(L, eye(nx, nx));
+W_Pomega = tf(1,1);
+W_Pxy = tf(1,1);
+W_Pz = tf(1,1);
-%% ------------------------------------------------------------------------
-% Simulate nominal controller
+figure(1); hold on;
+bodemag(W_Palpha);
+bodemag(W_Pomega);
+bodemag(W_Pxy);
+bodemag(W_Pz);
-%% ------------------------------------------------------------------------
-% Define performance goals
+grid on;
+legend('$W_{P,\alpha}$', '$W_{P,\omega}$', ...
+ '$W_{P,xy}$', '$W_{P,z}$', ...
+ 'interpreter', 'latex', 'fontSize', 8);
+title('Performance requirements');
+
+
+W_PP = blkdiag(W_Pxy * eye(2), W_Pz);
+
+perf = struct(...
+ 'FlapAngle', W_Palpha * eye(4), ...
+ 'Thrust', W_Pomega, ...
+ 'PositionAccuracy', W_PP);
%% ------------------------------------------------------------------------
-% Create uncertain model
+% Define stability requirements
+
+% Mechanically, flaps are constrained to a max of 20~25 degrees,
+% we assume a precision of
+% also, flaps tend to get less precise at higher frequencies
+alpha_max = 2 * pi * 20;
+W_malpha = alpha_max / (s + 2) * eye(4);
+
+W_momega = tf(1,1);
+W_mTheta = tf(1,1) * eye(3);
+W_mOmega = tf(1,1) * eye(3);
+
+uncert = struct(...
+ 'FlapAngle', W_malpha, ...
+ 'Thrust', W_momega, ...
+ 'EulerAnglesApprox', W_mTheta, ...
+ 'AngularRateApprox', W_mOmega);
%% ------------------------------------------------------------------------
-% Define stability goals
+% Create uncertain system
+
+% Load simulink model with uncertainties
+usys = linmod('uav_model_uncertain');
+G = ss(usys.a, usys.b, usys.c, usys.d);
%% ------------------------------------------------------------------------
% Perform H-infinity design
%% ------------------------------------------------------------------------
-% Perform mu-Analysis \ No newline at end of file
+% Perform mu-Analysis & DK iteration
+
+% vim: ts=2 sw=2 et: