我正在尝试使用MATLAB和connect()
找到我的四轴飞行器的闭环动态模型。这是我的系统和代码:
% throttle --------------------- 1450 ----------------
% throtScaled |
% |
% |
% e cs |+ u y
% r_phi,pitch,psi --->O---> PID array -----> Mapping ---->O-------> ssModel -----------
% ^ + |
% | |
% | |
% | |
% |----------------------------------------------------------------|
function closedLoopPoles
clc
% create the estimated blackbox nonlinear ARX model
nlArxSys = nonLinARXmodel(getDataSet());
% linearize the model about the operating points:
U0 = ones(4,1);
X0 = findstates(nlArxSys,getDataSet());
linTfSys = linearize(nlArxSys,U0, X0); % returns a tf
% Create the SS model
ssModel = ss(linTfSys);
%Define the PID controllers array
pidGains = [180 4 20; ...
160 4 20; ...
150 4 10];
pidTF_array = ones(3,3) * tf(0,1);
Ts = 0.0083;
for i = 1:size(pidGains,1)
pidTF_array(i,i) = pid( pidGains(i,1), pidGains(i,2), pidGains(i,3), 'Ts', Ts );
end
% Assign the signals names and the systems structure
mapping = 0.5 * [1 1 2; 1 -1 -2; -1 -1 2; -1 1 -2];
C = mapping * pidTF_array;
C.u = 'e';
C.y = 'cs';
ssModel.u = 'u';
ssModel.y = 'y';
throt_gain = tf(1450,1);
throt_gain.u = 'throttle';
throt_gain.y = 'throtScaled';
sum1 = sumblk('e = r - y',3);
sum2 = sumblk('u = throtScaled + cs',4);
% Find the closed loop system
clTF = minreal( connect(ssModel,sum2,C,sum1,{'throttle';'r'},'y') );
end
function nlArxSys = nonLinARXmodel(data)
na = [0 0 0; 0 0 0; 1 1 1];
nb = [4 4 4 4; 4 4 4 4; 3 3 3 3];
nk = [0 0 0 0; 0 0 0 0; 4 4 4 4];
Orders = [na, nb, nk]; % found blackbox per-hand tuning
nlArxSys = nlarx(data,Orders,'treepartition');
end
但即使我明确将throttle
定义为throt_gain
传输函数的输入信号,我也会收到以下错误:
Error using DynamicSystem/connect (line 226)
No block lists "throttle" as an input name.
Error in closedLoopPoles (line 55)
clTF = minreal( connect(ssModel,sum2,C,sum1,{'throttle';'r'},'y') );
根据我的理解,我如何创建系统并连接它是正确的,那么我做错了什么?