H-infinity controller : feedback gain calculation using LMI
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I everyone, i try to compute H-infinity feedback gain using LMI and i get that following error :
lhs of LMI #1, block (1,1): incompatible dimensions in A*X*B
I use LMI into level 2 Matlab S-function and the code is given below.
your help will be invaluable. Thanks
function path_following_controller(block)
setup(block);
function setup(block)
% number of ports.
block.NumInputPorts = 1;
block.NumOutputPorts = 1;
% port properties.
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
%input port properties.
block.InputPort(1).DatatypeID = 0; % double
block.InputPort(1).Complexity = 'Real';
block.InputPort(1).Dimensions = 4;
block.InputPort(1).DirectFeedthrough = false;
%output port properties.
block.OutputPort(1).DatatypeID = 0; % double
block.OutputPort(1).Complexity = 'Real';
block.OutputPort(1).Dimensions = 3;
% continuous states.
block.NumContStates = 2;
block.SampleTimes = [0 0];
% Specify the block simStateCompliance. The allowed values are:
% 'DefaultSimState', < Same SimState as a built-in block
block.RegBlockMethod('InitializeConditions', @InitializeConditions);
% block.RegBlockMethod('Start', @Start);
block.RegBlockMethod('Outputs', @Outputs);
block.RegBlockMethod('Derivatives', @Derivatives);
%endfunction
function InitializeConditions(block)
block.ContStates.Data(1) = 0; % ey
block.ContStates.Data(2) = 0; % delta_psi
%endfunction
function Outputs(block)
de=zeros(2,1); u=zeros(1,4);
for i=1:2
de(i)=block.ContStates.Data(i);
end
p = [120;0.5;0.5];
for i=1:4
if isnan(block.InputPort(1).data(i))
u(i)=0.000000001;
elseif block.InputPort(1).data(1:3)==0
for j=1:3
u(j)= p(j) ;
end
else
u(i)=block.InputPort(1).data(i); % création d'un vecteur de taille 4 contenant les entrées i
end
end
mu = .9; g = 9.8; delta_t = .5;
vx = u(1)
% vy = u(2);
% r = u(3);
% rho = u(4);
A = [0 vx;0 0];
B = [vx*delta_t;0];
C = [1 0;0 1];
% w = [vy;rho];
rlim = mu*g/vx;
alpha = rlim^2;
gama = 1;
setlmis([])
Q = lmivar(1,[2,1]);
Y = lmivar(1,[2,1]);
lmiterm([1 1 1 Q],A,1,'s');
lmiterm([1 1 1 Y],B,1,'s');
lmiterm([1 1 2 0],1);
lmiterm([1 1 3 Q],1,C');
lmiterm([1 2 1 0],1);
lmiterm([1 2 2 0],-gama^2);
lmiterm([1 3 1 Q],C,1);
lmiterm([1 3 3 0],-1);
lmiterm([2 1 1 0],alpha);
lmiterm([2 1 2 Y],1,1);
lmiterm([2 2 1 Y],1,1);
lmiterm([2 2 2 Q],-1,1);
lmis = getlmis;
[tmin,xfeas] = feasp(lmis);
Q = dec2mat(lmis,xfeas,Q);
Y = dec2mat(lmis,xfeas,Y);
K = Y/Q
% h1 = (vx - vxmin)/vxminxmax;
% h2 = vxmax/vxminxmax;
X = [block.ContStates.Data(1);block.ContStates.Data(2)];
rd = K*X
block.OutputPort(1).Data(1)= rd; % desired yaw rate
block.OutputPort(1).Data(1)= block.ContStates.Data(1); % ey
block.OutputPort(1).Data(1)= block.ContStates.Data(2); % delta_phi
%endfunction
function Derivatives(block)
mu = .9; g = 9.8; delta_t = .5;
de=zeros(2,1); u=zeros(1,4);
for i=1:2
de(i)=block.ContStates.Data(i);
end
for i=1:4
if isnan(block.InputPort(1).data(1))
u(i)=0.000000001;
else
u(i)=block.InputPort(1).data(i); % création d'un vecteur de taille 4 contenant les entrées i
end
end
vx = u(1);
vy = u(2);
% r = u(3);
rho = u(4);
A = [0 vx;0 0];
B = [vx*delta_t;0];
C = [1 0;0 1];
w = [vy;rho];
rlim = mu*g/vx;
alpha = rlim^2;
gama = 1;
setlmis([])
Q = lmivar(1,[2,1]);
Y = lmivar(1,[2,1]);
lmiterm([1 1 1 Q],A,1,'s');
lmiterm([1 1 1 Y],B,1,'s');
lmiterm([1 1 2 0],1);
lmiterm([1 1 3 Q],1,C');
lmiterm([1 2 1 0],1);
lmiterm([1 2 2 0],-gama^2);
lmiterm([1 3 1 Q],C,1);
lmiterm([1 3 3 0],-1);
lmiterm([2 1 1 0],alpha);
lmiterm([2 1 2 Y],1,1);
lmiterm([2 2 1 Y],1,1);
lmiterm([2 2 2 Q],-1,1);
lmis = getlmis;
[tmin,xfeas] = feasp(lmis);
Q = dec2mat(lmis,xfeas,Q);
Y = dec2mat(lmis,xfeas,Y);
K = Y/Q;
vxmin = 100; vxmax = 120;
h1 = (vx - vxmin)/vxmin;
h2 = vxmax/vxmin;
X = [d(1);d(2)];
dX = h1*((A + B*K)*X + w) + h2*((A + B*K)*X + w);
block.Derivatives.Data(1) = dX(1);
block.Derivatives.Data(2) = dX(2);
%endfunction
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Robust Control Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!