Prototyping a predictive maintenance system for your quadrotor UAV with Long Short Term Memory Neural Network (LSTM-NN)

Nabila Zahra
7 min readMar 6, 2021

As a part of my undergrad thesis, I and my thesis-partner developed a prototype of an end-to-end predictive maintenance system for Unmanned Aerial Vehicles (UAV) or drone. Though our work was built on the focus of only identifying and predicting faults because of shaft displacement in the propulsion system, it's widely accepted to be the most common fault in rotating machineries. In this article, I would like to tell you how you can easily implement this at home to your drone, using accelerometer and any data acquisition/logging tool that you have. The full code can be accessed in the github repo here.

Imagine you're flying your drone around, in far height, and its propulsion system suddenly fails to function properly. What would happen? Your drone could free fall, damaging all parts of the drone, although the original fault only happened in a small but critical part —the propulsion system. The drone propulsion system consists of a motor and a propeller. Based on this drone risk report, 50% of reported drone accidents were caused by machine failures, with almost 40% of the failures happened in the propulsion system. This is why it’s very important to prevent machine failures in drones' propulsion system before any fatal fault occurs. One of the most efficient way of preventing machine failures is by implementing the predictive maintenance strategy, where we predict the machine's Remaining Useful Life (RUL) with the objective to have the maintenance just before the fatal failure occurs. With this strategy, we could minimise the machine's downtime and the maintenance cost, while also maximises the machine lifetime to the fullest. We will be using the Long Short Term Memory (LSTM) Neural Network for the time series prediction to infer the drone's propulsion system RUL.

The Set Up

The fault type that we will try to predict the occurrence of is shaft displacement that is induced by mass imbalance in the propulsion system. This can easily be detected by a common condition monitoring parameter for rotating machinery, that is vibration. In the set up, we used MPU6050 as the accelerometer that measures the vibration of the propulsion system, and Raspberry Pi 2B as the data logger of the vibration data into a locally hosted database. To model the degradation process of the propulsion system, in each round of harvesting the training data we will induce a mass imbalance in the system by attaching an electrical tape to the motor. The proportion of the mass imbalance is up to you as long as it's proportional in each iteration of data harvest. In our experiment, we used a standardised 1x1 electrical tape as one level of mass imbalance.

The experiment set up

For the data acquisition we use 2 accelerometers where one is put on a normal conditioned motor and the other is put on where we will gradually adding mass imbalance at. In each iteration of data harvest, we fly the drone around a few times then add more level of mass imbalance until the drone stability is no longer safe for flight, observed by its ability to reach the height we commanded. If it can't reach the target height, then the drone has reached the maximum level of mass imbalance. We did the experiment up to 6 levels of mass imbalance with at least 3 lap maneuvers in each iteration until we observed the drone reached the maximum level. Each lap should at least lasts for 6 minutes.

The code to retrieve the acceleration data:

Retrieving the acceleration data from MPU6050 with Raspberry Pi

Processing the data

After successfully logging the vibration data of both motors, we simulate the lifetime of the propulsion system by treating the data retrieved as the degradation process of the propulsion system over time by stitching data from each iteration. We label the data with the maximum level of imbalance as the point of failure. Separate 80% of the data to generate at least one lifetime data for training, and the rest 20% for at least one lifetime data for testing. It's better to generate more than one of lifetime dataset for training, by randomising the data that get picked from each iteration. For example, if you did 3 laps for 6 level of iteration, then stitch 1 lap data from each iteration to generate the lifetime data for training, that leaves us with 2 laps data for each iteration. We can generate at least 10 lifetime dataset for training by picking different combination of the laps from each iteration.

Generate lifetime dataset from from vibration data stored in dataframe df
Lifetime dataset illustration with 6 levels of mass imbalance. X axis is time in (minute*100), y axis can be ignored.

After generating the lifetime datasets, we will transform or aggregate the datasets from raw vibration data into time domain features. The time domain features are Skewness, Kurtosis, RMS, Peak-to-Peak (P2P), and Crest Factor (CF). Each of the time domain features has the characteristic that could depict and amplify degradation process over time, that would help our LSTM model learns the data better. We aggregate the vibration data with the time window of 1 second to the time domain features.

As some works have stated that using Principal Component Analysis (PCA) on the statistical features can result in a dimensionless Health Indicator (HI) that is more anticipative in predicting faults, from the 5 time domain features, we then transform the data using PCA dimensionality reduction technique to generate one dimensionless Health Indicator of the propulsion system. We can see that the HI generated by PCA depicts the degradation of the propulsion system better than the raw time domain features.

5 time domain features and PCA transformation result

Modelling

The dimensionless HI will then be used as the input of the LSTM model to predict the RUL of the propulsion system. We use LSTM because of its capability to learn the relation between subsequent data due to the memory gate in its architecture. But first, we need to define what is the RUL first.

Based on the picture, we define the RUL as the time delta between the current time and the time when the HI surpasses the machine health threshold, that we have set earlier. Implementing the concept of predictive maintenance, we will use the real HI data in the last minute to predict the HI data in the next minutes until it surpasses the threshold and gives us the RUL.

We then reshape the HI data to the desirable dimension input of LSTM, with these functions:

We then build the LSTM Model with these short lines of code:

Where the LSTM has 2 hidden layers with the activation function of ReLU. After training the LSTM NN model, we iterate over the test dataset as the input to the model and observe the output over time:

We can see that from the graph, although in the beginning the model predicted the failure time too soon, as the model learns more over time, it could anticipatively predict the failure time and RUL with small error. Though in the predictive maintenance context, early predictions are better than of late predictions. The overall MAE for the RUL predicted by the model is 0,078 seconds, which is very acceptable for a prototype.

Congratulations, you just built a prototype of a predictive maintenance system for UAV! The next step would be to collect the appropriate data needed to develop the prototype to a ready-to-be-implemented system by running a run-to-failure experiment, though it might mean sacrificing your drone ;)

References:

(Showing only the 5 most relevant)

  1. Federal Aviation Administration, Aerospace Forecast 2017–2037
  2. A. Susini, “A Technocritical Review of Drones Crash Risk Probabilistic Consequences and its Societal Acceptance”, Risk Information Management, RISK Models and Applications Conference 2014 Berlin, vol. 7, pp. 27–38, 2014.
  3. A. Bondyra, P. Gasior, S. Gardecki and A. Kasiński, “Fault diagnosis and condition monitoring of UAV rotor using signal processing,” 2017 Signal Processing: Algorithms, Architectures, Arrangements, and Applications (SPA), Poznan, pp. 233–238, 2017.
  4. M. D. Anis, “Towards Remaining Useful Life Prediction in Rotating Machine Fault Prognosis: An Exponential Degradation Model,” 2018 Condition Monitoring and Diagnosis (CMD), Perth, WA, pp. 1–6, 2018.
  5. Time Series Prediction with LSTM Recurrent Neural Networks in Python with Keras, https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/

--

--