Approximate Model Inversion (AMI) Based MRAC
Zhao Zhao

1 Approximate Model Inversion (AMI) Based MRAC

Plant: Design a control law such that the plant tracks the reference model Design a pseudo control such that . If plant model were known and invertible, then we can simply set , in this case . However, this is usually not the case, so choose an inversion model and let . So, we have .

Control task: Design a pseudo control that achieves The combined control action has the following three parts Then, we have the combined control action: Next, we deduce the tracking error dynamics. We rewrite the plant as Let’s differentiate :

Structured Uncertainty: Given that there exists a constant matrix and known basis functions such that Then, choose adaptive element

Unstructured Uncertainty: Given is continuous and defined over a compact set, then: where is some universal function approximator parameterized by .

Therefore, we have

Instantaneous Error Minimization: Updates weights in the direction of maximum reduction of quadratic cost of the instantaneous tracking error

Letting be the solution of the closed loop Lyapunov equation: This results in the following rank -1 adaptive law: This adaptive law requires PE to ensure exponential stability of .

Then, we have The stability can be proved by the positive definite Lyapunov Candidate: The entire closed loop system has two coupled differential equations:

  • Here we assumed to be a constant;
  • Notice no feedback from in the second equation;
  • This could lead to issues with boundedness of , especially if there is noise in the system;
  • When does ? (Persistency of excitation)

Let denotes the roll attitude of an aircraft, denotes the roll rate and denotes the aileron control input. Then a model for wing rock dynamics is Model and reference model:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
% simulation model
function [x,x_rm,xDot,deltaErr,v_crm]=wingrock_correct(x,x_rm,v_h,delta,dt,controlDT,Wstar,xref,omegan_rm,zeta_rm)
% input : x---previous step system states, size= 2 x 1
% x_rm---previous step reference system states, size= 2 x 1
% v_h---control saturations, e don't consider control
% saturations in this sim with v_h = 0
% delta---approximate inversion, v=delta
% dt--- time step
% controlDT---control period=time step
% Wstar---ideal weights
% xref--- reference signal
% omegan_rm---natural frequency of reference model
% zeta_rm--- damping ratio of reference model

% output: x---current step system states
% x_rm---current step reference system states
% xDot---current step system derivations of states
% deltaErr--- actual system uncertainties
% v_crm---reference model output

deltaErr=Wstar'*[1;x(1);x(2);abs(x(1))*x(2);abs(x(2))*x(2);x(1)^3];

%Reference model update
xp=stat_refmodel(x_rm,v_h,xref,omegan_rm,zeta_rm);
x_rm=x_rm+xp*controlDT;
v_crm=omegan_rm^2*(xref-x_rm(1))-2*zeta_rm*omegan_rm*x_rm(2);

% propogate state dynamics
clear xp
xp=state(x,delta,Wstar);
xDot=xp;
x=x+dt*xp;
deltaErr=Wstar'*[1;x(1);x(2);abs(x(1))*x(2);abs(x(2))*x(2);x(1)^3];
% End main function
1
2
3
4
5
6
7
8
9
10
11
12
13
 %State model
function [xDot] = state(x,delta,Wstar)
x1Dot=x(2);
deltaErr=Wstar'*[1;x(1);x(2);abs(x(1))*x(2);abs(x(2))*x(2);x(1)^3];
x2Dot=delta+deltaErr;%delta=v
xDot=[x1Dot;x2Dot];

% reference model state dynamics
function [x_dot_rm] = stat_refmodel(x_rm,v_h,xref,omegan_rm,zeta_rm)
x1Dot_rm = x_rm(2);
v_crm=omegan_rm^2*(xref-x_rm(1))-2*zeta_rm*omegan_rm*x_rm(2);
x2Dot_rm = v_crm - v_h;
x_dot_rm=[x1Dot_rm;x2Dot_rm];

Feedback control:

1
2
3
4
5
6
7
Kp = 1.5;                 % proportional gain
Kd = 1.3; % derivative gain

A=[0 1;-Kp -Kd];
B = [0; 1];
Q = eye(2);
P = lyap(A',Q);%A' instead of A because need to solve A'P+PA+Q=0
1
2
3
4
5
6
7
%% reference model parameters
omegan_rm = 1; % reference model natural freq (deg/s)
zeta_rm = 0.5; % reference model damping ratio
x_rm = x;
v_h=0;
v_ad=0;
v_crm=omegan_rm^2*(XREF(1)-x_rm(1))-2*zeta_rm*omegan_rm*x_rm(2);

Main control loop:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
for t=t0:dt:tf
e=x_rm-x;%compute reference model error
xref=XREF(index);
v_crm=omegan_rm^2*(xref-x_rm(1))-2*zeta_rm*omegan_rm*x_rm(2);
v_pd=[Kp Kd]*e;
deltaCmd = v_crm + v_pd - v_ad;%Nu
delta = deltaCmd;
v_h=deltaCmd-delta;

[x,x_rm,xddot,deltaErr,v_crm]=wingrock_correct(x,x_rm,v_h,delta,dt,dt,Wstar,xref,omegan_rm,zeta_rm);
x=x+randn(2,1)*wn;
sigma= [1;x(1);x(2);abs(x(1))*x(2);abs(x(2))*x(2);x(1)^3];

Wd=-gammaW*e'*P*B*sigma ;
wtilde=W-Wstar;

lyap_v(index)=e'*P*e+wtilde'*inv(gammaW)*wtilde;
W=W+dt*Wd;
v_ad=W'*sigma;
end

2 Adaptive Control with Neural Network

Radial Basis Functions (RBFs) are Gaussian Kernels with the adaptive law:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
%% RBF NN parameters
n2=10;
phi_space=[-2,2];
phid_space=[-2,2];
%Distribute centers using a uniform random distribution
for ii = 2 :n2+1
rbf_c(1,ii)=unifrnd(phi_space(1),phi_space(2));
rbf_c(2,ii)=unifrnd(phid_space(1),phid_space(2));
rbf_mu(ii)=1;
end
W=zeros(n2+1,1);
sigma=zeros(n2+1,1);
bw=1;
sigma(1)=bw;

RBF kernel:

1
2
3
4
5
6
7
8
function sigma= sdash_rbf(x,rbf_c,rbf_mu,bw,n2)
%calculates sigma for a RBF NN given the state the rbf centers and rbf
%widths. Note that centers should be picked over a uniform distribution of
%the domain.
sigma(1)=bw;
for jj=2:n2+1
sigma(jj,1)=exp(-norm(x-rbf_c(:,jj-1))^2/rbf_mu(jj-1)^2);
end
1
2
3
4
sigma= sdash_rbf(x,rbf_c,rbf_mu,bw,n2);
Wd=-gammaW*e'*P*B*sigma-gammaW*kappa*W ;
Wdot=Wd;
W=W+dt*Wdot;