In recent years, unmanned aerial vehicles (UAVs) have gained significant attention due to their versatility in applications such as rescue operations, disaster monitoring, and military missions. Among these, the quadrotor stands out for its ability to perform vertical take-off and landing, hover, and maneuver in complex environments. However, commercial quadrotor systems often rely on proprietary or undocumented code, limiting transparency and customization. To address this, we present a comprehensive design and implementation of a quadrotor control system, focusing on re-establishing the modeling workflow based on flight control principles. This approach ensures robust performance through detailed dynamics modeling, sensor integration, and advanced control algorithms like Kalman filtering and cascade PID control. Our work aims to provide an open framework for quadrotor development, emphasizing stability, precision, and adaptability in diverse scenarios.
The quadrotor is a type of rotary-wing aircraft characterized by its four rotors arranged in a symmetric configuration. Its ability to achieve stable flight in confined spaces makes it ideal for both civilian and military uses. In this paper, we delve into the core aspects of quadrotor design, including physical modeling, force and torque analysis, hardware selection, and control strategy optimization. By leveraging a first-principles approach, we overcome the limitations of closed-source solutions and demonstrate a functional quadrotor system capable of autonomous flight. Key components such as the STM32F103C8T6 microcontroller, MPU6050 inertial measurement unit, and NRF24L01 wireless module are integrated to handle data acquisition, processing, and communication. Through extensive testing, we validate the effectiveness of our methods in achieving smooth and responsive quadrotor control.
Control Principles and Modeling of the Quadrotor
The foundation of quadrotor control lies in understanding its dynamics and spatial orientation. We begin by defining the quadrotor’s body layout and coordinate systems to facilitate accurate modeling. The quadrotor operates in a three-dimensional space, where its state can be described using position coordinates and Euler angles. Assuming the initial take-off position as the origin and the initial attitude as the reference, we model the quadrotor’s motion using Newton-Euler equations. This allows us to predict and control its behavior under various forces and moments.
Body Configuration
We adopt an X-type layout for the quadrotor, which efficiently distributes lift from the four rotors. Let motor A be positioned at the front-left, followed clockwise by motors B, C, and D. To balance torque, motors A and C rotate clockwise, while motors B and D rotate counterclockwise. This arrangement, combined with the use of reverse and standard propellers, generates upward lift and enables agile movements. The symmetry of the layout ensures that the quadrotor can maintain stability during pitch, roll, and yaw maneuvers. The rotor forces are denoted as $F_A$, $F_B$, $F_C$, and $F_D$, each contributing to the overall lift and control.
Physical Modeling Approach
The quadrotor’s spatial state is represented by its position $(x, y, z)$ and orientation $(\phi, \theta, \psi)$, where $\phi$ is the roll angle, $\theta$ is the pitch angle, and $\psi$ is the yaw angle. The equations of motion are derived from Newton’s second law and Euler’s equations for rigid body dynamics. The translational dynamics are given by:
$$m \ddot{x} = F (\sin \theta \cos \psi)$$
$$m \ddot{y} = F (\sin \phi \cos \theta)$$
$$m \ddot{z} = F (\cos \phi \cos \theta) – mg$$
where $m$ is the mass of the quadrotor, $g$ is gravitational acceleration, and $F$ is the total thrust from the rotors. The rotational dynamics are described by:
$$I \dot{\omega} + \omega \times (I \omega) = \tau$$
where $I$ is the inertia matrix, $\omega$ is the angular velocity vector, and $\tau$ is the torque vector. These equations form the basis for simulating and controlling the quadrotor’s flight.
Force Analysis and Simulation
For simplicity, we analyze forces in two-dimensional planes. The total lift $F$ is the sum of individual rotor forces: $F = F_A + F_B + F_C + F_D$. In the xOz plane, when the pitch angle $\theta$ increases, the resultant force tilts, and its component along the x-axis becomes $F \sin \theta$, which determines acceleration in the x-direction. Similarly, in the yOz plane, a roll angle $\phi$ results in a y-axis component $F \sin \phi$. The vertical component is $F \cos \phi \cos \theta$. Thus, the quadrotor’s attitude angles and thrust collectively influence its force balance. The following table summarizes the force components in different directions:
| Direction | Force Component | Equation |
|---|---|---|
| x-axis | Horizontal force due to pitch | $F_x = F \sin \theta$ |
| y-axis | Horizontal force due to roll | $F_y = F \sin \phi$ |
| z-axis | Vertical force | $F_z = F \cos \phi \cos \theta – mg$ |
Torque Analysis and Simulation
The quadrotor’s rotational motion is governed by torques generated by the rotors. The axis of rotation passes through the center of mass. Angular momentum is conserved, and to achieve balance, two rotors spin clockwise and two counterclockwise. The torque $\tau$ for each axis is given by:
$$\tau_\phi = l (F_A – F_B – F_C + F_D)$$
$$\tau_\theta = l (F_A + F_B – F_C – F_D)$$
$$\tau_\psi = k ( -F_A + F_B – F_C + F_D)$$
where $l$ is the arm length from the center to each rotor, and $k$ is a drag coefficient. These torques enable control over roll, pitch, and yaw movements. The quadrotor remains stable when the net torque is zero, which is achieved by adjusting rotor speeds dynamically.

System Design and Justification
Our quadrotor system is built around a modular hardware architecture that ensures reliability and efficiency. We selected components based on their performance, availability, and compatibility with open-source frameworks. The core modules include the main controller, attitude sensor, barometer, and wireless communication unit. Each module plays a critical role in data acquisition, processing, and execution of control commands.
Main Controller Module
We use the STM32F103C8T6 microcontroller, which features a 32-bit Cortex-M3 core, 256 KB of flash memory, and a 72 MHz clock speed. This chip supports various peripherals such as GPIO, timers, I2C, and SPI interfaces. Its efficiency in handling sensor data and executing control algorithms makes it ideal for quadrotor applications. Programming in C ensures low-level optimization and real-time performance.
Attitude Module
The MPU6050 sensor integrates a three-axis accelerometer and gyroscope, providing real-time angular velocity and acceleration data. It includes a digital motion processor (DMP) that offloads computation from the main controller by performing attitude estimation and filtering. Communication via I2C simplifies integration and reduces latency in feedback loops.
Barometer Module
For altitude sensing, we employ the BMP180 digital pressure sensor. It measures atmospheric pressure and temperature with high accuracy and low power consumption. The capacitance-based design detects pressure changes, enabling precise height control for the quadrotor.
Wireless Communication Module
The NRF24L01 transceiver operates at 2.4 GHz with a data rate of 2 Mbit/s, facilitating real-time control and telemetry. It pairs with a PS2 remote controller for manual input and transmits data to a ground station for monitoring. This module enhances the quadrotor’s operational range and responsiveness.
| Module | Component | Key Features |
|---|---|---|
| Main Controller | STM32F103C8T6 | 32-bit core, 72 MHz, multiple interfaces |
| Attitude Sensor | MPU6050 | 3-axis accelerometer/gyroscope, I2C, DMP |
| Barometer | BMP180 | High precision, low power, digital output |
| Wireless Comms | NRF24L01 | 2.4 GHz, 2 Mbit/s, SPI interface |
System Design and Construction
The control logic of our quadrotor centers on the STM32 microcontroller, which processes data from sensors and issues commands to motors. We employ a hierarchical structure where sub-tasks are delegated to peripherals, allowing the main controller to focus on attitude calculation. Sensor data from the MPU6050 and BMP180 are fused to determine position and orientation. PWM signals regulate motor speeds based on control outputs, while wireless modules enable external communication and data logging.
Kalman Filter Algorithm Design and Application
To improve sensor accuracy, we implement a Kalman filter that estimates the true state by combining predictions with measurements. The state-update equations are:
$$\hat{x}_{k|k-1} = F_k \hat{x}_{k-1|k-1} + B_k u_k$$
$$P_{k|k-1} = F_k P_{k-1|k-1} F_k^T + Q_k$$
$$K_k = P_{k|k-1} H_k^T (H_k P_{k|k-1} H_k^T + R_k)^{-1}$$
$$\hat{x}_{k|k} = \hat{x}_{k|k-1} + K_k (z_k – H_k \hat{x}_{k|k-1})$$
$$P_{k|k} = (I – K_k H_k) P_{k|k-1}$$
where $\hat{x}$ is the state estimate, $P$ is the error covariance, $K$ is the Kalman gain, $F$ is the state transition matrix, $H$ is the observation matrix, and $Q$ and $R$ are process and measurement noise covariances. This filter reduces data fluctuations and enhances the stability of the quadrotor during flight.
Control Strategy and Optimization
We adopt a cascade PID control system to manage the quadrotor’s attitude. This structure consists of an outer loop for angle control and an inner loop for angular rate control. The outer loop computes desired angular rates based on angle errors, while the inner loop adjusts motor outputs to achieve those rates. This decoupling improves responsiveness and stability.
Cascade PID Algorithm Design
The cascade PID system can be represented by the following equations. For the outer loop (angle control):
$$\omega_{des} = K_{P,outer} \cdot e_\theta + K_{I,outer} \cdot \int e_\theta \, dt + K_{D,outer} \cdot \frac{de_\theta}{dt}$$
where $e_\theta$ is the angle error (target angle minus measured angle), and $\omega_{des}$ is the desired angular rate. For the inner loop (angular rate control):
$$u = K_{P,inner} \cdot e_\omega + K_{I,inner} \cdot \int e_\omega \, dt + K_{D,inner} \cdot \frac{de_\omega}{dt}$$
where $e_\omega$ is the angular rate error (desired rate minus measured rate), and $u$ is the control output to the motors. We set output limits on the outer loop to constrain maximum angular rates and integral limits on the inner loop to prevent wind-up.
Inner Loop Proportional Coefficient $K_P$
We tuned $K_P$ for the inner loop to achieve consistent oscillations around the target value. After multiple tests, $K_P = 1.15$ yielded uniform distribution without excessive oscillation. The response curve showed that lower values led to sluggish performance, while higher values caused instability.
Inner Loop Derivative Coefficient $K_D$
Introducing $K_D$ damped the oscillations and stabilized the angle. With $K_P = 1.15$, we found $K_D = 4.00$ effectively reduced overshoot and settling time. However, a steady-state error persisted, necessitating the addition of an integral term.
Inner Loop Integral Coefficient $K_I
With $K_P = 1.15$ and $K_D = 4.00$, we adjusted $K_I$ to eliminate static error. At $K_I = 0.015$, the error was minimized with acceptable overshoot (±2°). Further tuning involved adding output and integral limits to suppress excessive fluctuations.
Yaw Angle Parameters
For yaw control, we prioritize static stability over dynamic response. Thus, we set $Y_P = 0.5$, $Y_I = 0$, and $Y_D = 0$, allowing the quadrotor to maintain a fixed heading with minimal error.
Cascade PID Parameters Summary
The finalized PID parameters for the quadrotor are listed below. These values ensure a balance between response speed and stability, enabling precise control in various flight conditions.
| Control Loop | Parameter | Value |
|---|---|---|
| Outer Loop (Angle) | $K_P$ | 5.0 |
| Outer Loop (Angle) | $K_I$ | 0 |
| Outer Loop (Angle) | $K_D$ | 0 |
| Inner Loop (Pitch/Roll Rate) | $K_P$ | 1.150 |
| Inner Loop (Pitch/Roll Rate) | $K_I$ | 0.015 |
| Inner Loop (Pitch/Roll Rate) | $K_D$ | 4.000 |
| Yaw Control | $Y_P$ | 0.5 |
| Yaw Control | $Y_I$ | 0 |
| Yaw Control | $Y_D$ | 0 |
The cascade PID control system effectively coordinates the quadrotor’s movements, allowing it to respond to commands while maintaining stability. The inner loop’s rapid adjustments complement the outer loop’s broader attitude management, resulting in smooth flight performance. Experimental results confirm that this strategy reduces errors and enhances robustness against disturbances.
Conclusion
In this work, we have developed a functional quadrotor control system by integrating hardware components like the STM32 microcontroller, MPU6050 sensor, and NRF24L01 module with advanced algorithms such as Kalman filtering and cascade PID control. Our modeling approach, based on first principles, provides a transparent alternative to proprietary solutions. The quadrotor demonstrates stable flight and precise attitude control, validating the effectiveness of our design. Future efforts will focus on incorporating machine learning for adaptive control and expanding applications in autonomous navigation. This project underscores the potential of open-source frameworks in advancing quadrotor technology toward greater intelligence and practicality.
