In this work, we address the inherent challenges in controlling quadrotor drones, which are characterized by strong coupling, underactuation, and significant nonlinearity. These platforms are highly susceptible to disturbances during actual flight, such as wind gusts, which can severely degrade stability and performance. To tackle these issues, we conduct a thorough analysis of the quadrotor drone’s dynamics and propose a novel, robust attitude control algorithm based on the fusion of Sliding Mode Control (SMC) and a Credit-Point Cerebellar Model Articulation Controller (CPCMAC). Furthermore, we design and implement a comprehensive semi-physical simulation system to validate the control strategy, streamline development, and reduce risks associated with real-world testing.
The core motivation stems from the difficulty in developing and verifying flight control systems. Traditional methods, involving isolated component testing and post-assembly integrated flights, are time-consuming and inefficient. In the event of a failure, pinpointing the exact fault is challenging. Current simulation tools often focus on visual immersion or separate dynamic testing from training, failing to provide a unified environment for parameter tuning and algorithm optimization based on the drone’s actual physical characteristics. Our proposed system aims to fill this gap by offering a cohesive platform for design, testing, and performance optimization prior to physical prototyping, thereby minimizing development time and mitigating the risks of crashes.

The overall architecture of our semi-physical simulation system integrates multiple software and hardware components. A ground control station is developed using LabVIEW to provide a user interface for command input and real-time data monitoring. The high-fidelity quadrotor drone dynamics and the proposed control algorithm are modeled and executed in MATLAB/Simulink. These two environments run in conjunction, facilitating data exchange. The core hardware platform is based on an STM32F407 microcontroller, which executes the control logic and communicates with the simulation model, effectively creating a hardware-in-the-loop (HIL) testbed. This setup allows the flight controller algorithm to interact with a simulated yet physically representative model of the quadrotor drone.
Dynamic Modeling of the Quadrotor Drone
Accurate dynamic modeling is fundamental for effective control system design. We begin by defining two coordinate systems: the Earth-fixed inertial frame $E\{X, Y, Z\}$ and the body-fixed frame $B\{x, y, z\}$ attached to the quadrotor drone’s center of mass. The vehicle’s orientation is described by the Euler angles: roll ($\phi$), pitch ($\theta$), and yaw ($\psi$). The rotation matrix $R$ transforming a vector from the body frame to the Earth frame is given by:
$$ R(\phi, \theta, \psi) = R_z(\psi) R_y(\theta) R_x(\phi) = \begin{bmatrix}
c_\psi c_\theta & c_\psi s_\theta s_\phi – s_\psi c_\phi & c_\psi s_\theta c_\phi + s_\psi s_\phi \\
s_\psi c_\theta & s_\psi s_\theta s_\phi + c_\psi c_\phi & s_\psi s_\theta c_\phi – c_\psi s_\phi \\
-s_\theta & c_\theta s_\phi & c_\theta c_\phi
\end{bmatrix} $$
where $c_{\bullet}$ and $s_{\bullet}$ denote cosine and sine functions, respectively.
The translational dynamics of the quadrotor drone, derived from Newton’s second law, account for the total thrust $T_B$, gravity $G$, and aerodynamic drag $f_d$. The equations in the Earth frame are:
$$ \begin{aligned}
m \ddot{x} &= T_B (\cos\phi \sin\theta \cos\psi + \sin\phi \sin\psi) – K_1 \dot{x} \\
m \ddot{y} &= T_B (\sin\phi \sin\theta \cos\psi – \cos\phi \sin\psi) – K_2 \dot{y} \\
m \ddot{z} &= T_B (\cos\phi \cos\theta) – mg – K_3 \dot{z}
\end{aligned} $$
Here, $m$ is the mass, $g$ is gravitational acceleration, $T_B = \sum_{i=1}^{4} K_t \omega_i^2$ is the total thrust from the four rotors with speed $\omega_i$ and thrust coefficient $K_t$, and $K_i$ are drag coefficients.
The rotational dynamics, derived from the Euler equations for a rigid body, are more complex due to gyroscopic effects and coupling. The angular accelerations are:
$$ \begin{aligned}
\ddot{\phi} &= \dot{\theta} \dot{\psi} \left( \frac{I_y – I_z}{I_x} \right) + \frac{J_{TP}}{I_x} \dot{\theta} \Omega + \frac{U_2}{I_x} \\
\ddot{\theta} &= \dot{\phi} \dot{\psi} \left( \frac{I_z – I_x}{I_y} \right) – \frac{J_{TP}}{I_y} \dot{\phi} \Omega + \frac{U_3}{I_y} \\
\ddot{\psi} &= \dot{\phi} \dot{\theta} \left( \frac{I_x – I_y}{I_z} \right) + \frac{U_4}{I_z}
\end{aligned} $$
where $I_x, I_y, I_z$ are moments of inertia, $J_{TP}$ is the rotor inertia, $\Omega = \omega_1 – \omega_2 + \omega_3 – \omega_4$ is the overall rotor speed imbalance, and $U_2, U_3, U_4$ are the control inputs for roll, pitch, and yaw moments, respectively. These moments are generated by differential thrusts:
$$ \begin{aligned}
U_1 &= K_t(\omega_1^2 + \omega_2^2 + \omega_3^2 + \omega_4^2) \\
U_2 &= L K_t (-\omega_2^2 + \omega_4^2) \\
U_3 &= L K_t (\omega_1^2 – \omega_3^2) \\
U_4 &= K_d (\omega_1^2 – \omega_2^2 + \omega_3^2 – \omega_4^2)
\end{aligned} $$
with $L$ as the arm length and $K_d$ as the drag torque coefficient.
To model environmental disturbances, a composite wind field model is incorporated, comprising constant wind, wind shear, gust, and turbulence components. The force $F_w$ and moment $M_w$ exerted by wind on the quadrotor drone are calculated and added to the dynamic equations, making the simulation more realistic.
For controller design, a simplified model is often used under the assumption of small angles and neglecting some disturbance terms initially:
$$ \begin{aligned}
\ddot{x} &= U_1 (\sin\theta \cos\psi \cos\phi + \sin\psi \sin\phi)/m \\
\ddot{y} &= U_1 (\sin\theta \cos\psi \cos\phi – \sin\psi \sin\phi)/m \\
\ddot{z} &= U_1 (\cos\theta \cos\phi)/m – g \\
\ddot{\phi} &= \dot{\theta} \dot{\psi} \left( \frac{I_y – I_z}{I_x} \right) + \frac{U_2}{I_x} \\
\ddot{\theta} &= \dot{\phi} \dot{\psi} \left( \frac{I_z – I_x}{I_y} \right) + \frac{U_3}{I_y} \\
\ddot{\psi} &= \dot{\phi} \dot{\theta} \left( \frac{I_x – I_y}{I_z} \right) + \frac{U_4}{I_z}
\end{aligned} $$
Design of the Sliding Mode – CPCMAC Joint Controller
The control objective is to track desired trajectories $(x_d, y_d, z_d)$ and a desired yaw angle $\psi_d$, while stabilizing roll and pitch. We employ a cascaded control structure: an outer-loop for position control and an inner-loop for attitude control.
Sliding Mode Controller Design
Sliding Mode Control is chosen for its robustness to model uncertainties and disturbances. We define sliding surfaces for the position and attitude subsystems. For the x-position:
$$ s_x = c_x e_x + \dot{e}_x, \quad e_x = x – x_d $$
where $c_x > 0$. Choosing the reaching law $\dot{s}_x = -\eta_1 s_x – \eta_2 \text{sgn}(s_x)$ with $\eta_1, \eta_2 > 0$, the equivalent virtual control input $u_{1x}$ (the x-component of the total thrust) is derived as:
$$ u_{1x} = m \left[ \ddot{x}_d – c_x \dot{e}_x – \eta_1 s_x – \eta_2 \text{sgn}(s_x) \right] + K_1 \dot{x} $$
Similar procedures yield $u_{1y}$ and $u_{1z}$. The total thrust magnitude $U_1$ and the desired roll ($\phi_d$) and pitch ($\theta_d$) angles for the inner loop are then computed from these virtual inputs:
$$ \begin{aligned}
U_1 &= \sqrt{u_{1x}^2 + u_{1y}^2 + (u_{1z}+mg)^2} \\
\phi_d &= \arctan\left( \frac{u_{1x} \sin\psi_d – u_{1y} \cos\psi_d}{u_{1z}+mg} \right) \\
\theta_d &= \arctan\left( \frac{u_{1x} \cos\psi_d + u_{1y} \sin\psi_d}{u_{1z}+mg} \right)
\end{aligned} $$
For the attitude loop, sliding surfaces are defined for the angle errors $e_\phi = \phi – \phi_d$, etc. The control laws for $U_2, U_3, U_4$ are derived similarly. For roll:
$$ U_2 = I_x \left[ \ddot{\phi}_d – c_\phi \dot{e}_\phi – \lambda_1 s_\phi – \lambda_2 \text{sgn}(s_\phi) – \dot{\theta}\dot{\psi}\left(\frac{I_y-I_z}{I_x}\right) \right] $$
While SMC provides robustness, its discontinuous $\text{sgn}()$ function often leads to chattering, which is undesirable for the physical actuators of a quadrotor drone.
CPCMAC Learning Compensator
To mitigate chattering and enhance adaptability, we integrate a Cerebellar Model Articulation Controller (CMAC) trained with a credit-assignment mechanism (CPCMAC). CMAC is a type of associative memory neural network that excels at local function approximation with fast learning. The CPCMAC learns to mimic the ideal output of the SMC online. Its output $u_{cmac}$ is added to the system.
The CPCMAC operates by mapping an input vector (e.g., error and error derivative) to a set of activated memory cells. The output is the sum of the weights $w_j$ associated with these cells:
$$ u_{cmac} = \sum_{j \in A} w_j $$
where $A$ is the set of activated cells. The key innovation is the credit-point based weight update rule. Each memory cell maintains a credit counter $f(j)$ incremented each time it is activated. The weight update for cell $j$ at time step $t$ is:
$$ \Delta w_j(t) = \alpha \cdot e(t) \cdot \frac{(f(j)+1)^{-1}}{\sum_{k \in A} (f(k)+1)^{-1}} $$
where $\alpha$ is the learning rate and $e(t)$ is the control error. This rule ensures that frequently used (high-credit) cells are updated with smaller steps, preserving learned knowledge, while less-used (low-credit) cells adapt more rapidly to new information. This enhances learning stability and convergence speed for the quadrotor drone controller.
Joint Control Structure
The final control signal $u_{total}$ for each channel is a combination of the SMC output $u_{smc}$ and the CPCMAC output $u_{cmac}$:
$$ u_{total} = u_{smc} + u_{cmac} $$
Initially, the SMC dominates to ensure stability and rapid response. As the CPCMAC learns the inverse dynamics of the quadrotor drone, its output increasingly compensates for the nonlinearities and disturbances, allowing the gain of the discontinuous term in SMC to be reduced, thereby minimizing chattering. The structure effectively leverages the robustness of SMC and the smooth, adaptive learning capability of CPCMAC.
The following table summarizes the key parameters and their roles in the controller design for the quadrotor drone.
| Component | Parameter/Symbol | Role |
|---|---|---|
| Sliding Mode | $c_x, c_\phi, …$ | Sliding surface coefficients, determine convergence rate. |
| Sliding Mode | $\eta_1, \eta_2, \lambda_1, \lambda_2$ | Reaching law coefficients, govern approach to sliding surface. |
| CPCMAC | $\alpha$ | Global learning rate for weight updates. |
| CPCMAC | $f(j)$ | Credit counter for memory cell $j$, modulates individual learning rate. |
| Quadrotor Drone Model | $I_x, I_y, I_z$ | Moments of inertia, crucial for attitude control moments. |
| Quadrotor Drone Model | $K_t, K_d$ | Thrust and drag torque coefficients, map rotor speed to force/moment. |
Semi-Physical Simulation System Implementation
The simulation platform bridges the digital control algorithm and physical hardware. The quadrotor drone’s complete nonlinear dynamics, including the detailed wind disturbance model, are implemented in Simulink. The Sliding Mode-CPCMAC joint controller is also coded within Simulink. A crucial component is the interface between this simulated world and the real flight controller hardware.
The flight control code is compiled and deployed onto the STM32F407 microcontroller. This board receives the simulated vehicle’s state (position, velocity, attitude, etc.) from the Simulink model via a serial communication link. It runs the identical Sliding Mode-CPCMAC algorithm as in simulation, generating control signals $U_1$ to $U_4$. These signals are converted into Pulse-Width Modulation (PWM) commands for four simulated motors. The motor dynamics, including their electromechanical response, are modeled in Simulink to close the loop. The motor speeds determine the forces and torques acting on the simulated quadrotor drone body, completing the HIL cycle.
Concurrently, a LabVIEW-based ground station provides the user interface. It sends high-level commands (e.g., desired waypoints) to Simulink and visualizes the real-time telemetry data (position, attitude, errors) received back from the simulation. This setup creates a realistic testing environment where the physical flight controller “thinks” it is flying a real quadrotor drone, but the vehicle dynamics and environment are simulated. This allows for exhaustive, risk-free testing and parameter tuning.
Simulation Results and Analysis
We validated the proposed control system through comprehensive simulations. The quadrotor drone was tasked with tracking a trajectory while maintaining a specific orientation and subjected to wind disturbances. The performance of the Sliding Mode-CPCMAC (SM-CPCMAC) joint controller was compared against a standard Sliding Mode Controller (SMC), a classical PID controller, and an Integral Backstepping controller.
Trajectory Tracking: For a command to move to $(x_d=0, y_d=5\text{m}, z_d=5\text{m})$ with a desired yaw, the SM-CPCMAC controller demonstrated superior performance. The quadrotor drone achieved stability in the x and y positions in approximately 1.3 seconds with negligible overshoot. In contrast, the standard SMC took about 1.8 seconds and exhibited noticeable overshoot. The PID and Backstepping controllers were significantly slower, taking around 10 and 5 seconds, respectively, to stabilize.
Attitude Control: The inner loop performance was equally impressive. The roll angle $\phi$, which was actively controlled to a non-zero reference, converged within 0.2 seconds using the SM-CPCMAC scheme. The pitch and yaw angles, which needed to be regulated indirectly to achieve the desired translational motion, also remained stable within very small error bounds. The chattering phenomenon evident in the pure SMC attitude outputs was effectively smoothed out by the CPCMAC compensator in the joint control scheme.
Disturbance Rejection: Under the influence of the modeled composite wind field, the SM-CPCMAC controller maintained stable tracking with minimal deviation, showcasing its robustness. The adaptive learning feature of the CPCMAC allowed the controller to compensate for the persistent wind effects online.
The following table quantitatively compares the performance metrics of the different controllers for the quadrotor drone stabilization task.
| Control Method | Settling Time (x,y) | Overshoot | Steady-State Error | Chattering | Robustness to Wind |
|---|---|---|---|---|---|
| PID | > 10 s | Moderate | Small | None | Poor |
| Integral Backstepping | ~ 5 s | Low | Very Small | None | Fair |
| Sliding Mode (SMC) | ~ 1.8 s | High | Negligible | Severe | Good |
| SM-CPCMAC (Proposed) | ~ 1.3 s | Very Low | Negligible | Minimal | Excellent |
The error output of the CPCMAC itself was also monitored. The results confirmed that the network successfully learned to approximate the required control signal, with its output error converging rapidly to near zero. This validates that the CPCMAC can effectively take over from the SMC, providing a smooth control action.
Conclusion
In this work, we have presented a robust control solution for quadrotor drones and a practical framework for its development. The proposed Sliding Mode-CPCMAC joint control algorithm successfully addresses the conflicting needs of robustness and smooth operation. The SMC component guarantees stability and fast dynamic response in the face of nonlinearities and disturbances inherent to the quadrotor drone. The CPCMAC component, with its credit-based learning, adaptively compensates for these complex dynamics, allowing the reduction of SMC switching gains and the effective elimination of chattering. Comparative simulations conclusively demonstrate the superiority of this approach over conventional PID, backstepping, and pure SMC in terms of settling time, overshoot suppression, and disturbance rejection.
Furthermore, the developed semi-physical simulation system provides an invaluable tool for the rapid prototyping and validation of flight control algorithms. By integrating a realistic dynamic model, hardware-in-the-loop testing, and an intuitive ground station, it significantly lowers the barrier to entry for advanced quadrotor drone controller development, reduces risks, and accelerates the design cycle. The modular nature of the platform allows for easy extension to other multi-rotor configurations or more complex scenarios, underscoring its broad practical utility in the field of autonomous aerial systems.
