Attitude Control of Quadcopter Using Double Closed Loop Fuzzy PID

In recent years, quadcopters have gained significant attention due to their simple structure, compact size, low cost, and high reliability. They are widely used in various fields such as aerial photography, border surveillance, environmental monitoring, and search-and-rescue missions. The flight control system of a quadcopter is a key research focus, with attitude control being the core component. However, quadcopters exhibit underactuated and nonlinear control characteristics, making them highly susceptible to external disturbances during flight. This poses substantial challenges for achieving stable and robust attitude control. To address these issues, this paper proposes a double closed-loop fuzzy PID control algorithm for quadcopter attitude control. The approach involves developing position and attitude models for the quadcopter flight control system, designing a dual closed-loop fuzzy PID controller based on PID control principles, and validating its feasibility through Simulink simulations. The results demonstrate that the proposed attitude control system offers excellent rapidity, stability, and robustness, providing a valuable research direction for quadcopter attitude control.

The quadcopter’s mathematical modeling encompasses dynamics and kinematics, with dynamics further divided into position and attitude dynamics, and kinematics into position and attitude kinematics. To simplify the analysis, the following assumptions are made: (1) the quadcopter is a rigid body without elastic deformation, (2) it has a symmetrical structure with the center of mass at the geometric center, (3) air resistance during flight is negligible, and (4) the lift and anti-torque generated by the rotors are proportional to the square of their rotational speeds.

To establish the coordinate systems, the ground coordinate system is fixed to the earth, following the right-hand rule, with the initial forward direction as the X-axis, vertical upward as the Z-axis, and the Y-axis determined accordingly. The body coordinate system is attached to the quadcopter, with its origin at the center, the X-axis pointing forward, the Z-axis upward, and the Y-axis following the right-hand rule. The transformation from the body coordinate system to the ground coordinate system involves rotation matrices. The rotation matrices for rotations around the X, Y, and Z axes are given by:

$$ R_x(\phi) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos(\phi) & \sin(\phi) \\ 0 & -\sin(\phi) & \cos(\phi) \end{bmatrix} $$

$$ R_y(\theta) = \begin{bmatrix} \cos(\theta) & 0 & -\sin(\theta) \\ 0 & 1 & 0 \\ \sin(\theta) & 0 & \cos(\theta) \end{bmatrix} $$

$$ R_z(\psi) = \begin{bmatrix} \cos(\psi) & \sin(\psi) & 0 \\ -\sin(\psi) & \cos(\psi) & 0 \\ 0 & 0 & 1 \end{bmatrix} $$

The composite rotation matrix from the body to the ground coordinate system is:

$$ R_B^E = R_x(\phi) R_y(\theta) R_z(\psi) = \begin{bmatrix} \cos(\theta)\cos(\psi) & \sin(\phi)\sin(\theta)\cos(\psi) – \cos(\phi)\sin(\psi) & \sin(\phi)\sin(\psi) + \cos(\phi)\sin(\theta)\cos(\psi) \\ \cos(\theta)\sin(\psi) & \cos(\phi)\cos(\psi) + \sin(\phi)\sin(\theta)\sin(\psi) & \cos(\phi)\sin(\theta)\sin(\psi) – \sin(\phi)\cos(\psi) \\ -\sin(\theta) & \sin(\phi)\cos(\theta) & \cos(\phi)\cos(\theta) \end{bmatrix} $$

The relationship between the body and ground coordinates is expressed as:

$$ \begin{bmatrix} X_E \\ Y_E \\ Z_E \end{bmatrix} = R_B^E \begin{bmatrix} X_B \\ Y_B \\ Z_B \end{bmatrix} $$

For the position dynamics, the forces and moments acting on the quadcopter are defined as:

$$ U_1 = b(\omega_1^2 + \omega_2^2 + \omega_3^2 + \omega_4^2) $$
$$ U_2 = b(-\omega_2^2 + \omega_4^2) $$
$$ U_3 = b(-\omega_1^2 + \omega_3^2) $$
$$ U_4 = d(\omega_1^2 – \omega_2^2 + \omega_3^2 – \omega_4^2) $$

Here, $U_1$ represents the total lift from the four rotors, while $U_2$, $U_3$, and $U_4$ correspond to the moments for pitch, yaw, and roll, respectively. The parameters $b$ and $d$ are the lift and drag coefficients, and $\omega_i$ denotes the rotational speed of the $i$-th rotor. Applying Newton’s second law, the acceleration in the ground coordinate system is derived as:

$$ \ddot{x} = \frac{U_1 (\sin(\phi)\sin(\psi) + \cos(\phi)\sin(\theta)\cos(\psi))}{m} $$
$$ \ddot{y} = \frac{U_1 (\sin(\phi)\cos(\psi) – \sin(\psi)\sin(\theta)\cos(\phi))}{m} $$
$$ \ddot{z} = \frac{U_1 \cos(\phi)\cos(\theta)}{m} – g $$

For attitude dynamics, the moment balance equations for a rigid body yield:

$$ \begin{bmatrix} M_x \\ M_y \\ M_z \end{bmatrix} = \begin{bmatrix} I_x \dot{p} – (I_y – I_z) q r \\ I_y \dot{q} – (I_z – I_x) r p \\ I_z \dot{r} – (I_x – I_y) p q \end{bmatrix} $$

where $I_x$, $I_y$, and $I_z$ are the moments of inertia about the X, Y, and Z axes, and $p$, $q$, $r$ are the angular velocities. For small angles, the angular velocities relate to the Euler angles as:

$$ \begin{bmatrix} p \\ q \\ r \end{bmatrix} = \begin{bmatrix} \dot{\phi} \\ \dot{\theta} \\ \dot{\psi} \end{bmatrix} $$

Differentiating both sides gives:

$$ \begin{bmatrix} \dot{p} \\ \dot{q} \\ \dot{r} \end{bmatrix} = \begin{bmatrix} \ddot{\phi} \\ \ddot{\theta} \\ \ddot{\psi} \end{bmatrix} $$

The moments can also be expressed in terms of $U_2$, $U_3$, and $U_4$:

$$ \begin{bmatrix} M_x \\ M_y \\ M_z \end{bmatrix} = \begin{bmatrix} U_2 \\ U_3 \\ U_4 \end{bmatrix} $$

Combining these equations, the attitude dynamics are:

$$ \ddot{\phi} = \frac{U_2 + (I_y – I_z) \dot{\theta} \dot{\psi}}{I_x} $$
$$ \ddot{\theta} = \frac{U_3 + (I_z – I_x) \dot{\phi} \dot{\psi}}{I_y} $$
$$ \ddot{\psi} = \frac{U_4 + (I_x – I_y) \dot{\phi} \dot{\theta}}{I_z} $$

The complete position and attitude equations are summarized as:

$$ \begin{aligned}
\ddot{x} &= \frac{U_1 (\sin(\phi)\sin(\psi) + \cos(\phi)\sin(\theta)\cos(\psi))}{m} \\
\ddot{y} &= \frac{U_1 (\sin(\phi)\cos(\psi) – \sin(\psi)\sin(\theta)\cos(\phi))}{m} \\
\ddot{z} &= \frac{U_1 \cos(\phi)\cos(\theta)}{m} – g \\
\ddot{\phi} &= \frac{U_2 + (I_y – I_z) \dot{\theta} \dot{\psi}}{I_x} \\
\ddot{\theta} &= \frac{U_3 + (I_z – I_x) \dot{\phi} \dot{\psi}}{I_y} \\
\ddot{\psi} &= \frac{U_4 + (I_x – I_y) \dot{\phi} \dot{\theta}}{I_z}
\end{aligned} $$

The double closed-loop fuzzy PID control system for the quadcopter consists of an inner loop for attitude control and an outer loop for position control, both utilizing fuzzy PID techniques. The PID controller combines proportional, integral, and derivative actions to regulate the system. The output of a PID controller is given by:

$$ u(t) = K_p \left[ e(t) + \frac{1}{K_i} \int_0^t e(t) \, dt + K_d \frac{de(t)}{dt} \right] $$

where $K_p$, $K_i$, and $K_d$ are the proportional, integral, and derivative gains, respectively. The fuzzy PID controller integrates a fuzzy logic system with the PID controller, comprising fuzzification, fuzzy rule base, fuzzy inference, and defuzzification stages. For fuzzification, the input variables error ($e$) and error change ($ec$) are defined with universes of discourse $[-6, 6]$, and the output variables $K_p$, $K_i$, and $K_d$ have ranges $[16, 30]$, $[0, 1]$, and $[2, 8]$, respectively. Each variable is partitioned into seven fuzzy sets: {NB, NM, NS, ZO, PS, PM, PB}. The triangular membership functions for the input variable $e$ are illustrated below, though the specific plot is not included here.

The fuzzy rules for adjusting $K_p$, $K_i$, and $K_d$ are designed to minimize error and enhance system performance. These rules are summarized in the following table:

$K_p / K_i / K_d$ NB NM NS ZO PS PM PB
NB PB/NB/PS PB/NB/NS PM/NM/NB PM/NM/NB PS/NS/NB ZO/ZO/NM ZO/ZO/PS
NM PB/NB/PS PB/NB/NS PM/NM/NB PS/NS/NM PS/NS/NM ZO/ZO/NS NS/PS/ZO
NS PM/NB/ZO PM/NM/NB PM/NS/NM PS/NS/NM ZO/ZO/NS NS/PM/NS NS/PM/ZO
ZO PM/NM/ZO PM/NM/NS PS/NS/NS ZO/ZO/NS NS/PS/NS NM/PM/NS NM/PM/ZO
PS PS/NM/ZO PS/NS/ZO ZO/ZO/ZO NS/PS/ZO NS/PS/ZO NM/PM/ZO NM/PB/ZO
PM PS/ZO/PB ZO/ZO/PM NS/PS/PM NM/PS/PM NM/PM/PS NM/PB/PS NB/PB/PB
PB ZO/ZO/PB ZO/ZO/PM NM/PS/PM NS/PM/PM NM/PM/PS NB/PB/PS NB/PB/PB

For fuzzy inference, the Mamdani method is employed. The output of the Mamdani fuzzy system is computed as:

$$ f(x) = \frac{\sum_{j=1}^{49} y_j \left( \prod_{i=1}^{n} (b_{ji} + \sigma_i + x_i – x_{ij})^2 \right)}{\sum_{j=1}^{49} \left( \prod_{i=1}^{n} (b_{ji} + \sigma_i + x_i – x_{ij})^2 \right)} $$

where $x = (x_1, x_2, \dots, x_n)$ is the input vector, $y_j$ is the center of the $j$-th rule’s fuzzy set, $b_{ji}$ and $x_{ij}$ are the half-width and center of the triangular antecedent fuzzy number, and $\sigma_i$ is the fuzzification parameter. Defuzzification uses the centroid method:

$$ z_0 = \frac{\sum_{i=0}^{n} \mu_c(z_i) \cdot z_i}{\sum_{i=0}^{n} \mu_c(z_i)} $$

where $z_0$ is the defuzzified output, $z_i$ is the domain value, and $\mu_c(z_i)$ is the membership degree.

The double closed-loop control structure for the quadcopter is implemented with the attitude loop as the inner loop and the position loop as the outer loop. This design leverages the semi-decoupled nature of the quadcopter dynamics, where the attitude affects the position but not vice versa. The inner loop uses fuzzy PID for attitude control, while the outer loop employs fuzzy PID for position control, ensuring robust performance against disturbances.

To validate the proposed control system, simulations are conducted in MATLAB/Simulink. The transfer functions for the quadcopter’s roll, pitch, and yaw channels are derived based on experimental parameters and model functions. For instance, the transfer functions for roll and pitch angles are:

$$ G_1 = G_2 = \frac{50}{0.15s^2 + s} $$

The yaw angle transfer function is:

$$ G_3 = \frac{14.3}{0.15s^2 + s} $$

And the roll and pitch rate transfer functions are:

$$ G_4 = \frac{14.3}{0.15s + 1} $$

The simulation compares double closed-loop control, double closed-loop PID control, and double closed-loop fuzzy PID control. The PID parameters are tuned using the Control System Tuner in MATLAB, with values listed in the following table:

Parameter P I D N
Inner Loop 0.03582 0.04439 0.00095 13.50644
Outer Loop 0.28720 0.47133 0.03246 44.47831

Under no external disturbances, the system responses for the three control methods are analyzed. Key performance metrics such as overshoot, peak time, rise time, and settling time are recorded in the following table:

Control Method Overshoot (%) Peak Time (s) Rise Time (s) Settling Time (s)
Double Closed-Loop 60.4 0.183 0.093 1.520
Double Closed-Loop PID 12.9 1.744 0.68 5.312
Double Closed-Loop Fuzzy PID 20.2 0.003162 0.001834 0.008335

To test robustness, a step disturbance with an amplitude of 0.2 is applied between 3 and 4 seconds. The double closed-loop fuzzy PID control shows minimal overshoot (less than 0.01) and rapid recovery, highlighting its superior disturbance rejection capabilities compared to the other methods. The double closed-loop control exhibits significant oscillations and slow adjustment, while the double closed-loop PID control has reduced overshoot but longer settling times and larger errors under disturbance.

In conclusion, the double closed-loop fuzzy PID control system for quadcopter attitude control demonstrates excellent performance in terms of rapidity, stability, and robustness. The inner attitude loop and outer position loop, both utilizing fuzzy PID control, effectively handle the nonlinear and underactuated characteristics of the quadcopter. Simulation results confirm that this approach outperforms traditional double closed-loop and PID-based methods, making it a promising solution for practical quadcopter applications. Future work could explore real-time implementation and optimization for varying flight conditions.

Scroll to Top