## 5 Simulation  
In this section, we use the Links-Box semi-physical simulator to verify the effectiveness of algorithms. Links-Box automatically converts the MATLAB simulation models to the embedded control prototype and support engineering hardware to test in the models. The physical device can be directly connected to the rapid prototyping simulator to dynamically verify controller performance. The features of software package Links-RT are: (1) adapting to the models built in MATLAB; (2) providing input and output hardware to enable users to integrate the hardware environment into the simulation models; (3) automatic conversion of MATLAB model codes to VxWorks codes; (4) providing communication, storage, scheduling, and other services in VxWorks. To illustrate our adaptive method and evaluate its effectiveness, we applied it to an attitude system of a variable structure spacecraft where the physical parameters were set according to [32]. The fixed structure inertia \(J\), variable structure parameter \(J_{VS}\), and actuator distribution matrix are given by  
\[J=\left[ \begin{array}{ccc}40&12&9\\ 12&90&14\\ 9&14&40\end{array} \right]\mathrm{kg}\cdot\mathrm{m}^{3},\;D=\left[ \begin{array} []{ccc}1&0&0&\frac{1}{\sqrt{3}}\\ 0&1&0&\frac{1}{\sqrt{3}}\\ 0&0&1&\frac{1}{\sqrt{3}}\end{array} \right],\]  
\[J_{VS}=\left\{ \begin{array}{ccc}\left[\begin{array}{ccc}10\mathrm{tanh}[10 (t-20)]&0&5\mathrm{tanh}[10(t-20)]\\ 0&7\mathrm{tanh}[10(t-20)]&0\\ 3\mathrm{tanh}[10(t-20)]&0&5\mathrm{tanh}[10(t-20)]\end{array}\right]\mathrm{kg} \cdot\mathrm{m}^{3},&t\geq 20\,\mathrm{s}\\ 0,&0\leq t<20\,\mathrm{s}\end{array} \right.\]where \(\tanh(\cdot)\) is the hyperbolic tangent function which satisfies:  
\[\tanh[10(t-20)]=\frac{e^{10(t-20)}-e^{-10(t-20)}}{e^{10(t-20)}+e^{-10(t-20)}}\]  
The inertia uncertainty was chosen as \(\Delta I=2\text{diag}\{\sin(0.1t)\), \(2\text{cos}(0.2t)\), \(\sin(0.1t)\}\) kg\(\cdot\)m\({}^{3}\), and the external disturbance vector was chosen as \(d(t)=[0.1\text{sin}(0.1t),0.2\text{sin}(0.2t),0.1\text{sin}(0.3t)]\) N\(\cdot\)m. The initial attitude angles were chosen as \(\sigma_{0}=[0.5,\,0.3,\,-0.5]^{T}\) deg, and the initial angular velocities were selected as \(\omega_{0}=[0.5,\,0.3,\,-0.6]^{T}\) deg/s. The gyro was used for the angular velocity measurement, and it will inevitably encounter measurement noise in practical applications. The output signal of each gyro could be modeled as  
\[\omega_{g}(t)=\omega(t)+\omega_{n}(t) \tag{108}\]  
where \(\omega_{g}(t)\) is the actual measured angular velocity, \(\omega_{n}(t)\) is the zero mean Gaussian white noise process, and the covariance of \(\omega_{n}(t)\) is given by  
\[E\Big{\{}\omega_{n}(t)\omega_{n}^{\text{T}}(h)\Big{\}}=I_{3}\eta_{n}^{2} \alpha(t-h) \tag{109}\]  
where \(\alpha(t-h)\) is the Dirac delta function [21]. All the variable structure harmonic functions are linear functions. It was set that there are four reaction wheels used for the attitude control of a variable structure spacecraft. The actuator saturation is addressed in the position, namely, the maximum torque of each actuator was constrained to be the value of 0.8 N\(\cdot\)m. The first reaction wheel works normally, the second reaction wheel decreases 40% of the control effectiveness after \(t=2\) s, the third reaction wheel occurs a bias fault \(f_{3}=0.4\) N\(\cdot\)m after \(t=2\) s, and the fourth reaction wheel occurs a complete failure fault after \(t=2\) s.  
In the design of the fault detection observer, the positive matrix \(A_{1}\) was chosen as diag\([2,\,6,\,2]\), and the unknown positive matrix \(P_{1}\) could be solved from Equation (23) as diag\([20,\,10,\,20]\). In the design of the fault estimation observer, the Hurwitz matrix \(A_{2}\) was chosen as diag\([-3,\,-6,\,-5]\), and the unknown positive matrix \(P_{2}\) could be solved from inequality (45) as diag\([19,\,21,\,6]\). In addition, the other constant parameters were selected as \(c_{0}=0.9,\,c_{1}=0.8,\,c_{2}=0.7,\,c_{3}=0.9\), and \(\hat{W}(0)=\text{diag}\{1,\quad 1,\quad 1\}\).