Gpos.InputName = {'p_demand','q_demand','r_demand'};
size(Gpos)
8x5 array of generalized state-space models.
Each model has 6 outputs, 3 inputs, 7 states, and 1 blocks.
Note that these commands seamlessly manage the fact that we are dealing with arrays of
plants and gains corresponding to the various (alpha,beta) conditions.
Tuning the Outer Loops
Next move to the outer loops. We already have an array of linear models Gpos for the
"plant" seen by the outer loops. As done in Part 3 (“Attitude Control in the HL-20 Autopilot
- SISO Design” (Control System Toolbox)), parameterize the six gain schedules as
polynomial surfaces in alpha and beta. Again we use quadratic surfaces for the
proportional gains and multilinear surfaces for the integral gains.
% Grid of (alpha,beta) design points
alpha_vec = -10:5:25; % Alpha Range
beta_vec = -10:5:10; % Beta Range
[alpha,beta] = ndgrid(alpha_vec,beta_vec);
SG = struct('alpha',alpha,'beta',beta);
% Proportional gains
alphabetaBasis = polyBasis('canonical',2,2);
P_PHI = tunableSurface('Pphi', 0.05, SG, alphabetaBasis);
P_ALPHA = tunableSurface('Palpha', 0.05, SG, alphabetaBasis);
P_BETA = tunableSurface('Pbeta', -0.05, SG, alphabetaBasis);
% Integral gains
alphaBasis = @(alpha) alpha;
betaBasis = @(beta) abs(beta);
alphabetaBasis = ndBasis(alphaBasis,betaBasis);
I_PHI = tunableSurface('Iphi', 0.05, SG, alphabetaBasis);
I_ALPHA = tunableSurface('Ialpha', 0.05, SG, alphabetaBasis);
I_BETA = tunableSurface('Ibeta', -0.05, SG, alphabetaBasis);
The overall controller for the outer loop is a diagonal 3-by-3 PI controller taken the errors
on angular positions phi,alpha,beta and calculating the rate demands
p_demand,q_demand,r_demand.
KP = append(P_PHI,P_ALPHA,P_BETA);
KI = append(I_PHI,I_ALPHA,I_BETA);
Cpos = KP + KI * tf(1,[1 0]);
MATLAB Workflow for Tuning the HL-20 Autopilot