## 3 Data Fusion Algorithm
### Software Modelling and Experimental Testing of the Data Fusion Algorithm  
As in the attitude algorithm situation, the software implementation involved the use of Matlab/Simulink facilities. Depending on the number of sensors considered in the detection cluster to be fused, various Simulink models allowed the testing and evaluation of the proposed algorithm performance through numerical simulation and experimental testing [88]. Taking into account the goal of the present research and the hardware possibilities to test experimentally such a redundant spacecraft attitude system, the team decided to use three detection clusters on the IMU axes, with four miniaturized gyros in linear configuration for each cluster. Therefore, in this section, we will give results obtained with the software model of the data fusion algorithm developed for detection clusters with four sensors. The Matbal/Simulink model associated to the mathematics of the algorithm particularized for \(n=4\) sensors resulted as in Figure 6, and was called \"Sensor data fusion\" [79; 84; 88]. As the input, it has the data provided by the four sensors considered in the cluster (\"Sensor 1\"-\"Sensor 4\"), and as the output, it has the fused signal (\"fused signal\"), the standard deviation of the fused signal (\"fused signal std\"), the standard deviations of the four sensors data (\"std1\"-\"std4\"), and the weights (\"w1\"-\"w4\") assigned to each of the sensors in cluster. Looking under the mask of the \"Sensor data fusion\" block, we can see that the input data obtained from the sensors are multiplexed and then passed through a \"Buffer\" block, which generates data frames of \(m\) successive samples for each of the four sensors channels considered as inputs; actually, the data stored at a moment of time are distributed in a matrix \(n\times m\). In the \"Buffer\" settings, we opted for a structure with \(m=100\) samples (\(n\times m=4\times 100\)) in a FIFO (first in first out) configuration, which means that in each channel between two consecutive data frames, there will be 99 common samples. From this perspective, the implementation follows the mathematical flow, with the evaluation of the standard deviations (by using the \"Standard deviation\" block) for each data frame provided by the \"Buffer\", with the determination of the sensor's associated weights for each data frame of 100 samples, and with the calculation of the data fusion result for each set of four input samples provided by the four sensors in the cluster (Equations (18) and (19)). As a measure to detect and isolate defects, the user imposes a threshold above which the standard deviation is considered abnormal for the functioning of the type of sensor used in the cluster, and when this threshold is exceeded, the sensor receives a null weight and is excluded from the calculus which estimates the fused signal. The sensor receives also a null weight if it provides data for which the calculated standard deviation is zero. This protection mechanism is implemented in the simulation model by using the \"Switch\" block. Therefore, the \"Switch\" block is the one that decides the correct operation of each of the four sensors, having the ability to give zero weight, in the calculation of the output value, to those that have failed. The blocks between \"Switch\" and \"Product\" compete to implement Equation (18) for each of the four measurement channels. The completion of the implementation of Equation (19) is achieved with the \"Product\" block, to whose input the information read on the four channels at the sample \(m+1\) is brought, and with the \"Matrix Sum1\" and \"Frame Status Conversion\" blocks, which perform the summation of the \(r_{i,m+1}\) weighted inputs, respectively, and the conversion of the numeric format of the output \(f_{m+1}\). As was already mentioned, the software model implementing the data fusion algorithm was simulated and evaluated in various situations.