## 3 Methodology of Complementary Filter Calibration
### Optimization Methodology  
In the first step, the output signal is transformed by centering it with respect to the true angle value. This transformation yields a time series of actual errors. The evaluation metric for the signal is the mean absolute error (MAE), expressed as a function of the complementary filter time constant (TC). This choice represents the most appropriate objective function for this optimization, as it operates in the same unit as the error, providing a direct and interpretable measure of the mean error. Alternative measures introduce functional distortions, affecting the physical meaning of the evaluated error. The second step of the algorithm involves locating the minimum of the objective function through a \"coarse\" search. The range of time constant values, spanning from 1 to 100, is explored using a variable step size: between 1 and 20, the step size is fixed at 1, whereas beyond 20, it increases to 5 or more. This step size adjustment is informed by practical observations, leveraging the highly regular behavior of the MAE function with respect to the time constant. Such regularity facilitates efficient localization of the minimum. The analysis was performed independently for roll and pitch angles, within the range of 0 to 30 degrees, with 5-degree increments. Below are example plots demonstrating the variation in MAE as a function of the time constant for roll at 5 degrees and pitch at 25 degrees. Highly regular plots were obtained for all tested roll and pitch angles. Since these functions exhibit a minimum, it must reside within the interval \((0,1]\). This interval was explored with high precision, using a fixed step size of 0.01. Once again, highly consistent dependencies were observed for each angle. To illustrate this, we provide complementary plots for the angles described above. To further quantify the observed regularities and precisely identify the optimal time constants, we summarize in the tables below the values at which the objective function--the mean absolute error (MAE)--reaches its minimum for the analyzed pitch and roll angles. These results provide a comprehensive summary of the behavior of the MAE function and demonstrate the high degree of regularity observed across the tested angles. The analysis of the results reveals certain differences in the time constant values that minimize errors for various pitch and roll angles. For pitch angles, a universal time constant is determined as the average rounded to two decimal places. In this case, the optimal time constant is 0.12, for which the mean absolute error (MAE) remains below 0.05. For each attitude angle, the relations (Figures 7 and 8) between the mean absolute error (MAE)  
Figure 6: Example of roll angle for different time constants TK. and the time constant (TC) exhibit very regular and stable behavior. For different attitude angles, the location of the minimum remains stable and can be considered deterministic. In the case of roll angles, minimizing errors for small angles is of greater importance. Hence, we applied a weighted average with the weights 0.6, 0.1, 0.1, 0.05, 0.05, 0.05, and 0.05, corresponding to the time constants for angles of 0, 10, 15, 20, 25, and 30 degrees, respectively. Using this approach, the optimal time constant is 0.15, with the MAE not exceeding 0.07. Even without a deeper analysis of the data, the presented plots clearly demonstrate that improperly selected time constants can lead to errors several dozen times greater. This procedure is therefore critical to ensuring the precise operation of the system. The next stage of the algorithm involves the detection of systematic errors, or, more specifically, trends in the output signal. Given the iterative and cumulative nature of the system's operation, it is hypothesized that the trend should exhibit a linear character. To identify such errors, we employed a linear model for trend analysis. Let the dependent variable \(y\) represent the centered signal, which corresponds to the error as a function of time.