Quadrotor UAV Attitude Control with Unbalanced Load Using LSTM-MPC Strategy

In recent years, the advancement in attitude control for quadrotor unmanned aerial vehicles (UAVs) has been significant, with various control strategies such as proportional-integral-derivative (PID) control, adaptive control, model predictive control (MPC), and active disturbance rejection control being employed to manage the quadrotor’s orientation. However, when a quadrotor carries an unbalanced load, the control system becomes highly nonlinear and coupled, introducing uncertainties from external disturbances that compromise stability. This paper addresses these challenges by proposing a novel control strategy that integrates a long short-term memory (LSTM) neural network with MPC, referred to as LSTM-MPC. The LSTM component predicts attitude changes, enhancing the quadrotor’s ability to anticipate errors, while MPC serves as a feedforward control to dynamically optimize inputs, thereby improving precision. Through MATLAB simulations and real-world flight tests on an F450 quadrotor platform, the LSTM-MPC strategy demonstrates superior performance in tracking desired attitude trajectories under unbalanced load conditions, outperforming traditional methods like MPC and fuzzy PID in terms of root mean square error and stability. This approach offers a robust solution for complex scenarios such as agricultural spraying and geographic mapping, where quadrotors often operate with asymmetrical payloads.

The quadrotor UAV is an underactuated and highly coupled nonlinear system that adjusts its attitude by varying the rotational speeds of four propellers to generate thrust in different directions. This enables precise hovering, autonomous flight, and obstacle avoidance. However, when an unbalanced load is attached, the quadrotor’s dynamics become more complex due to shifts in the center of mass and additional load torques, leading to nonlinearities that traditional control methods struggle to handle. In this work, we focus on developing a control strategy that leverages the predictive capabilities of LSTM neural networks and the optimization strengths of MPC to enhance the quadrotor’s attitude control under such conditions. The LSTM-MPC strategy not only predicts future attitude states but also adjusts control inputs in real-time, ensuring robust performance even with significant load imbalances. This integration is particularly beneficial for applications requiring high precision, as it reduces tracking errors and improves overall flight stability.

Mathematical Model of Quadrotor with Unbalanced Load

The attitude dynamics of a quadrotor UAV are derived from its rigid-body motion in a body-fixed coordinate system, with the origin at the center of mass. The standard attitude dynamics model for a quadrotor is given by the following equations:

$$ \dot{\phi} = \left[ M_x – (J_y – J_z) \dot{\theta} \dot{\psi} \right] / J_x $$
$$ \dot{\theta} = \left[ M_y – (J_z – J_x) \dot{\phi} \dot{\psi} \right] / J_y $$
$$ \dot{\psi} = \left[ M_z – (J_x – J_y) \dot{\phi} \dot{\theta} \right] / J_z $$

where $\dot{\phi}$, $\dot{\theta}$, and $\dot{\psi}$ represent the angular accelerations of roll, pitch, and yaw angles in radians per second squared, respectively; $M_x$, $M_y$, and $M_z$ are the moments around the $x_b$, $y_b$, and $z_b$ axes in Newton-meters; and $J_x$, $J_y$, $J_z$ denote the moments of inertia around these axes in kilogram-meter squared. The terms $\dot{\phi}$, $\dot{\theta}$, $\dot{\psi}$ are the angular velocities in radians per second. When an unbalanced load is attached to the quadrotor, the overall dynamics change due to the additional mass and its offset from the center of mass. The moment of inertia of the coupled system, $J_C$, is calculated as:

$$ J_C = J_Q + m_L \left( \| \mathbf{d}_L \|^2 I_3 – \mathbf{d}_L \mathbf{d}_L^T \right) $$

where $J_Q$ is the moment of inertia of the quadrotor alone, $m_L$ is the mass of the load in kilograms, $\mathbf{d}_L$ is the displacement vector of the load’s center of mass relative to the quadrotor’s center of mass, and $I_3$ is the 3×3 identity matrix. The load-induced torque in the body frame is given by:

$$ \mathbf{M}_L = \mathbf{d}_L m_L g $$

where $g$ is the acceleration due to gravity in meters per second squared. Assuming the load is rigidly fixed to the quadrotor frame with no relative motion, the modified attitude dynamics for the coupled system become:

$$ \dot{\phi}_C = \left[ M_x + M_{Lx} – (J_{Cy} – J_{Cz}) \dot{\theta} \dot{\psi} \right] / J_{Cx} $$
$$ \dot{\theta}_C = \left[ M_y + M_{Ly} – (J_{Cz} – J_{Cx}) \dot{\phi} \dot{\psi} \right] / J_{Cy} $$
$$ \dot{\psi}_C = \left[ M_z + M_{Lz} – (J_{Cx} – J_{Cy}) \dot{\phi} \dot{\theta} \right] / J_{Cz} $$

Here, $\dot{\phi}_C$, $\dot{\theta}_C$, and $\dot{\psi}_C$ are the angular accelerations of the coupled system, $M_{Lx}$, $M_{Ly}$, $M_{Lz}$ are the components of the load torque, and $J_{Cx}$, $J_{Cy}$, $J_{Cz}$ are the moments of inertia of the coupled system. This model accounts for the nonlinearities introduced by the unbalanced load, providing a foundation for designing the LSTM-MPC control strategy. The quadrotor’s ability to maintain stability under such conditions depends on accurately predicting and compensating for these dynamic changes.

LSTM-MPC Control Strategy Design

The LSTM-MPC strategy combines the predictive power of LSTM neural networks with the optimization capabilities of MPC to address the nonlinear and coupled nature of quadrotor attitude control under unbalanced loads. The LSTM component forecasts future attitude states based on historical data, while MPC computes optimal control inputs by minimizing a cost function over a prediction horizon. This synergy allows the quadrotor to anticipate errors and adjust inputs dynamically, leading to improved tracking performance and robustness.

LSTM Neural Network Model

The LSTM neural network model consists of an input layer, LSTM layers, fully connected layers, and an output layer. The input layer processes sequence data, such as current attitude angles ($\phi$, $\theta$, $\psi$), angular velocities ($\dot{\phi}$, $\dot{\theta}$, $\dot{\psi}$), and moments ($M_{Cx}$, $M_{Cy}$, $M_{Cz}$), which are preprocessed and reshaped into a tensor format suitable for the LSTM layers. The LSTM layers utilize memory cells and gating mechanisms—input gate, forget gate, and output gate—to capture long-term dependencies in the sequence data. The input gate controls the flow of new information, the forget gate decides what information to discard, and the output gate determines the next hidden state. Mathematically, the LSTM operations can be expressed as:

$$ \mathbf{i}_t = \sigma(\mathbf{W}_{xi} \mathbf{x}_t + \mathbf{W}_{hi} \mathbf{h}_{t-1} + \mathbf{b}_i) $$
$$ \mathbf{f}_t = \sigma(\mathbf{W}_{xf} \mathbf{x}_t + \mathbf{W}_{hf} \mathbf{h}_{t-1} + \mathbf{b}_f) $$
$$ \mathbf{o}_t = \sigma(\mathbf{W}_{xo} \mathbf{x}_t + \mathbf{W}_{ho} \mathbf{h}_{t-1} + \mathbf{b}_o) $$
$$ \mathbf{g}_t = \tanh(\mathbf{W}_{xg} \mathbf{x}_t + \mathbf{W}_{hg} \mathbf{h}_{t-1} + \mathbf{b}_g) $$
$$ \mathbf{c}_t = \mathbf{f}_t \odot \mathbf{c}_{t-1} + \mathbf{i}_t \odot \mathbf{g}_t $$
$$ \mathbf{h}_t = \mathbf{o}_t \odot \tanh(\mathbf{c}_t) $$

where $\mathbf{i}_t$, $\mathbf{f}_t$, $\mathbf{o}_t$ are the input, forget, and output gates at time $t$; $\mathbf{g}_t$ is the candidate cell state; $\mathbf{c}_t$ and $\mathbf{h}_t$ are the cell state and hidden state; $\sigma$ is the sigmoid activation function; $\odot$ denotes element-wise multiplication; and $\mathbf{W}$ and $\mathbf{b}$ are weight matrices and biases, respectively. The fully connected layers then map the LSTM outputs to the target dimensions, using activation functions to extract features, and the output layer produces predictions for the next time step’s attitude angles ($\phi_{\text{next}}$, $\theta_{\text{next}}$, $\psi_{\text{next}}$). For instance, a sample of input and prediction data is shown in Table 1, illustrating how the LSTM model processes sequential data to forecast quadrotor attitudes.

Table 1: Sample Input and Prediction Data for LSTM Model
Index $\phi$ (rad) $\theta$ (rad) $\psi$ (rad) $\dot{\phi}$ (rad/s) $\dot{\theta}$ (rad/s) $\dot{\psi}$ (rad/s) $M_{Cx}$ (N·m) $M_{Cy}$ (N·m) $M_{Cz}$ (N·m) $\phi_{\text{next}}$ (rad) $\theta_{\text{next}}$ (rad) $\psi_{\text{next}}$ (rad)
1 0.1535 0.0834 0.0367 0.2079 0.3835 0.0872 1.1440 0.7144 0.0013 0.1574 0.0756 0.0385
2 0.1574 0.0756 0.0385 0.1885 0.3936 0.0873 1.1757 0.6343 0.0013 0.1610 0.0677 0.0402
3 0.1610 0.0677 0.0402 0.1686 0.4025 0.0873 1.2039 0.5592 0.0009 0.1642 0.0595 0.0420
4 0.1642 0.0595 0.0420 0.1482 0.4104 0.0873 1.2290 0.4915 0.0004 0.1669 0.0513 0.0437
5 0.1669 0.0513 0.0437 0.1275 0.4172 0.0873 1.2512 0.4284 0.0004 0.1693 0.0428 0.0455

Model Predictive Control Method

MPC is a control technique that uses a dynamic model of the system to predict future behavior over a finite horizon and computes optimal control inputs by minimizing a cost function subject to constraints. For a discrete-time system, the state-space representation is:

$$ \mathbf{x}(k+1) = A \mathbf{x}(k) + B \mathbf{u}(k) $$
$$ \mathbf{y}(k) = C \mathbf{x}(k) + D \mathbf{u}(k) $$

where $\mathbf{x}(k)$ is the state vector at time step $k$, $A$ is the state matrix, $B$ is the input matrix, $\mathbf{u}(k)$ is the input vector, $\mathbf{y}(k)$ is the output vector, $C$ is the output matrix, and $D$ is the direct transfer matrix. The cost function for MPC is designed to minimize tracking errors and control efforts:

$$ J = \sum_{k=0}^{n-1} \left[ (\mathbf{y}(k) – \mathbf{y}_{\text{ref}}(k))^T Q (\mathbf{y}(k) – \mathbf{y}_{\text{ref}}(k)) + \mathbf{u}(k)^T R \mathbf{u}(k) \right] $$

where $n$ is the prediction horizon, $\mathbf{y}_{\text{ref}}(k)$ is the reference trajectory at step $k$, $Q$ is a positive semi-definite weight matrix for state errors, and $R$ is a positive definite weight matrix for control inputs. Constraints on inputs and states can be incorporated, and numerical optimization algorithms, such as quadratic programming, are used to solve for the optimal control sequence $\{\mathbf{u}^*_0, \mathbf{u}^*_1, \ldots, \mathbf{u}^*_{n-1}\}$. The first element $\mathbf{u}^*_0$ is applied to the system, and the process is repeated at each time step in a receding horizon fashion. This approach allows the quadrotor to handle nonlinearities and disturbances effectively, especially when combined with LSTM predictions.

Integration of LSTM and MPC

The LSTM-MPC strategy integrates the LSTM neural network as a predictive model within the MPC framework. The overall control loop consists of three main components: the MPC optimizer, the LSTM predictor, and feedback correction. As shown in the control flow, the LSTM model predicts the next output $\mathbf{y}_p(k+1)$ based on the current state $\mathbf{x}(k)$ and input $\mathbf{u}(k)$. The MPC optimizer then uses this prediction to compute the optimal control input $\mathbf{u}(k)$ by minimizing the cost function with respect to the reference $\mathbf{r}(k)$. Feedback correction is applied twice: first, the error $\mathbf{e}_p(k)$ between the actual output $\mathbf{y}(k)$ and the predicted output $\mathbf{y}_p(k)$ is fed back to the LSTM model for online adaptation; second, the error $\mathbf{e}_p(k+1)$ between the reference and the predicted output is used to adjust the MPC optimization. This dual feedback mechanism enhances the quadrotor’s ability to compensate for uncertainties and improves control accuracy. The LSTM-MPC strategy effectively handles the nonlinear dynamics of a quadrotor carrying an unbalanced load by leveraging temporal dependencies and optimization, making it suitable for real-time applications.

Training and Testing of LSTM-MPC Strategy

To ensure the LSTM-MPC strategy achieves high prediction accuracy, it is trained and tested using a dataset of 200 samples, split into a training set (70%) and a testing set (30%). The performance is evaluated using the coefficient of determination ($R^2$), root mean square error ($E_{\text{RMSE}}$), and mean absolute error ($E_{\text{MAE}}$), defined as:

$$ R^2 = 1 – \frac{\sum_{i=1}^{m} (y_i – \hat{y}_i)^2}{\sum_{i=1}^{m} (y_i – \bar{y})^2} $$
$$ E_{\text{RMSE}} = \sqrt{\frac{1}{m} \sum_{i=1}^{m} (y_i – \hat{y}_i)^2} $$
$$ E_{\text{MAE}} = \frac{1}{m} \sum_{i=1}^{m} |y_i – \hat{y}_i| $$

where $m$ is the number of samples, $y_i$ is the true value, $\hat{y}_i$ is the predicted value, and $\bar{y}$ is the mean of true values. The LSTM model is trained to predict the quadrotor’s attitude angles ($\phi$, $\theta$, $\psi$) based on inputs including current angles, angular velocities, and moments. The training and testing results show that the predicted attitudes closely match the true values, as illustrated in the comparison plots. For example, the training set attains high $R^2$ values, low $E_{\text{RMSE}}$, and low $E_{\text{MAE}}$, indicating excellent fit and prediction accuracy. Similarly, the testing set results demonstrate good generalization, with metrics comparable to the training set, as summarized in Table 2 and Table 3.

Table 2: Training Set Evaluation Metrics for LSTM-MPC
Attitude Angle $R^2$ $E_{\text{RMSE}}$ (rad) $E_{\text{MAE}}$ (rad)
Roll ($\phi$) 0.9926 0.0103 0.0084
Pitch ($\theta$) 0.9853 0.0187 0.0140
Yaw ($\psi$) 0.9934 0.0085 0.0073
Table 3: Testing Set Evaluation Metrics for LSTM-MPC
Attitude Angle $R^2$ $E_{\text{RMSE}}$ (rad) $E_{\text{MAE}}$ (rad)
Roll ($\phi$) 0.9838 0.0148 0.0127
Pitch ($\theta$) 0.9776 0.0202 0.0149
Yaw ($\psi$) 0.9869 0.0134 0.0115

The training set results show minimum $R^2$ values of 0.9853, maximum $E_{\text{RMSE}}$ of 0.0187 rad, and maximum $E_{\text{MAE}}$ of 0.0140 rad, indicating high predictive performance. In the testing set, the corresponding metrics are 0.9776 for $R^2$, 0.0202 rad for $E_{\text{RMSE}}$, and 0.0149 rad for $E_{\text{MAE}}$, which are 99.22%, 92.57%, and 93.96% of the training set values, respectively. This consistency confirms the LSTM-MPC strategy’s robustness and generalization capability, making it reliable for predicting quadrotor attitudes in real-world scenarios with unbalanced loads.

Simulation Experiments

Simulation experiments are conducted using MATLAB to evaluate the LSTM-MPC strategy’s performance in tracking desired attitude trajectories for a quadrotor with an unbalanced load. The load is set to 0.9 kg, positioned at coordinates (0.15 m, 0.15 m, 0.05 m) in the body frame, and the environment is assumed free of external disturbances. The LSTM-MPC strategy is compared against fuzzy PID and standard MPC strategies to assess its effectiveness. The attitude tracking results for roll, pitch, and yaw angles are plotted, showing that LSTM-MPC achieves lower tracking errors compared to the other methods. For instance, the average errors for LSTM-MPC are 0.0049 rad, 0.0103 rad, and 0.0011 rad for roll, pitch, and yaw, respectively, whereas fuzzy PID yields 0.0074 rad, 0.0147 rad, and 0.0015 rad, and MPC gives 0.0059 rad, 0.0121 rad, and 0.0013 rad. This demonstrates the superior accuracy of LSTM-MPC in handling the nonlinear dynamics of a quadrotor under load imbalances.

To quantify the performance, the root mean square errors (RMSE) for each control strategy are computed and presented in Table 4. The LSTM-MPC strategy reduces RMSE by 13.33% for roll, 12.31% for pitch, and 11.11% for yaw compared to MPC, and by 14.05%, 25.33%, and 23.81% compared to fuzzy PID, respectively. These improvements highlight the enhanced predictive tracking capability of LSTM-MPC, making it more suitable for complex nonlinear systems like quadrotors with unbalanced loads.

Table 4: Root Mean Square Errors for Attitude Tracking in Simulation
Attitude Angle Fuzzy PID $E_{\text{RMSE}}$ (rad) MPC $E_{\text{RMSE}}$ (rad) LSTM-MPC $E_{\text{RMSE}}$ (rad)
Roll ($\phi$) 0.0121 0.0120 0.0104
Pitch ($\theta$) 0.0229 0.0195 0.0171
Yaw ($\psi$) 0.0021 0.0018 0.0016

Flight Test Experiments

Flight tests are performed using a commercial F450 quadrotor platform to validate the LSTM-MPC strategy under real-world conditions. The quadrotor is equipped with a Flight Control System and Mission Planner ground station for data acquisition. An unbalanced load of 0.6 kg is fixed at the body-frame coordinates (0.15 m, 0.15 m, 0.05 m). The quadrotor’s attitude data, including angles and angular velocities, are collected via an inertial measurement unit (IMU) and GPS modules, transmitted wirelessly to the ground station. The test lasts 60 seconds, divided into flight phases from 0 to 20 seconds and 40 to 60 seconds, and a hovering phase from 20 to 40 seconds. During the flight phases, the desired roll, pitch, and yaw angles are varied to evaluate tracking performance.

The results show that the LSTM-MPC strategy maintains stable attitude control, with actual outputs closely following the desired trajectories. The average errors between actual and desired values are 3.91% for roll, 5.31% for pitch, and 1.10% for yaw, indicating effective compensation for the unbalanced load. The quadrotor exhibits smooth transitions and minimal oscillations, demonstrating the practical viability of LSTM-MPC for enhancing flight stability in applications such as payload delivery or surveillance, where load asymmetries are common.

Conclusion

This paper presents a comprehensive approach to controlling the attitude of a quadrotor UAV under unbalanced load conditions using an LSTM-MPC strategy. By integrating LSTM neural networks for prediction and MPC for optimization, the method effectively addresses the nonlinearities and coupling introduced by asymmetrical payloads. The mathematical model of the quadrotor with an unbalanced load provides a foundation for understanding the dynamic challenges, while the LSTM-MPC strategy leverages temporal dependencies and real-time adjustments to improve control accuracy. Training and testing results confirm the strategy’s high predictive performance and generalization, with evaluation metrics showing strong agreement between predicted and actual attitudes. Simulation experiments demonstrate that LSTM-MPC outperforms fuzzy PID and standard MPC in terms of RMSE reduction for roll, pitch, and yaw angles. Flight tests on an F450 quadrotor platform further validate the strategy, achieving low average errors and stable flight performance. Overall, the LSTM-MPC strategy offers a robust solution for quadrotor attitude control in complex environments, paving the way for advanced applications in fields like agriculture and mapping. Future work could explore adaptive learning techniques and multi-sensor fusion to enhance robustness under varying operational conditions.

Scroll to Top