Application of Filters to Improve Flight Stability of Rotary Unmanned Aerial Objects

The most common filters used to determine the angular position of quadrotors are the Kalman filter and the complementary filter. The problem of angular position estimation consist is a result of the absence of direct data. The most common sensors on board UAVs are micro electro mechanical system (MEMS) type sensors. The data acquired from the sensors are processed using digital filters. In the literature, the results of research conducted on the effectiveness of Kalman and complementary filters are known. A significant problem in evaluating the performance of the studied filters was the lack of an arbitrarily determined UAV position. The authors of this paper undertook the task of determining the best filter for a real object. The main objective of this research was to improve the stability of the physical quadrotor. For this purpose, we developed a research method using a laboratory station for testing quadrotor drones. Moreover, using the MATLAB environment, they determined the optimal parameters for the real filter applied using the PX4 software, which is new and has not been considered before in the available scientific literature. It should be mentioned that the authors of this work focused on the analysis of filters most commonly used for flight stabilization, without modifying the structure of these filters. By not modifying the filter structure, it is possible to optimize the existing flight controllers. The main contribution of this study lies in finding the most optimal filter, among those available in flight controllers, for angular position estimation. The special emphasis of our work was to develop a procedure for selecting the filter coefficients for a real object. The algorithm was designed so that other researchers could use it, provided they collected arbitrary data for their objects. Selected results of the research are presented in graphical form. The proposed procedure for improving the embedded filter can be used by other researchers on their subjects.


Introduction
The Kalman filter and the complementary filter are the most popular filters for determining the angular position of unmanned aerial vehicles (UAVs). The problem of angle estimation is the absence of direct data. The most common sensors on board UAVs are micro electro mechanical system (MEMS) sensors. Basic sensors are used, such as accelerometer, gyroscope, magnetometer sensors. The data acquired from the sensors are processed by using digital filters. The Kalman filter has been studied in [1][2][3][4][5][6][7]. Publications are available in which the authors have undertaken modifications to the structure of the Kalman filter. In 2015, Xiong, J.J., and Zheng, E.H. [8] developed an optimal Kalman filter (OKF) for quadrotor position estimation. In 2019, Alawsi, A.A.A., Jasim, B.H., and Raafat, S.M. [9] developed the unscented Kalman filter (UKF). In both these papers, the authors worked exclusively on simulation objects. Information about the complementary filter and its use in UAV navigation can be found in references [10][11][12][13]. The problem so far in evaluating the filter's performance has been the lack of an arbitrary UAV position. One of the first attempts to compare the two filters was made by Walter Higgins [14]. In his 1975 paper, he compared only the theoretical operation of the filters. The authors of reference [15] used a

Measurement Method
A real drone was used to conduct experimental research. PX4 software was uploaded to the flight controller. It enabled the drone to connect to the computer, which is the central unit of the ROS (robot operating system). The Mavlink protocol data and parameters of the drone were transmitted using a 433 MHz radio module. The Mavros program supervised the exchange of information in real time. The raw data from the sensors were archived to a csv file along with the timestamp by ROS script (written in Python). The drone was controlled via radio by the operator during the research. In the next step, the archived data were processed and filtered. This made it possible to compare the two filters under the same conditions. The raw data were recorded for all degrees of freedom in which the sensors implemented in the flight controller operate. In parallel, through the same script, data were collected concerning the physical position of the frame on which the drone was mounted.
The information about the angular position of the frame was measured by 3 Baumer XX laser distance sensors. The sensors were spaced every 120 degrees ( Figure 1). Each sensor collected data concerning the distance of the ring on which the laser beam fell. The output signal of the sensors is a voltage. The analog signals were processed using ADCs of the STM32 Nucleo-F429ZI development kit. The voltage values were divided by resistive voltage dividers to go from a 0-10 V sensor output range to a 0-3.3 V one, corresponding to the capabilities of the development board. The sensors were powered by an external 12 V power supply. Each voltage divider was made of three 470 Ohm precision resistors. The analog signals were read using a device memory access (DMA) mechanism. The microcontroller was clocked at a maximum frequency of 180 MHz. The analog readings were converted into distance values expressed in millimeters in the main program loop. The ring height was chosen to be within the sensor range of 100-600 mm. The width of the ring was chosen to be able to perform tilt and roll of the drone up to 10 degrees. This is a value consistent with the angular displacement that occurs in drones during flight, and the tests were conducted within this range. The information about the angular position of the frame was measured by 3 Baume XX laser distance sensors. The sensors were spaced every 120 degrees ( Figure 1). Eac sensor collected data concerning the distance of the ring on which the laser beam fell. Th output signal of the sensors is a voltage. The analog signals were processed using ADC of the STM32 Nucleo-F429ZI development kit. The voltage values were divided by resis tive voltage dividers to go from a 0-10 V sensor output range to a 0-3.3 V one, correspond ing to the capabilities of the development board. The sensors were powered by an externa 12 V power supply. Each voltage divider was made of three 470 Ohm precision resistor The analog signals were read using a device memory access (DMA) mechanism. The m crocontroller was clocked at a maximum frequency of 180 MHz. The analog readings wer converted into distance values expressed in millimeters in the main program loop. Th ring height was chosen to be within the sensor range of 100-600 mm. The width of th ring was chosen to be able to perform tilt and roll of the drone up to 10 degrees. This is value consistent with the angular displacement that occurs in drones during flight, an the tests were conducted within this range. To convert the values from the three sensors to pitch and roll, the trigonometric rela tionships and the arcus tangent function were used. The pitch is calculated using the fo lowing formula: where: -pitch angle, rotation about the X axis, , , -the height determined by the particular sensors, -the diameter of the circle. The difference in height between the reading of sensor no. 1 and the average of read ings of sensors no. 2 and 3 is divided by the height of an equilateral triangle determine by the sensors. It is a triangle inscribed in a circle ( Figure 2). The pitch angle is determine by relation (1). To convert the values from the three sensors to pitch and roll, the trigonometric relationships and the arcus tangent function were used. The pitch is calculated using the following formula: where: ϕ-pitch angle, rotation about the x axis, l 1 , l 2 , l 3 -the height determined by the particular sensors, d-the diameter of the circle. The difference in height between the reading of sensor no. 1 and the average of readings of sensors no. 2 and 3 is divided by the height of an equilateral triangle determined by the sensors. It is a triangle inscribed in a circle ( Figure 2). The pitch angle is determined by relation (1).  where: -roll angle, rotation about the Y axis. The difference in height between sensor no. 2 and s the equilateral triangle defined by the sensors. The roll a The described calculations were performed in the in the STM32F429 microcontroller. The positions calcu tion were compensated with a logical condition so tha position deviated from the zero value in a direction n the increment, a negative value is returned. The obta system node via ST-link. This is a built-in programmer port. Libraries prepared by the Open Agriculture Foun An ST-link programmer was connected via USB c The roll is determined from the following formula: where: θ-roll angle, rotation about the y axis. The difference in height between sensor no. 2 and sensor no. 3 is divided by the side of the equilateral triangle defined by the sensors. The roll angle is determined by relation (2).
The described calculations were performed in the main loop of the program running in the STM32F429 microcontroller. The positions calculated from the arcus tangent function were compensated with a logical condition so that when the drone is in an angular position deviated from the zero value in a direction not consistent with the direction of the increment, a negative value is returned. The obtained values were sent to the ROS system node via ST-link. This is a built-in programmer along with a serial communication port. Libraries prepared by the Open Agriculture Foundation were used to send the data.
An ST-link programmer was connected via USB cable to the computer on which the roscore unit was running. The rosserial library was used to receive data from the nucleo development board. Data were data published to the topic from which the archiving script subscribed. The same script in parallel subscribed to the data published by the flight controller. The writing to the csv file was carried out line by line. Raw accelerometer and gyroscope data, angular position estimated by the default Kalman filter, arbitrary values from the test-bench collected by the development kit, and timestamp were written. Data recording occurred in real time. The flight controller published the data at 50 Hz. As soon as new data became available, the script archived it along with the corresponding data from the arbitrary test-bench.
The full algorithm of the conducted research is included below (Figure 3).   The above diagram shows the filter coefficient optimization algorithm. The essence of this process is to collect the raw sensor data along with the arbitrary position. Then, optimization (which involves multiple iterations in the computational environment) is performed on the same data. Its effect is to obtain tuned filter coefficients, consistent in type with the filter built into the flight controller. In most flight controllers, the manufacturer's software allows the user to enter their own filter coefficients.

Parameters of Drone
The selected type of drone is a quadrotor. The flight controller used is Pixhawk 2.4.8 to which PX4 software v1.12.0 was uploaded. Communication with the operator is carried out via FrSky RC radio. The drone is powered by four DC brushless motors. The K V constant of the motors, which is the motor speed constant measured in revolutions per minute (RPM) per volt, or radians per volt, is equal to 2300. The sensors are located on the board the flight controller. The drone was rigidly mounted to the aluminum profiles of the test stand ( Figure 4). Roll and pitch are realized by the joint on which the profiles are supported. Rotational movement of the yaw does not take place.
The above diagram shows the filter coefficient optimization algorithm of this process is to collect the raw sensor data along with the arbitrary p optimization (which involves multiple iterations in the computational en performed on the same data. Its effect is to obtain tuned filter coefficients type with the filter built into the flight controller. In most flight controllers turer's software allows the user to enter their own filter coefficients.

Parameters of Drone
The selected type of drone is a quadrotor. The flight controller used is to which PX4 software v1.12.0 was uploaded. Communication with the ope out via FrSky RC radio. The drone is powered by four DC brushless motor stant of the motors, which is the motor speed constant measured in revolutio (RPM) per volt, or radians per volt, is equal to 2300. The sensors are located the flight controller. The drone was rigidly mounted to the aluminum prof stand ( Figure 4). Roll and pitch are realized by the joint on which the pr ported. Rotational movement of the yaw does not take place. The position of the test-bench was leveled in the X and Y axes before th Then, through the QGroundControl software, the zero level was set for th man filter implemented in the PX4 software. Through the mavlink proto controller communicated with the ROS version of Melodic Morenia insta Ubuntu Mate 18.04 operating system.

Drone Sensors
Angular position information is required to stabilize the UAV. This ca indirectly from sensors measuring other values. Popular solutions include ation sensors (accelerometers) and angular velocity sensors (gyroscopes). angular position from the accelerometer, the ground acceleration is used. The position of the test-bench was leveled in the X and Y axes before the tests started. Then, through the QGroundControl software, the zero level was set for the default Kalman filter implemented in the PX4 software. Through the mavlink protocols, the flight controller communicated with the ROS version of Melodic Morenia installed inside the Ubuntu Mate 18.04 operating system.

Drone Sensors
Angular position information is required to stabilize the UAV. This can be provided indirectly from sensors measuring other values. Popular solutions include linear acceleration sensors (accelerometers) and angular velocity sensors (gyroscopes). To obtain the angular position from the accelerometer, the ground acceleration is used. Depending on the position of the accelerometer, it will be distributed across the axes. This requires establishing a base position where the object is parallel to the ground. The premise of the measurement is to detect roll or pitch by determining the deviation from the axis of gravity, which correlates with acceleration due to gravity. The disadvantage of this solution is the influence of other forces that generate linear acceleration. The noise caused is a high-frequency signal. To determine the angular position from the gyroscope, it is necessary to integrate the data obtained from this sensor. Before starting the integration, the angular position must be given as the initial condition for integration. During the process of computing, the data, accumulating small errors (resulting from integration) create a bias of the gyroscope. As a result, as time passes, the calculated outcome may deviate from the true value.
The following sensors are implemented on board the flight controller: L3GD20 [19] is a low power three-axis gyroscope. It is produced by ST microelectronics for navigation systems. The maximum sensitivity is 8.75 mdps (mili degrees per second)/digit. MPU6000 [20] is used as main accelerometer and secondary gyroscope. Depending on the range of measured acceleration, the accuracy is from 2.048 to 16.384 lsb (least significant bit)/g (acceleration expressed in relation to the acceleration due to gravity). The gyroscope in this module is used secondarily. The measurements are used to verify the data from the master module and, in case of discrepancies, represent the reason for rejecting particular samples.
LSM303D [21] is three-dimension accelerometer, used as a secondary 3D magnetometer. A magnetometer is needed for calculation of the yaw angle.
MS5611 [22] is a barometric pressure sensor, the measurements of which are not relevant to the content of this paper.

Types of Filters
To obtain angular position, intermediate data are used by measuring other physical values. From the accelerometer readings, the deviation from the vertical position is determined by measuring the acceleration of the earth. From the trigonometric functions, the pitch and roll of the measurement system relative to the earth system are calculated. When other linear accelerations are involved, the ratio of the contribution of the ground acceleration to the individual accelerometer axes may be disturbed. This effect is called accelerometer noise. To obtain the angular position from the gyroscope readings, the collected data corresponding to the angular velocity in the respective axes must be integrated. The error that occurs in this case is called gyro drift. It is due to the integration process and imperfections in the system, which, with prolonged operation, begin to accumulate with the integration process. To compensate for these errors, digital filters are used (i.e., the complementary filter and the Kalman filter). The authors of this paper chose to consider these two mentioned filters due to their popularity in flight controllers.

Complementary Filter
The complementary filter is used when data come from different channels and sensors [10]. To obtain the final result, part of the data is added ( Figure 5). For every single component, a specified filter (such as LPF (low-pass filter); HPF (high-pass filter)) is used. The specificity of the filter can be described by the formula: To obtain the angular position of the drone, the data from two independent channels are used ( Figure 6). First, data comes from the gyroscope. The obtained value ω, which is the angular velocity, is integrated to the angular position. Then, it is passed through a high-pass filter. Secondly, data come from accelerometer and magnetometer. The pitch and roll are calculated from the acceleration values a (as described in Section 2.2), while the yaw is determined from the reading of the earth's magnetic field m [11]. The data are then passed through a low-pass filter. The LPF transfer function can be represented as: where T is the time constant of inertial component and s is the complex variable. Analogously, according to the principle of the complementary filter, the HPF transfer function can be written as: The specificity of the filter can be described by the formula: To obtain the angular position of the drone, the data from two independent channels are used ( Figure 6). First, data comes from the gyroscope. The obtained value ω, which is the angular velocity, is integrated to the angular position. Then, it is passed through a high-pass filter. Secondly, data come from accelerometer and magnetometer. The pitch and roll are calculated from the acceleration values a (as described in Section 2.2), while the yaw is determined from the reading of the earth's magnetic field m [11]. The data are then passed through a low-pass filter. The specificity of the filter can be described by the formula: To obtain the angular position of the drone, the data from two independent channels are used ( Figure 6). First, data comes from the gyroscope. The obtained value ω, which is the angular velocity, is integrated to the angular position. Then, it is passed through a high-pass filter. Secondly, data come from accelerometer and magnetometer. The pitch and roll are calculated from the acceleration values a (as described in Section 2.2), while the yaw is determined from the reading of the earth's magnetic field m [11]. The data are then passed through a low-pass filter. The LPF transfer function can be represented as: where T is the time constant of inertial component and s is the complex variable. Analogously, according to the principle of the complementary filter, the HPF transfer function can be written as: The parameter for the complementary filter is f 0 which is defined as the cut-off frequency. It determines frequencies for both the low-pass filter and high-pass filter (Figure 7). The parameter for the complementary filter is f0 which is defined as the cut-off frequency. It determines frequencies for both the low-pass filter and high-pass filter (Figure 7). As may be noted in the figure above, by setting a boundary for one basic filter, it is necessary to apply it to the other as well. The optimization of the complementary filter comes down to determining this boundary.

Kalman Filter
The Kalman filter is an algorithm used for multiple measurements that contain inaccuracies, such as statistical noise observed over time. It produces estimates of unknown variable that are more accurate than results based on measurements from a single channel. From the time of its invention until now, the Kalman filter has been refined. There are now many versions of the Kalman filter that are the subject of scientific research [3].
The algorithm operates in a two-steps process. Considering the system as a discretetime model in state space, the following equations can be written [5]: ( ) = · ( ) + ( ) where: ( )-state of the system at time t, -state matrix, -input matrix, ( )-process noise, ( )-system output, The first step is called the time update and it consists in computing the single state prediction (i.e., the a priori estimate and its covariance).
In the next step, the time is increased by one and the algorithm goes on to update the measurement. As may be noted in the figure above, by setting a boundary for one basic filter, it is necessary to apply it to the other as well. The optimization of the complementary filter comes down to determining this boundary.

Kalman Filter
The Kalman filter is an algorithm used for multiple measurements that contain inaccuracies, such as statistical noise observed over time. It produces estimates of unknown variable that are more accurate than results based on measurements from a single channel. From the time of its invention until now, the Kalman filter has been refined. There are now many versions of the Kalman filter that are the subject of scientific research [3].
The algorithm operates in a two-steps process. Considering the system as a discretetime model in state space, the following equations can be written [5]: where: x(t)-state of the system at time t, A-state matrix, B-input matrix, v(t)-process noise, y(t)-system output, C-output matrix, w(t)-measurement noise. The first step is called the time update and it consists in computing the single state prediction (i.e., the a priori estimate and its covariance). where: x(t)-a priori estimate, P(t)-covariance matrix for x, V-covariance matrix for v.
In the next step, the time is increased by one and the algorithm goes on to update the measurement.
where: W-covariance matrix for w, ε(t)-the difference between the most recent measurement and the value expected from state estimate, S-covariance matrix for ε, K(t)-Kalman gain.
Kalman gain decides what effect a new measurement has on the a posteriori estimate of the state versus the a priori estimate. The algorithm repeats its steps alternately. This is shown in Figure 8 [7].
where: W-covariance matrix for w, ε(t)-the difference between the most recent measurement and the value expected from state estimate, S-covariance matrix for ε, ( )-Kalman gain.
Kalman gain decides what effect a new measurement has on the a posteriori estimate of the state versus the a priori estimate. The algorithm repeats its steps alternately. This is shown in Figure 8   Due to the nonlinearity in the measuring system associated with the readout of the speed data, an EKF (extended Kalman filter) is a frequently used form of the Kalman filter. It is presented in detail in [23]. For a nonlinear system, the matrices appearing in Equations (6) and (7) are replaced with a set of nonlinear functions. The equations then have the following form: where: ( )-input vector, , ℎ-sets of nonlinear functions describing state and input dependencies.
In the case under consideration, the input vector is a measurement vector and can be represented as [6]: where: Due to the nonlinearity in the measuring system associated with the readout of the speed data, an EKF (extended Kalman filter) is a frequently used form of the Kalman filter. It is presented in detail in [23]. For a nonlinear system, the matrices appearing in Equations (6) and (7) are replaced with a set of nonlinear functions. The equations then have the following form: where: u(t)-input vector, f , h-sets of nonlinear functions describing state and input dependencies. In the case under consideration, the input vector is a measurement vector and can be represented as [6]: where: b a t -the measurements of the linear accelerations, obtained from a triaxial accelerometer, b w t -the three angular velocity measurements obtained from a triaxial rate-gyro. Functions f , h must be differentiable after all parameters. This makes it possible to linearize the equations. In order to carry out this process, the above-mentioned functions should be developed into Taylor series. It is assumed that the obtained matrices A, B, C, D approximate the behavior of the studied nonlinear system in the neighborhood of the given operating point (x', u'). To obtain the desired matrices, it is necessary to determine the partial derivatives of the functions from the nonlinear model: The EKF equations differ slightly from those of the linear Kalman filter and can be expressed as follows: Equations (10)- (14) corresponding to state updates can be reformulated as follows: These equations are well known. Detailed considerations for the EKF can be found in the publications [4,23].

Data Processing
The MATLAB 2021a environment was used for data processing. Archived data were collected to 12 precision decimal places. Ready-made filters available from version 2019b were used to process the data. The arbitrary values are the data obtained from the measuring station.
The test procedure carried out in this paper to obtain the optimal filter and to improve the embedded filter included the following operations:  Figures 9 and 10 show the angular position calculated from the data from the individual sensors. It can be noticed that the position obtained from the accelerometer looks much noisier in comparison to the position from the gyroscope. There are a lot of peaks in the figure, and the estimation run is very dynamically changed. It was assumed that the initial position of the gyroscope, necessary for the integration process, should be taken from the accelerometer.  Figures 9 and 10 show the angular position calculated from the data from the individual sensors. It can be noticed that the position obtained from the accelerometer looks much noisier in comparison to the position from the gyroscope. There are a lot of peaks in the figure, and the estimation run is very dynamically changed. It was assumed that the initial position of the gyroscope, necessary for the integration process, should be taken from the accelerometer.  Both figures above are taken from the raw data. They are provided to show how the angle estimation task is handled by the various sensors. In the next steps, the obtained estimates will be compared with the results obtained from the filters.

Complementary Filter
The complementary filter was designed using the ready-made 'complementaryFilter' object [24]. this corresponds to the theoretical considerations described in Section 3.1. The data obtained from the filter were converted to Euler angles and are presented in Figure 11.  Figures 9 and 10 show the angular position calculated from the data from the individual sensors. It can be noticed that the position obtained from the accelerometer looks much noisier in comparison to the position from the gyroscope. There are a lot of peaks in the figure, and the estimation run is very dynamically changed. It was assumed that the initial position of the gyroscope, necessary for the integration process, should be taken from the accelerometer.  Both figures above are taken from the raw data. They are provided to show how the angle estimation task is handled by the various sensors. In the next steps, the obtained estimates will be compared with the results obtained from the filters.

Complementary Filter
The complementary filter was designed using the ready-made 'complementaryFilter' object [24]. this corresponds to the theoretical considerations described in Section 3.1. The data obtained from the filter were converted to Euler angles and are presented in Figure 11. Both figures above are taken from the raw data. They are provided to show how the angle estimation task is handled by the various sensors. In the next steps, the obtained estimates will be compared with the results obtained from the filters.

Complementary Filter
The complementary filter was designed using the ready-made 'complementaryFilter' object [24]. this corresponds to the theoretical considerations described in Section 3.1. The data obtained from the filter were converted to Euler angles and are presented in Figure 11.

Extended Kalman Filter
The EKF was designed using the 'insfilterNonholonomic' object [25]. This object is a specialized version of the EKF, dedicated to work with data coming from IMU sensors. It has a 'tune' method allowing one to optimize the filter parameters referring to arbitrary data. The data obtained from this filter are shown in Figure 12.

Comparison between Filters
To compare the filters, apart from those designed in MATLAB environment, a default filter implemented in PX4 software is presented. It is an extended Kalman filter. In Figures  13 and 14, a summary of these filters together with the arbitrary position obtained from the test-bench may be seen.

Extended Kalman Filter
The EKF was designed using the 'insfilterNonholonomic' object [25]. This object is a specialized version of the EKF, dedicated to work with data coming from IMU sensors. It has a 'tune' method allowing one to optimize the filter parameters referring to arbitrary data. The data obtained from this filter are shown in Figure 12.

Extended Kalman Filter
The EKF was designed using the 'insfilterNonholonomic' object [25]. This object is a specialized version of the EKF, dedicated to work with data coming from IMU sensors. It has a 'tune' method allowing one to optimize the filter parameters referring to arbitrary data. The data obtained from this filter are shown in Figure 12.

Comparison between Filters
To compare the filters, apart from those designed in MATLAB environment, a default filter implemented in PX4 software is presented. It is an extended Kalman filter. In Figures  13 and 14, a summary of these filters together with the arbitrary position obtained from the test-bench may be seen.

Comparison between Filters
To compare the filters, apart from those designed in MATLAB environment, a default filter implemented in PX4 software is presented. It is an extended Kalman filter. In Figures 13 and 14, a summary of these filters together with the arbitrary position obtained from the test-bench may be seen.

Results
The criterion adopted to evaluate the filters is the integral absolute error (IAE). Est mations from raw data from both sensors, a complementary filter, an EKF implemente in MATLAB, and an EKF from PX4 software were evaluated. The results are presented Table 1.

Results
The criterion adopted to evaluate the filters is the integral absolute error (IAE). E mations from raw data from both sensors, a complementary filter, an EKF implemen in MATLAB, and an EKF from PX4 software were evaluated. The results are presented Table 1.

Results
The criterion adopted to evaluate the filters is the integral absolute error (IAE). Estimations from raw data from both sensors, a complementary filter, an EKF implemented in MATLAB, and an EKF from PX4 software were evaluated. The results are presented in Table 1. Definitely the worst in the comparison are the results estimated only on the basis of the reading from the accelerometer. This is due to the accelerometer noise. A significant improvement can be seen in the results obtained from integrating the gyroscope readings. It should be recalled that the initial condition for integration (i.e., the initial position of the drone) was assumed on the basis of the first reading from the accelerometer. Without this, obtaining the angular position would have been impossible, or it would have been necessary to assume that the drone always takes off from a specific position, which in reality is not very realistic. The best physical position was calculated by extended Kalman filters. The extended Kalman filter implemented in the PX4 firmware contains process and measurement noise covariance matrices that do not take into account the drone's physical parameters. These parameters can be changed in the configuration structure when uploading the software to the flight controller. This requires a change in the source code and a build for a specific controller model. A simpler method is to find and change the desired parameters in the QGroundControl software dedicated to the configuration of flight controllers running under PX4 control. During the research work, QGroundControl software version 4. Definitely the worst in the comparison are the results estimated only on the ba the reading from the accelerometer. This is due to the accelerometer noise. A signi improvement can be seen in the results obtained from integrating the gyroscope read It should be recalled that the initial condition for integration (i.e., the initial position drone) was assumed on the basis of the first reading from the accelerometer. Withou obtaining the angular position would have been impossible, or it would have been n sary to assume that the drone always takes off from a specific position, which in rea not very realistic. The best physical position was calculated by extended Kalman f The extended Kalman filter implemented in the PX4 firmware contains process and urement noise covariance matrices that do not take into account the drone's physic rameters. These parameters can be changed in the configuration structure when up ing the software to the flight controller. This requires a change in the source code build for a specific controller model. A simpler method is to find and change the de parameters in the QGroundControl software dedicated to the configuration of fligh trollers running under PX4 control. During the research work, QGroundControl sof    After transferring the filter parameters from the MATLAB script to PX4 software, running the experiment on the test bench, re-archiving the data, processing the raw readings, and filtering with the previously designed EKF, there is no difference in the comparison of the estimation between the filter built in PX4 software and the filter designed in the MATLAB environment.
The integral absolute error values are close to being the same Table 2. The difference in values is less than 1% and can be considered negligible.

Discussion
The paper presents a comparison of available methods of filtering signals from the most popular sensors used in unmanned aerial vehicles. Its purpose was to develop and investigate an algorithm for improving angular position filtration in a real drone. The research was conducted on a drone that can be self-assembled from commonly available and affordable components. As can be seen from Table 1, using only one sensor is not sufficient to obtain reliable data. It is necessary to use filtering. The authors of this study showed that the extended Kalman filter is clearly preferable to the complementary filter. It reproduces the course of changes in the angular position of the real drone much better. Only during the biggest angular changes in peaks was the complementary filter closer to the real value. As can be seen from the data presented in Table 1, the EKF after tuning in MATLAB has the smallest IAE error. The development of embedded systems has made the extended Kalman filter, despite its greater computational complexity, a solution that does not overload the processing power of flight controllers.
Other researchers may use this work to practically improve the filter performance in their drones by reflecting drone station and our procedure presented at the beginning of Section 4. The authors recommend that anyone wishing to take advantage of the presented results perform the individual steps on their own object. Due to the physical specifications of the real quadrotor object, including sensors, it is not suitable to compare the results After transferring the filter parameters from the MATLAB script to PX4 software, running the experiment on the test bench, re-archiving the data, processing the raw readings, and filtering with the previously designed EKF, there is no difference in the comparison of the estimation between the filter built in PX4 software and the filter designed in the MATLAB environment.
The integral absolute error values are close to being the same Table 2. The difference in values is less than 1% and can be considered negligible.

Discussion
The paper presents a comparison of available methods of filtering signals from the most popular sensors used in unmanned aerial vehicles. Its purpose was to develop and investigate an algorithm for improving angular position filtration in a real drone. The research was conducted on a drone that can be self-assembled from commonly available and affordable components. As can be seen from Table 1, using only one sensor is not sufficient to obtain reliable data. It is necessary to use filtering. The authors of this study showed that the extended Kalman filter is clearly preferable to the complementary filter. It reproduces the course of changes in the angular position of the real drone much better. Only during the biggest angular changes in peaks was the complementary filter closer to the real value. As can be seen from the data presented in Table 1, the EKF after tuning in MATLAB has the smallest IAE error. The development of embedded systems has made the extended Kalman filter, despite its greater computational complexity, a solution that does not overload the processing power of flight controllers.
Other researchers may use this work to practically improve the filter performance in their drones by reflecting drone station and our procedure presented at the beginning of Section 4. The authors recommend that anyone wishing to take advantage of the presented results perform the individual steps on their own object. Due to the physical specifications of the real quadrotor object, including sensors, it is not suitable to compare the results between different objects or between object and simulation. The MATLAB program was used to process the data collected from the real object. Then, based on multiple iterations of filtering processes on the same data, the best optimized filter was selected from those available in the flight controllers. A further research direction projected by the authors is to study the optimization of individual flying units and the effect of unit improvement on swarm behavior during a cooperative task of multiple UAVs.

Conclusions
This article shows how the filter embedded in the flight controller software can be improved. Popular flight controller software such as Ardupilot and PX4, have implemented filters whose parameters can be changed by the user. Based on arbitrary angular position data, a "tune" function was used to optimize the filter coefficients. Angular position estimation of the real drone has been improved, which was our goal.