Pattern recognition of UAV flight data based on semi-supervised clustering

UAV is an unmanned aerial vehicle controlled by a remote radio signal or a trajectory planning software carried itself. It is widely used in military, civil and scientific research fields. However, due to the lack of real-time decision-making ability, the UAV has high fault rate. The flight quality assessment of UAV and the construction of fault prediction model can be used for debugging and fault-removing to customer’s aircraft, and also to increase the added value of the civilian UAV products. Before building a fault prediction model, a very important step is to identify the pattern of sampled data. For each group of flight data, the efficiency and accuracy rate of manual quality evaluation and fault identification are not acceptable. Based on the UAV flight data accumulated in the big data platform of an UAV production company in Shenyang, Liaoning Province of China, this paper proposes a semi-supervised clustering technique to do automatic pattern recognition for the sampling points. According to the characteristics of UAV flight data, two different methods are designed to choose initial centroids. Meanwhile, we use the existing normal flight data to train distance thresholds to combine some clusters to eliminate the resulting error clustering. Real flight data or flight test data with manually added labels are used to run the proposed algorithms to verify the recognition results. The experimental results show that the proposed methods greatly improve the efficiency and accuracy of adding precise labels to the historical flight data and play a role in assisting the manual recognition of sampling points while strengthening the management and statistics.


Introduction
The unmanned aerial vehicle (UAV) has a significant improvement in its autonomous ability compared with the manned vehicle, and the ability to survive is greatly strengthened. The UAV can replace humans to complete the task in a bad environment and do not need to worry about the safety of the driver's life, and can perform the task of high risk [1,2,3,4]. So, UAV has been widely applied in military, civilian and scientific research fields. The widely application of UAV requires that it should have a high stability in addition to the efficient completion of the task, that is, the UAV is required to  2 detect the health status of itself and take the corresponding scheme according to the current state [5]. Due to the lack of real-time decision-making ability, the UAV has high fault rate. Fault prediction is the core of UAV health management technology. The flight quality assessment of UAV and the construction of fault prediction model can be used for debugging and fault-removing to customer's aircraft, and also to improve the added value of the civilian UAV products. The methods of fault diagnosis can be divided into model-based and model-free methods. When the model is not accurate, the diagnostic accuracy of the model-based diagnosis method is low, so the diagnosis method that does not rely on the model is getting more and more attention. The advantage of the model-free method is that it does not require the accurate model of the system and has strong self-adaption ability. Its defects are complex construction making it not conducive to practical application [6]. The model-free methods can be classified into data driven, knowledge based and discrete event-based methods. UAV produces a large number of real-time data during the flight process. Using these data and machine learning algorithms, such as neural network-based methods [7,8,9,10], the fault prediction model of aircrafts can be constructed. However, the real-time data produced in the flight process are all unlabelled data, which is not to determine which sampling points in a flight data are fault-free points of normal flight and which are the fault points. So before building a fault prediction model, a very important step is to identify the pattern of the sampling data, which is also partially for improving the whole flight portrait. The interval of sampling points for UAV flight data is usually in milliseconds, for example, the data involved in this paper comes from the big data platform of a Shenyang UAV production company, with the data sampling interval of 2ms. For each group of flight data, the efficiency and accuracy rate of manual quality evaluation and fault identification are not acceptable. All measurement variables have strong correlations, rather than independent characteristics. Therefore, we speculate that the pattern between the variables in normal flight will be different from that after fault happens. Running the proposed clustering methods on one group of flight data, the patterns of the sampling points are distinguished. In this algorithm, two different methods of choosing initial centroids are designed according to the characteristics of UAV flight data. Meanwhile, we use the existing normal flight data to train distance thresholds to combine some clusters to eliminate the resulting error clustering. We use real flight data or flight test data to test our methods. The experimental results show that the proposed methods greatly improve the efficiency and accuracy of adding precise labels to the historical flight data and play a role in assisting the manual recognition of sampling points while strengthening the management and statistics.

Feature selection
The UAV system consists of the controlled object (aircraft), the controller (generally including the measuring element, the sensor) and the actuator (steering engine, propeller). In addition, some other auxiliary positioning components (such as millimeter wave radar) may also be installed on the basis of the specific circumstances. The flight state of the aircraft is automatically determined by the flight control system according to the height or vertical speed of the aircraft. The flight mode of the aircraft can be controlled by the remote controller. The control volume of the remote controller channel is different under different flight modes. According to the flight mode and control volume or certain mission planning, the flight control system calculates the expectation data of location and speed. The controller calculates some control quantities based on these control expectations and current aircraft status and drives the actuator to control the behaviour of the important components, such as accelerometers, gyroscopes, magnetic compass and other ones, so that the aircraft will produce a certain mode of motion. The flight sensors mounted on these components measure these movements, including the pitch angle, the roll angle, the corresponding angular velocity and other variables, and return the calculated values, and the barometer returns the measured height. These values as actual values are compared with expectation values, and some control quantities for adjusting attitude are obtained, and then, the flight is corrected. Therefore, we can filter out the data generated during the The UAV flight control system adopts closed loop control. In different flight modes, the variables involved in the control and calculation are different. There are more than one flight mode switching in one flight data. Therefore, the unified characteristic variables cannot be used. For example, for multi axis UAV, in attitude mode, the index of speed is not involved in calculation and control. For the helicopter's unique mode of non-aileron, the indices of attitude, position and speed can be eliminated. Therefore, this paper runs clustering algorithm respectively on different flight modes.

Data normalization
After manual screening, we have retained a total of 51 characteristic variables for the flight data obtained by the big data platform, all of which are numerical data. Because the range gap between the feature variables is large and the value of each characteristic variable tends to be concentrated, the linear normalization function (Min-Max Scaling) is adopted to convert the original data value to the value in range of [-1,1]: 2.3. Feature merging and feature weighting 2.3.1. Feature merging. Abrupt separation of three axis posture is one common fault which will produce the poor following values of Pitch, Roll and Yaw. According to this, we get the new combination features through the difference between the expectation value and the measure value of Pitch, Roll and Yaw.

Feature weighting.
Another common fault is sensor failure. Data show that about 50% of UAV faults are caused by sensor failures [11]. When the fault is identified manually, it is found that the three-axis data change returned by the accelerometer is the most dominant fault data, which generally indicates that the accelerometer vibration suddenly becomes larger and is the most frequent fault type. Data normalization eliminates the influence of eigenvalues on distance calculation results, thus weakening the change of this mode. We dynamically weighted two sets of three axis data returned by the accelerometer (one set is the fixed data, the other is the shock absorption data), that is, the greater the three axis values of a certain sampling point being higher than its previous sampling point, the higher the weight value added to it.
The weight function is , in which, ' ' represents Euclidean distance function, is the vector composed of the two sets of three axis data. If there is a fault, the acceleration value will change greatly, and the corresponding weight of the point will be bigger. However, this does not distinguish between a real fault and a sharp change in the acceleration caused by the unsuitable operation of human operator, so that these will also be classified as fault data.

Choose the number of clusters
For simplification, we only consider one kind of fault in flight process, or a most significant fault mode, not considering the mode of multiple fault superpositions for now. In fact, through the analysis of the flight data, we find that in the actual flight process, there are few fault superimpositions, even if there is, it is also such a situation that a component fault happens first, and before a short time of crashing, or in the moment of crashing, there may appear several other faults. After fault happens, there are two cases of crashing and non-crashing for the aircraft. We hope to identify the normal flight data points, the fault points (if crashing, also containing the crashing point), and the points after crashing (if crashing). Therefore, the selected number of clusters is 2 (not crashing) and 3 (crashing For the flight data without fault, we pre-train cluster centroids distance threshold, and two clusters with the inter centroid distance less than the threshold are considered to be an error pattern recognition. For example, for a group of flight data without fault, all of the sampling points in theory should belong to the same cluster, but because the minimum clustering number is 2, the clustering results are not reasonable. At this time, the distance between the two cluster centroids is smaller than that of the faultfree points cluster and the fault points cluster and so, we will merge the two clusters.

Choose the initial centroids
We design two methods to choose the initial centroids and run the proposed clustering algorithm respectively: (1) Random selection of k sampling points as the initial centroids; (2) The two adjacent sampling points with the maximum change amplitude of the three axis acceleration values are selected as the first two initial centroids, and the farthest sampling point from the set of the first two initial centroids is selected as the third centroid.
The third centroid in the method (2) determines which is farthest from set S (here composed of the first two initial centroids) by solving the following optimization problems, namely the optimal function: , This optimal function represents: For each points ( , represents the number of the points in set ), let be the smallest distance from to all points of S, is the farthest point from S if .

Flight data pattern discrimination algorithm based on k-means clustering
For the method of randomly selecting k centroids, we run k-means clustering algorithm 10 times on each group of data and get the clustering result with the smallest clustering error. The clustering error is computed by SSE (Sum of Squared Errors), and the distance between sampling points is calculated by Euclidean distance formula. The flight data pattern discrimination algorithm based on k-means clustering is described as PattDiscrBasedonKMeans, in which we suppose there are m kinds of flight modes.

Algorithm. PattDiscrBasedonKMeans( DataSet, GenerateCentMethod, ω):
# DataSet is the data set to be clustered, GenerateCentMethod is the two proposed methods to get the initial centroids, and ω is the centroid distance threshold of merging fault-free data.  In this way, we get the F values between each predefined class and each derived cluster. We generate the weighted mean value of F obtained by the different initial centroids selection methods used in this paper.
F-measure=sum(f[i][j]*the number of points in the predefined ith class) / the number of total points The larger the value is, the better the clustering result is.

Experimental design.
In this paper, we do experiments to 17 groups of fault flight data respectively. Two different methods are used to select the initial centroids, and the corresponding F values are calculated. At the same time, the accuracy of discrimination for the fault occurrence point is calculated.
In the course of the experiment, in accordance with the different flight mode, 29 groups of normal flight data are used to run the clustering algorithm with cluster number of 2. The distance between the two clusters of each flight mode is calculated, and the average value of the distances of the 29 sets of data is taken as the threshold for merging the clusters of the normal sampling points.

Results and analysis
For each group of flight data, we cluster it according to different modes, and then combine and manually correct the clustering results of different flight modes according to the time stamp of the sampling points.
In the clustering results obtained in a certain mode, the cluster composed of those points closer to starting time is classified as the normal class(fault free); the cluster composed of those points closer to ending time is classified as the after-crashing class (if the results are 3 clusters); the other points are classified as the fault class.
Thus, we get the final clustering result of a group of flight data. Then we calculate the values of indexes for the clustering results when running the clustering algorithms with different methods of generating initial centroids: Method1 and Method2, corresponding to the two methods in Section 3.2. The results are shown in Table 2 and Table 3.