# Observer-Based Distributed Fault Detection for Heterogeneous Multi-Agent Systems
## 4 Simulation Example  
In this section, we will provide an example to illustrate the effectiveness of the two proposed distributed FD schemes.  
Consider the following agent dynamics in Reference [31]:  
\[\begin{split}\dot{x}_{i}&=\begin{bmatrix}0&1&0\\ 0&0&c_{i}\\ 0&-d_{i}&a_{i}\end{bmatrix}x_{i}+\begin{bmatrix}0\\ 0\\ b_{i}\end{bmatrix}u_{i}+\begin{bmatrix}-0.5&0\\ -1&0.5\\ 0&0\end{bmatrix}v\\ e_{i}&=\begin{bmatrix}1&0&0\\ 0&1&0\end{bmatrix}x_{i}+\begin{bmatrix}-1&0\\ -0.5&-1\end{bmatrix}v\\ y_{mi}&=\begin{bmatrix}1&0&0\\ 0&1&0\end{bmatrix}x_{i}\end{split} \tag{35}\]  
where the parameters \(\{a_{i},b_{i},c_{i},d_{i}\}\) are modelled as \(\{1,1,1,1\}\), \(\{10,2,1,1\}\), \(\{2,1,1,10\}\) and \(\{2,1,1,1\}\), respectively.  
Assume the communication graph \(\mathcal{G}\) among all the follower agents and the exosystem can be described by Figure 1, where node \(0\) represents the exosystem and the other nodes represent four follower agents, where agent \(2\) is assumed as faulty, it can be observed that only agent \(3\) can access the exosystem state \(v\), \(v\) is generated by the exosystem \(\hat{v}=Sv\), where Then, it can be verified that Assumptions 1-3 are satisfied, \((A_{i},B_{i})\) are stabilisable, \((A_{i},C_{mi})\) are detectable, and four follower agents have paths to the leader in the graph \(\mathcal{G}\). What is more,  
\[B_{f_{1}}=B_{f_{2}}=B_{f_{3}}=B_{f_{4}}=\begin{bmatrix}1&0&0\end{bmatrix}^{T}\]  
which satisfy Assumption 4. The solutions of (6) are given by  
\[X_{i}=\begin{bmatrix}1&0.5&0\\ 0&1&0\end{bmatrix}^{T},U_{i}=\begin{bmatrix}0.5d_{i}&\frac{d_{i}}{b_{i}}\\ \frac{1}{b_{i}}&\end{bmatrix}\]  
where \(i=1,2,3,4\).  
Choose the coupling gain coefficient \(c\), parameter matrices of control laws as Theorems 2 and 3, which correspond to the state-feedback-based and output-feedback-based distributed FD schemes, respectively, as well as parameter matrices of the observers for FD.  
For the condition that state information is measurable, run control law (7) and observers (15) for FD.  
The fault is assumed to be a constant and occur in the first element of \(x_{2}\), i.e., \(f_{2}=3.5\), which occurs after 25 s. Residual generators \(r_{11}\), \(r_{12}\) and \(r_{14}\) in agent 1 are shown as Figure 2, which are represented by 2-norm type. According to Remark 8, we could choose a positive scalar \(\epsilon\), which is larger than \(||e_{21}(0)||\), \(||e_{22}(0)||\) and \(||e_{24}(0)||\), and \(e^{\epsilon t}\), which is larger than \(||e^{\alpha_{21}t}||\), \(||e^{\alpha_{22}t}||\) and \(||e^{\alpha_{21}t}||\), combined with \(||C_{2}||=1.64\). Then, the isolation threshold could be set as \(1.64e\cdot e^{\epsilon t}\).  
It is shown that above residuals converge to little enough values before the fault occurs, then \(r_{11}\) and \(r_{14}\) fluctuate when the fault occurs at the time of 25 s. However, \(r_{12}\) does not fluctuate as \(r_{11}\) and \(r_{14}\) when the fault occurs, then according to Algorithm 1, the fault occurs in agent 2.  
For the condition that state information is unmeasurable, run control law (21) and observers (29) for FD.  
The fault signal is the same as the state feedback case, as well as the isolation threshold selection method. Simulation results of residual generators \(r_{11}\), \(r_{12}\) and \(r_{14}\) in agent 1 are shown as Figure 3, and still represented by 2-norm type. It is shown that \(r_{12}\) remains converging after the fault occurs, where \(r_{11}\) and \(r_{14}\) fluctuate; therefore, the fault occurs in agent 2.  
Figure 1: Communication topology of the multi-agent system (MAS).  
Figure 2: Residual generators in agent 1 under state feedback.