This page provides an essential summary of the two-layer MRAC (model reference adaptive control) techniques coded in the simulator
https://github.com/andrealaffly/UAV_Sim_PyChrono/wiki
for hybrid plant models (plants with discontinuities in the trajectory and the dynamical model)
The MRAC systems for hybrid plant models can be exented to embrace the two-layer technology.
Assume that the plant model (i.e., the system to be controlled) is in the form
\[ \begin{aligned} \begin{bmatrix} \dot{x}(t) \\ \dot{\sigma}(t) \end{bmatrix} &= \begin{bmatrix} A_{\sigma(t)} x(t) + B_{\sigma(t)} \Lambda \left[u(t) + \Theta_{\sigma(t)}^{\rm T} \Phi_{\sigma(t)}(t,x(t)) \right] \\ 0 \end{bmatrix} \nonumber \\ &\hspace{1.0em} + \begin{bmatrix} \xi_{\sigma(t)}(t) \\ 0 \end{bmatrix}, \quad \begin{bmatrix} x(t_0) \\ \sigma(t_0) \end{bmatrix} = \begin{bmatrix} x_0 \\ \sigma_0 \end{bmatrix}, \quad (t,x(t)) \notin \mathcal{D}_{\sigma(t)}, \\ \begin{bmatrix} x(t^+) \\ \sigma(t^+) \end{bmatrix} &= g_{{\rm d},\sigma(t)}(t,x(t)), \quad (t,x(t)) \in \mathcal{D}_{\sigma(t)}, \end{aligned} \]
where
The primary goal of two-layer hybrid MRAC systems is to steer the plant state toward the trajectory of the refence model
\[ \begin{aligned} \begin{bmatrix} \dot{x}_{\rm ref}(t) \\ \dot{\sigma}(t) \end{bmatrix} &= \begin{bmatrix} A_{\rm ref,\sigma(t)} x_{\rm ref}(t) + B_{\rm ref,\sigma(t)} r(t) \\ 0 \end{bmatrix}, \nonumber \\ &\hspace{0.5em} \begin{bmatrix} x_{\rm ref}(t_0) \\ \sigma(t_0) \end{bmatrix} = \begin{bmatrix} x_{{\rm ref},0} \\ \sigma_0 \end{bmatrix}, \,\,\, (t,x_{\rm ref}(t)) \notin \mathcal{D}_{{\rm ref},\sigma(t)}, \\ \begin{bmatrix} x_{\rm ref}(t^+) \\ \sigma(t^+) \end{bmatrix} &= g_{{\rm d, ref}, \sigma(t)}(t,x_{\rm ref}(t)), \,\,\, (t,x_{\rm ref}(t)) \in \mathcal{D}_{{\rm ref},\sigma(t)}, \end{aligned} \]
where
\[ \mathcal{D}_{{\rm ref},\sigma_{i_w}} \triangleq \left\{ t_{{\rm ref},i_w} \right\} \times \mathbb{R}^n, \qquad{} (i,w) \in \mathbb{N} \times \mathbb{N} \]
To apply an MRAC system, the plant model must not be integrated. It suffices to assume that \(x(t)\) is known for all \(t \geq t_0\).
To this goal, two-layer hybrid MRAC systems set \[ u(t) = \phi(\tilde{K}(t),\tilde{\pi}(t)), \quad t \geq t_0, \]
where
\[ \phi(\tilde{K},\tilde{\pi}) \triangleq \tilde{K}^{\rm T} \tilde{\pi}, \quad (\tilde{K},\tilde{\pi}) \in \mathbb{R}^{(2n+m+N) \times m} \times \mathbb{R}^{(2n+m+N)}, \]
\[ \begin{aligned} \dot{\tilde{K}}(t) &= {\rm Proj}\left(\tilde{K}(t), - \mu_{\rm step}(\varepsilon(t),\epsilon_0) \Gamma \tilde{\pi}(t) \varepsilon^{\rm T}(t) P_{{\rm tran},\sigma(t)} B_{\sigma(t)} \right), \\ &\quad \tilde{K}(t_0) = \tilde{K}_0, \quad t \geq t_0, \end{aligned} \]
\(\Gamma \succ 0_{(2n+m+N) \times (2n+m+N)}\) denotes the adaptive rate matrix, which is user-defined
the augmented regressor vector is defined as
\[ \begin{aligned} \tilde{\pi}(t) &= \begin{bmatrix} x(t) \\ r(t) \\ - \Phi_{\sigma(t)}(t,x(t)) \\ e(t) \end{bmatrix}, \end{aligned} \]
\(e(t) \triangleq x(t) - x_{\rm ref}(t)\) denotes the trajectory tracking error
\(\varepsilon(t) \triangleq e(t) - e_{\rm ref,tran}(t)\) denotes the auxiliary tracking error
\[ e_{\rm ref,tran}(t) = {\rm exp}\left(A_{\rm tran,\sigma}(t-t_0)\right) e_{\rm ref,tran}(t_0), \quad{} t \geq t_0 \]
\[ {\rm Re}\left(\lambda_{\max}(A_{\rm tran,\sigma})\right) < {\rm Re}\left(\lambda_{\max}(A_{\rm ref,\sigma})\right) \]
(i.e., the eigenvalues of \(A_{\rm tran,\sigma}\) are all to the left of the eigenvalues of \(A_{\rm ref,\sigma}\) in the complex plane)
\[ A_{\rm tran, \sigma}^{\rm T} P_{\rm tran, \sigma} + P_{\rm tran, \sigma} A_{\rm tran,\sigma} = - Q_{\sigma} \]
\[ \mu_{\rm step}(e,\epsilon_0) \triangleq \begin{cases} 1, & \text{if } \lVert e \rVert \geq \epsilon_0, \\[6pt] \dfrac{\lVert e \rVert - \delta \epsilon_0}{(1 - \delta)\epsilon_0}, & \text{if } \lVert e \rVert \in [\delta \epsilon_0, \epsilon_0], \\[6pt] 0, & \text{if } \lVert e \rVert \leq \delta \epsilon_0, \end{cases} \quad e \in \mathbb{R}^n \]
\(\epsilon_0 \triangleq 2 \max_{\sigma \in \Sigma} \dfrac{\lambda_{\max}(P_{\rm tran, \sigma})}{\lambda_{\max}(Q_{\sigma})}\)
\(\delta \in (0,1)\) is user-defined
\(\lambda_{\max}(\cdot)\) denotes the eigenvalue of its matrix argument with largest real part
\(\lambda_{\min}(\cdot)\) denotes the eigenvalue of its matrix argument with smallest real part
\(\overline{\xi} \geq \max_{\sigma \in \Sigma} \Vert \xi_{\sigma}(t) \Vert\) denotes an upper bound on the unmatched uncertainty for all \(t \geq t_0\), which is user-defined
resets the reference model at
\[ \begin{aligned} &t_{{\rm ref},i_w} \triangleq \inf \Bigg\{t > \max\{t_{{\rm plant},i}, t_{{\rm ref},i_w - 1}\} : \int_{t_0}^t W(e(\tau)) {\rm d} \tau \nonumber \\ &\hspace{7.0em} \geq \sum_{j = 1}^{k - 1} \left[ e^{\rm T}(t_j^+) P_\sigma e(t_j^+) - e^{\rm T}(t_j) P_\sigma e(t_j) \right] \Bigg\} \end{aligned} \]
with
\[ g_{{\rm d, ref}, \sigma}(t_{{\rm ref},i_w},x_{\rm ref}(t_{{\rm ref},i_w})) \triangleq \begin{bmatrix} x_{\rm ref}(t_{{\rm ref},i_w}^+) \\ 0_n \end{bmatrix} \]
where
\[ \begin{aligned} x_{\rm ref}(t_{{\rm ref},i_w}^+) &= x(t_{{\rm ref},i_w}) - e_{\rm tran}(t_{{\rm ref},i_w}) \nonumber \\ &\quad{} - \sqrt{\frac{\varepsilon^{\rm T}(t_{{\rm ref},i_w}) P_{\rm tran, \sigma(t_{{\rm ref},i_w})} \varepsilon(t_{{\rm ref},i_w}) - z_{{\rm ref},i_w}} {\varepsilon^{\rm T} (t_{{\rm ref},i_w}) P_{\rm tran, \sigma(t_{{\rm ref},i_w})} \varepsilon(t_{{\rm ref},i_w})}} \nonumber \\ &\quad\quad \cdot P_{\rm tran, \sigma(t_{{\rm ref},i_w}^+)}^{-\frac{1}{2}} P_{\rm tran, \sigma(t_{{\rm ref},i_w})}^{\frac{1}{2}} \varepsilon(t_{{\rm ref},i_w}), \quad{} (i,w) \in \mathbb{N} \times \mathbb{N}. \end{aligned} \]
and resets the auxiliary tracking error at
\[ \begin{aligned} &t_{{\rm tran},i_{w_q}} \nonumber \\ &\quad \triangleq \inf \Bigg\{t > \max\{t_{{\rm plant},i},t_{{\rm ref},i_w - 1},t_{{\rm tran},i_{w_q} - 1}\} : \nonumber \\ &\quad \int_{t_0}^t W(e_{\rm tran}(\tau)) {\rm d} \tau \nonumber \\ &\quad\quad \geq \max \Bigg\{\sum_{j = 1}^{k-1} \left[\varepsilon^{\rm T}(t_j^+) P_{\rm tran, \sigma} \varepsilon(t_j^+) - \varepsilon^{\rm T}(t_j) P_{\rm tran, \sigma} \varepsilon(t_j) \right], \nonumber \\ &\quad\quad \sum_{j = 1}^{k-1} \left[e_{\rm tran}^{\rm T}(t_j^+) P_{\rm tran, \sigma} e_{\rm tran}(t_j^+) - e_{\rm tran}^{\rm T}(t_j) P_{\sigma} e_{\rm tran}(t_j) \right] \Bigg\} \Bigg\}. \end{aligned} \]
with
\[ \begin{aligned} &e_{\rm tran}(t_{{\rm tran},i_{w_q}}^+) \nonumber \\ &= - \sqrt{\frac{e_{\rm tran}^{\rm T}(t_{{\rm tran},i_{w_q}}) P_{\rm tran, \sigma} e_{\rm tran}(t_{{\rm tran},i_{w_q}}) - z_{{\rm tran},i_{w_q}}}{e_{\rm tran}^{\rm T} (t_{{\rm tran},i_{w_q}}) P_{\rm tran, \sigma(t_{{\rm ref},i_{w_q}})} e_{\rm tran}(t_{{\rm ref},i_{w_q}})}} \nonumber \\ &\hspace{1.0em} \cdot P_{\rm tran, \sigma}^{-\frac{1}{2}} P_{\rm tran, \sigma(t_{{\rm ref},i_{w_q}})}^{\frac{1}{2}} e_{\rm tran}(t_{{\rm tran},i_{w_q}}), \quad{} (i,w,q) \in \mathbb{N} \times \mathbb{N} \times \mathbb{N}. \end{aligned} \]
The control law for hybrid MRAC is the same as the control law for classical MRAC.
The adaptive law for hybrid MRAC is the same as the control law for classical MRAC.
To counter the destabilizing effect of resetting events in the plant model, the reference trajectory is reset at \(t_{{\rm ref},i_w}\) and the auxiliary tracking error is reset at \(t_{{\rm tran},i_{w_q}}\)
Assume that there exist \(K_{x,\sigma} \in \mathbb{R}^{n \times m}\), \(K_{r,\sigma} \in \mathbb{R}^{m \times m}\), \(K_{g,\sigma} \in \mathbb{R}^{n \times m}\) such that the matching conditions
\[ \begin{aligned} A_{\rm ref,\sigma} &= A_{\sigma} + B_{\sigma} \Lambda K_{x,\sigma}^{\rm T}, \\ B_{\rm ref,\sigma} &= B_{\sigma} \Lambda K_{r,\sigma}^{\rm T}, \\ A_{\rm tran,\sigma} &= A_{\rm ref, \sigma} + B_{\sigma} \Lambda K_{g,\sigma}^{\rm T} \end{aligned} \]
are verified.
Hybrid MRAC guarantees
It is impossible to solve the matching conditions since \(\{A_{\sigma}\}_{\sigma \in \Sigma}\) and \(\Lambda\) are unknown. However, the structure of each \(A_{\sigma}\) (i.e., the location of its zeros) is usually known and we know that \(\Lambda\) is diagonal and positive-definite. Thus, the existence of solutions to the matching conditions can usually be safely assumed.
The matching conditions are needed to verify compatibility between the plant model and the reference model. Here is a simple exmple, if the plant model captures the dynamics of a car and the reference model captures the dynamics of an airplane, the matching conditions can not be verified because a car is unable to take off.
For additional information, see
hybrid_two_layer_mrac.py