diff options
author | Nao Pross <np@0hm.ch> | 2024-04-01 14:00:16 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-04-01 14:00:16 +0200 |
commit | 47ce5760b1c45fc5513e56dce92e29b9363bb03e (patch) | |
tree | 8494b4f43f7b5da3615cc9b973726e69a3d5e5c5 /midterm.m | |
parent | Whitespace (diff) | |
download | uav-47ce5760b1c45fc5513e56dce92e29b9363bb03e.tar.gz uav-47ce5760b1c45fc5513e56dce92e29b9363bb03e.zip |
Update a lot of small things and add SIMULINK model
Diffstat (limited to '')
-rw-r--r-- | midterm.m | 68 |
1 files changed, 52 insertions, 16 deletions
@@ -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: |