Quadcopters, as a class of unmanned aerial vehicles (UAVs), have garnered significant attention due to their versatility in applications such as infrastructure inspection, surveillance, and delivery. Their ability to hover, maneuver in tight spaces, and carry payloads makes them ideal for tasks requiring precise trajectory tracking and attitude control. However, the inherent nonlinearities, underactuation, and susceptibility to external disturbances like wind gusts pose substantial challenges for control system design. Traditional control methods, including proportional-integral-derivative (PID), adaptive control, and sliding mode control, have been employed with varying degrees of success. Yet, these approaches often struggle with handling state and input constraints directly or may require linearization that compromises performance in highly dynamic environments. This paper addresses these limitations by developing a comprehensive nonlinear dynamic model for a quadcopter and designing a controller based on a nonlinear model predictive control (NMPC) algorithm. The NMPC framework naturally incorporates input and output constraints while providing robustness against disturbances, enabling accurate trajectory tracking and attitude stabilization. Through numerical simulations, the effectiveness of the proposed method is demonstrated for complex flight paths, highlighting its potential for real-world quadcopter operations.
The quadcopter dynamic model is derived using a Newton-Euler formulation, considering the forces and moments generated by the four rotors. The quadcopter is assumed to be a rigid body with symmetric structure, and its center of mass coincides with the geometric center. The body-fixed frame is defined with the x-axis forward, y-axis to the right, and z-axis downward, while the inertial frame is used for position and orientation representation. The rotational dynamics are governed by the moments around the three axes, and the translational dynamics account for the total thrust and gravitational forces. The control inputs are the squared angular velocities of the four rotors, denoted as $U = [w_1^2, w_2^2, w_3^2, w_4^2]^T$, which generate lift and torques. The thrust force $F_z$ and moments $M_x$, $M_y$, $M_z$ are expressed as:
$$F_z = \alpha \sum_{i=1}^{4} w_i^2$$
$$M_x = L \alpha (w_4^2 – w_2^2)$$
$$M_y = L \alpha (w_1^2 – w_3^2)$$
$$M_z = \beta (w_1^2 – w_2^2 + w_3^2 – w_4^2)$$
where $\alpha$ is the thrust coefficient, $\beta$ is the drag coefficient, and $L$ is the distance from the rotor center to the quadcopter’s center of mass. The full nonlinear dynamics of the quadcopter, including position and orientation, are described by the following equations:
$$\ddot{x} = \frac{1}{m} [\cos\phi \sin\theta \cos\psi + \sin\phi \sin\psi] F_z$$
$$\ddot{y} = \frac{1}{m} [\cos\phi \sin\theta \sin\psi – \sin\phi \cos\psi] F_z$$
$$\ddot{z} = \frac{1}{m} [\cos\phi \cos\theta] F_z – g$$
$$\ddot{\phi} = \frac{1}{I_x} [\dot{\theta} \dot{\psi} (I_y – I_z) + M_x]$$
$$\ddot{\theta} = \frac{1}{I_y} [\dot{\phi} \dot{\psi} (I_z – I_x) + M_y]$$
$$\ddot{\psi} = \frac{1}{I_z} [\dot{\phi} \dot{\theta} (I_x – I_y) + M_z]$$
Here, $m$ is the mass of the quadcopter, $g$ is the gravitational acceleration, and $I_x$, $I_y$, $I_z$ are the moments of inertia about the respective axes. The state vector is defined as $X = [x, y, z, \phi, \theta, \psi, \dot{x}, \dot{y}, \dot{z}, \dot{\phi}, \dot{\theta}, \dot{\psi}]^T$, and the input vector is $U = [w_1^2, w_2^2, w_3^2, w_4^2]^T$. This model captures the essential nonlinearities and couplings inherent in quadcopter dynamics, serving as the foundation for the NMPC design.

The parameters used in the quadcopter model are summarized in the table below, which are typical for a medium-sized quadcopter and used in subsequent simulations:
| Parameter | Symbol | Value | Unit |
|---|---|---|---|
| Mass | $m$ | 2.0 | kg |
| Gravity | $g$ | 9.81 | m/s² |
| Moment of inertia (x-axis) | $I_x$ | 1.2 | kg·m² |
| Moment of inertia (y-axis) | $I_y$ | 1.2 | kg·m² |
| Moment of inertia (z-axis) | $I_z$ | 2.3 | kg·m² |
| Rotor distance | $L$ | 0.25 | m |
| Thrust coefficient | $\alpha$ | 1.0 | N·s² |
| Drag coefficient | $\beta$ | 0.2 | N·m·s² |
The nonlinear model predictive control algorithm is designed to handle the quadcopter’s trajectory tracking and attitude control problem. NMPC leverages the nonlinear dynamic model to predict future states over a finite horizon and computes optimal control inputs by minimizing a cost function subject to constraints. The discrete-time nonlinear system is represented as:
$$X(k+1) = f(X(k), U(k))$$
where $f(\cdot)$ is the nonlinear state transition function derived from the continuous-time dynamics using a suitable discretization method, such as Euler integration with sampling time $T$. The cost function $J$ is formulated to penalize deviations from the reference trajectory and excessive control efforts:
$$J = \sum_{i=1}^{N} \left\| X_p(k+i) – X_r(k+i) \right\|_Q^2 + \sum_{j=1}^{N} \left\| U(k+j-1) \right\|_R^2$$
Here, $N$ is the prediction horizon, $X_p(k+i)$ is the predicted state at step $k+i$, $X_r(k+i)$ is the reference state, and $Q$ and $R$ are positive definite weighting matrices for states and inputs, respectively. The norms are weighted Euclidean norms, i.e., $\left\| e \right\|_Q^2 = e^T Q e$. The first term ensures accurate tracking, while the second term regularizes the control inputs to avoid actuator saturation. Constraints are incorporated to reflect physical limits, such as minimum and maximum rotor speeds:
$$U_{\min} \leq U(k) \leq U_{\max}$$
where $U_{\min}$ and $U_{\max}$ are vectors defining the lower and upper bounds for each rotor input. For the quadcopter, typical constraints might include $0 \leq w_i^2 \leq w_{\max}^2$ to prevent negative thrust and limit maximum motor speed. The NMPC problem is solved online at each sampling instant using sequential quadratic programming (SQP), which iteratively approximates the nonlinear optimization problem as a series of quadratic programs. The first element of the optimal control sequence $U^*(k)$ is applied to the quadcopter, and the process repeats in a receding horizon fashion. This approach allows the quadcopter to adapt to disturbances and model uncertainties while maintaining constraint satisfaction.
The weighting matrices $Q$ and $R$ are tuned to balance tracking performance and control effort. For instance, $Q$ can be chosen as a diagonal matrix with larger weights on position states to prioritize trajectory tracking, while $R$ penalizes aggressive control actions. The prediction horizon $N$ and sampling time $T$ are selected based on the system’s dynamics and computational capabilities. A longer horizon improves performance but increases computational load, whereas a shorter horizon may lead to myopic control. The table below summarizes the NMPC parameters used in the simulations:
| Parameter | Symbol | Value |
|---|---|---|
| Prediction horizon | $N$ | 18 |
| State weight matrix | $Q$ | $\text{diag}(5, 5, 5, 1, 1, 1)$ |
| Input weight matrix | $R$ | $\text{diag}(0.1, 0.1, 0.1, 0.1)$ |
| Sampling time | $T$ | 0.1 s |
| Minimum input | $U_{\min}$ | $[0, 0, 0, 0]^T$ |
| Maximum input | $U_{\max}$ | $[100, 100, 100, 100]^T$ |
To validate the proposed NMPC-based controller, numerical simulations are conducted in MATLAB for two distinct reference trajectories: a descending spiral and a horizontal “8” shape. The quadcopter starts from initial conditions $X(0) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]^T$, and the simulation time is 30 s with a step size of 0.1 s. The first trajectory, a descending spiral, is defined by:
$$x_r(t) = \sin(t), \quad y_r(t) = \cos(t), \quad z_r(t) = t$$
This path tests the quadcopter’s ability to track a three-dimensional curve with continuous variations in position and orientation. The tracking results show that the quadcopter closely follows the reference, with position errors converging within 3 s and remaining below 0.05 m. The control inputs, i.e., the squared rotor speeds, are constrained within 100 (corresponding to a maximum speed of 10 rad/s for each rotor), demonstrating effective input management. The second trajectory, a horizontal “8” shape, is given by:
$$x_r(t) = \sin(t), \quad y_r(t) = \sin(t) \cos(t), \quad z_r(t) = 1$$
This path evaluates performance in a planar maneuver with constant altitude. The quadcopter achieves accurate tracking, with errors similarly bounded and rapid convergence. To assess robustness, a disturbance in the form of a step signal with amplitude 5 is introduced at 15 s to simulate a wind gust. The quadcopter quickly recovers and returns to the reference trajectory, highlighting the disturbance rejection capability of the NMPC controller. The following table summarizes the performance metrics for both trajectories under nominal and disturbed conditions:
| Trajectory | Condition | Max Position Error (m) | Settling Time (s) | Control Effort (Norm of U) |
|---|---|---|---|---|
| Descending Spiral | Nominal | 0.048 | 2.8 | 45.2 |
| Horizontal “8” | Nominal | 0.042 | 2.5 | 38.7 |
| Horizontal “8” | With Disturbance | 0.055 | 3.2 | 52.1 |
The control inputs for the quadcopter rotors during the simulations are plotted and analyzed to ensure they remain within the specified constraints. For the descending spiral, the inputs vary smoothly to generate the required thrust and torques, while for the “8” shape, the inputs exhibit periodic patterns corresponding to the trajectory’s curvature. Under disturbance, the inputs temporarily increase to counteract the effect but return to nominal levels once the quadcopter stabilizes. The NMPC formulation effectively handles the nonlinear dynamics and constraints, providing a robust solution for quadcopter control. The use of SQP for online optimization ensures real-time feasibility, though computational load may be a consideration for very long horizons or fast sampling rates.
In conclusion, this paper presents a nonlinear model predictive control approach for quadcopter trajectory tracking and attitude control. The comprehensive dynamic model captures the essential nonlinearities, and the NMPC controller incorporates state and input constraints while offering disturbance rejection. Simulations on complex trajectories demonstrate high accuracy and robustness, with errors below 0.05 m and rapid convergence. Compared to traditional methods, NMPC avoids linearization errors and directly handles constraints, making it suitable for real-world quadcopter applications. Future work will focus on reducing computational complexity through efficient optimization algorithms and extending the framework to multi-quadcopter systems or scenarios with obstacles. The proposed method provides a solid foundation for advanced quadcopter operations in dynamic environments.
