diff options
author | Nao Pross <np@0hm.ch> | 2024-05-14 01:05:15 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-05-14 01:05:15 +0200 |
commit | 868d27134a48f3de23139e873b867dba46b0d5ec (patch) | |
tree | 0d5c98573a2c95cc225e149c106335d640c11c2c | |
parent | Prepare structure for endterm (diff) | |
download | uav-868d27134a48f3de23139e873b867dba46b0d5ec.tar.gz uav-868d27134a48f3de23139e873b867dba46b0d5ec.zip |
Improve console output
Diffstat (limited to '')
-rw-r--r-- | uav.m | 36 | ||||
-rw-r--r-- | uav_model.m | 18 | ||||
-rw-r--r-- | uav_sim_step_hinf.m | 2 |
3 files changed, 39 insertions, 17 deletions
@@ -8,16 +8,36 @@ clear; clc; close all; s = tf('s'); -fprintf('Generating system parameters...\n') -params = uav_params(); -ctrl = struct(); - % Flags to speed up running for debugging do_plots = true; do_lqr = false; % unused -do_hinf = false; % midterm +do_hinf = true; % midterm do_musyn = true; % endterm +fprintf('Controller synthesis for ducted fan VTOL micro-UAV\n') +fprintf('Will do:\n') +if do_plots + fprintf(' - Produce plots\n') +end +if do_lqr + fprintf(' - LQR synthesis\n') +end +if do_hinf + fprintf(' - H-infinity synthesis\n') +end +if do_musyn + fprintf(' - Mu synthesis\n') +end + +% Synthesized controllers will be stored here +ctrl = struct(); + +% ------------------------------------------------------------------------ +%% Define system parameters + +fprintf('Generating system parameters...\n') +params = uav_params(); + % ------------------------------------------------------------------------ %% Define performance requirements @@ -59,10 +79,10 @@ if do_hinf % Get nominal system without uncertainty (for lower LFT) P_nom = minreal(P([idx.OutputError; idx.OutputNominal], ... - [idx.InputExogenous; idx.InputNominal])); + [idx.InputExogenous; idx.InputNominal]), [], false); - nmeas = max(size(idx.OutputNominal)); % size of y - nctrl = max(size(idx.InputNominal)); % size of u + nmeas = model.uncertain.Ny; + nctrl = model.uncertain.Nu; hinfopt = hinfsynOptions('Display', 'on', 'Method', 'RIC', ... 'AutoScale', 'off', 'RelTol', 1e-3); diff --git a/uav_model.m b/uav_model.m index 3b691f4..0af0818 100644 --- a/uav_model.m +++ b/uav_model.m @@ -223,7 +223,7 @@ D = zeros(12, 5); % Create state space object T = params.measurements.SensorFusionDelay; n = params.linearization.PadeApproxOrder; -sys = minreal(pade(ss(A, B, C, D, 'OutputDelay', T), n)); +sys = minreal(pade(ss(A, B, C, D, 'OutputDelay', T), n), [], false); % slient % Save linearized dynamics (numerical) model.linear = struct(... @@ -241,7 +241,7 @@ eigvals = eig(A); % Check system controllability / stabilizability Wc = ctrb(sys); if rank(Wc) < nx - fprintf('Linearized system has %d uncontrollable states!\n', ... + fprintf(' - Linearized system has %d uncontrollable states!\n', ... (nx - rank(Wc))); % Is the system at least stabilizable? @@ -257,17 +257,17 @@ if rank(Wc) < nx end end if unstabilizable > 0 - fprintf('Linearized system has %d unstabilizable modes!\n', ... + fprintf(' - Linearized system has %d unstabilizable modes!\n', ... unstabilizable); else - fprintf('However, it is stabilizable.\n'); + fprintf(' However, it is stabilizable.\n'); end end % Check system observability / detectability Wo = obsv(sys); if rank(Wo) < nx - fprintf('Linearized system has %d unobservable states!\n', ... + fprintf(' - Linearized system has %d unobservable states!\n', ... (nx - rank(Wo))); % is the system at least detectable? undetectable = 0; @@ -281,10 +281,10 @@ if rank(Wo) < nx end end if undetectable > 0 - fprintf('Linearized system has %d undetectable modes!\n', ... + fprintf(' - Linearized system has %d undetectable modes!\n', ... undetectable); else - fprintf('However, it is detectable.\n') + fprintf(' However, it is detectable.\n') end end @@ -367,10 +367,12 @@ idx = model.uncertain.index; % Number of inputs model.uncertain.Nv = max(size(idx.InputUncertain)); -model.uncertain.Nr = max(size(idx.InputReference)); model.uncertain.Nw = max(size(idx.InputExogenous)); model.uncertain.Nu = max(size(idx.InputNominal)); +model.uncertain.Nr = max(size(idx.InputReference)); +% size of noise is (Nw - Nr) + % Number of outputs model.uncertain.Nz = max(size(idx.OutputUncertain)); model.uncertain.Ne = max(size(idx.OutputError)); diff --git a/uav_sim_step_hinf.m b/uav_sim_step_hinf.m index 71510b8..5e448a1 100644 --- a/uav_sim_step_hinf.m +++ b/uav_sim_step_hinf.m @@ -20,7 +20,7 @@ P_nom_clp = minreal(usys_clp(... [model.uncertain.index.OutputError; model.uncertain.index.OutputNominal; model.uncertain.index.OutputPlots], ... - model.uncertain.index.InputExogenous)); + model.uncertain.index.InputExogenous), [], false); % Indices for exogenous inputs Iwwind = (1:3)'; |