Design and Implementation of an Autonomous Ground Path Tracking System for a Quadrotor Drone Using Onboard Machine Vision and Linear Active Disturbance Rejection Control

The autonomous navigation of unmanned aerial vehicles (UAVs) along predefined paths represents a fundamental capability with extensive applications in logistics, infrastructure inspection, surveillance, and agricultural monitoring. Among various UAV platforms, the quadrotor drone offers distinct advantages due to its mechanical simplicity, vertical take-off and landing (VTOL) capability, and exceptional maneuverability, allowing for stable hovering and precise low-altitude flight. A critical challenge in achieving full autonomy for a quadrotor drone is the reliable perception of its environment and subsequent accurate control to follow a desired trajectory without external guidance like GPS, which may be unavailable or unreliable in indoor or constrained environments.

This article presents a comprehensive system design for enabling a quadrotor drone to autonomously track a ground-based path, typically a high-contrast line. The core of the system is an onboard machine vision module that captures and processes real-time imagery of the ground below the drone. The extracted path information—namely the lateral deviation and angular error relative to the drone’s heading—is fed into a custom flight control architecture. We employ a cascade control structure featuring a Linear Active Disturbance Rejection Controller (LADRC) for the outer position loop and a Proportional-Integral-Derivative (PID) controller for the inner velocity loop. This combination is designed to robustly eliminate tracking errors despite model uncertainties and disturbances. For heading correction on sharp turns, a bang-bang control logic is implemented. The entire system, from perception to actuation, is integrated onto a custom-built quadrotor drone platform. Experimental validation involving tracking of a complex “8”-shaped trajectory confirms the effectiveness of the proposed approach, demonstrating stable and accurate path-following performance.

1. System Architecture and Hardware Platform

The successful implementation of an autonomous tracking system for a quadrotor drone necessitates a carefully selected hardware suite that balances computational power, sensor accuracy, and real-time performance. Our platform is built around a layered architecture comprising a flight controller, sensors for state estimation, and a dedicated vision processing unit.

1.1 Flight Control Core

The central processing unit is a 32-bit ARM Cortex-M4 microcontroller (STM32F407), chosen for its high clock speed (up to 168 MHz), integrated Digital Signal Processing (DSP) instructions, and Floating-Point Unit (FPU). These features are essential for executing computationally intensive flight control algorithms, sensor fusion, and communication protocols with low latency. The flight controller runs a real-time operating system (RTOS) to manage tasks such as attitude estimation, control law execution, and data logging.

1.2 State Estimation Sensors

Accurate knowledge of the drone’s attitude (orientation) and velocity is paramount for stable flight. Our quadrotor drone utilizes the following sensor suite:

  • Inertial Measurement Unit (IMU): An MPU6050 provides 6-axis motion data, combining a 3-axis accelerometer and a 3-axis gyroscope. Sensor fusion algorithms (e.g., Complementary or Kalman filters) are applied to these readings to estimate the roll ($\phi$) and pitch ($\theta$) angles, which are critical for attitude stabilization.
  • Magnetometer: A 3-axis magnetometer (e.g., AK8975) measures the Earth’s magnetic field vector. Its readings are fused with the roll and pitch estimates to derive the yaw angle ($\psi$), providing a stable global heading reference that does not drift like a gyroscope-integrated estimate.
  • Optical Flow Sensor: A downward-facing optical flow sensor (e.g., PMW3901 or PX4FLOW) estimates the quadrotor drone‘s horizontal velocity ($v_x$, $v_y$) relative to the ground. This velocity feedback is crucial for the inner-loop velocity control, enabling precise hovering and smooth translational movement, independent of attitude changes.

1.3 Machine Vision Module

The primary sensor for path perception is an OpenMV Cam module. This is a compact, programmable camera module featuring an STM32F765 microcontroller and an OV7725 image sensor. It runs a MicroPython interpreter, allowing for rapid development of computer vision algorithms using Python scripts. The module includes optimized libraries for basic image processing functions (grayscaling, thresholding, blob detection) and more advanced features. For our application, it is configured to capture grayscale images at a resolution of 160×120 pixels, providing a sufficient field of view and manageable data throughput for real-time processing.

The table below summarizes the key hardware components of the autonomous quadrotor drone system:

Component Model/Type Primary Function
Flight Controller MCU STM32F407 (Cortex-M4) Runs flight control algorithms, sensor fusion, system management.
IMU MPU6050 (6-Axis) Provides raw accelerometer and gyroscope data for attitude estimation.
Magnetometer AK8975 Provides heading reference for yaw angle estimation.
Optical Flow Sensor e.g., PMW3901 Estimates ground-relative horizontal velocity.
Vision Processor OpenMV Cam (STM32F765) Captures and processes ground images for path detection.
Communication Radio Telemetry Module Enables wireless data transmission for monitoring and debugging.

2. Vision-Based Path Recognition Algorithm

The algorithm for detecting the ground path must be both accurate and computationally efficient to run in real-time on the embedded vision processor. Processing a full 160×120 image for every frame is prohibitively expensive. Therefore, a region-of-interest (ROI) based approach is adopted to drastically reduce the processed pixel count while retaining critical path information.

2.1 Image Acquisition and Preprocessing

The OpenMV camera captures a grayscale image $I_{gray}(x, y)$, where each pixel intensity $I$ ranges from 0 (black) to 255 (white). The target path is assumed to be a dark line (near 0 intensity) on a lighter background. The image is first binarized using a fixed threshold $T$ (e.g., $T = 80$):
$$
B(x, y) = \begin{cases}
1 & \text{(Black/Object)} & \text{if } I_{gray}(x, y) \leq T \\
0 & \text{(White/Background)} & \text{if } I_{gray}(x, y) > T
\end{cases}
$$
This creates a binary image $B(x, y)$ where the path appears as connected white regions (blobs) on a black background, simplifying subsequent analysis.

2.2 Strategic Region Segmentation and Analysis

Instead of analyzing the entire binary image, five specific rectangular regions are defined, as conceptually illustrated in the system diagram. These regions are strategically placed to capture the path’s position under various scenarios (straight, curved, intersections).

  • Region 1 (R1): A horizontal strip near the top of the image. Indicates the path’s location ahead of the drone.
  • Region 2 & 3 (R2, R3): Two horizontal strips located in the middle-left and middle-right portions of the image. Crucial for detecting the current lateral position and calculating the path’s angle.
  • Region 4 & 5 (R4, R5): Vertical strips on the far left and far right edges of the image. Primarily used to detect sharp turns (90-degree corners) and wide curves.

Within each region $i$, a connected component analysis (blob detection) is performed on $B(x, y)$. The largest blob (by pixel area) is selected as the candidate path segment within that region. A validity check is applied based on the blob’s area $A_i$: if $A_{min} \leq A_i \leq A_{max}$ (e.g., 200 to 400 pixels, calibrated for flight altitude), the region is marked as valid. For a valid region, its flag $flag_i$ is set to 1, and the centroid coordinates $(x_i, y_i)$ of the blob are recorded. Otherwise, $flag_i = 0$ and $x_i$ is considered undefined.

2.3 Deriving Path State Information

The flags and centroid data from the five regions are synthesized to determine the drone’s state relative to the path.

Lateral Deviation ($\Delta x$): The immediate lateral error is computed from the valid regions in the forward-looking and central areas (R1, R2, R3). Let $N$ be the number of valid regions among {R1, R2, R3}. The perceived path center $x_0$ in image coordinates is:
$$
x_0 = \frac{1}{N} \sum_{i \in \mathcal{V}} x_i, \quad \mathcal{V} = \{i | flag_i = 1, i \in \{1,2,3\}\}
$$
where $x_i$ is the x-coordinate of the centroid in region $i$. The lateral deviation from the image center ($x_{center} = 80$) is $\Delta x = x_0 – x_{center}$. This value, scaled appropriately, becomes the primary error signal for the lateral position controller.

Path Angle ($\theta_{path}$): The angle of the path relative to the drone’s heading is estimated using the centroids from the middle regions (R2, R3) and the forward region (R1). The logic, designed for robustness when some regions are invalid, is as follows:

$$
\text{If } N \ge 2: \quad \theta_{path} = \arctan\left(\frac{\Delta X}{\Delta Y}\right)
$$

Where $\Delta X$ and $\Delta Y$ are chosen based on which regions are valid. For example:
– If R1 and R2 are valid: $\Delta X = x_1 – x_2$, $\Delta Y = H$ (vertical distance between regions, e.g., 50 pixels).
– If R1 and R3 are valid: $\Delta X = x_1 – x_3$, $\Delta Y = H$.
– If R2 and R3 are valid: $\Delta X = x_2 – x_3$, $\Delta Y = h$ (smaller vertical distance, e.g., 25 pixels).
If $N < 2$, $\theta_{path}$ is set to 0, assuming the path is straight ahead.

Path Element Identification: The pattern of region flags uniquely identifies different track elements, enabling the drone to anticipate and react appropriately.

Track Element Flag Pattern (R1, R2, R3, R4, R5) Interpretation & Action
Straight / Gentle Curve (1,1,1,0,0), (1,1,0,0,0), etc. Path is visible ahead and centrally. Controlled by $\Delta x$ and $\theta_{path}$.
Cross Intersection (1,1,1,1,1) or (1,0,0,1,1) Path is visible in all directions. System may hold current heading or follow a predefined rule (e.g., go straight).
Left 90° Corner (1,1,0,1,0) or (1,0,0,1,0) Path makes a sharp left turn. Triggers a discrete heading correction command.
Right 90° Corner (1,1,0,0,1) or (1,0,0,0,1) Path makes a sharp right turn. Triggers a discrete heading correction command.
Path Lost (0,0,0,0,0) No valid path detected. Initiate a lost-path recovery maneuver (e.g., hover, slow spin, or land).

3. Control Strategy for Path Tracking

The control system translates the vision-derived state ($\Delta x$, $\theta_{path}$, element ID) into actuator commands (motor speeds) to minimize tracking error. The overall architecture is a cascade control system, renowned for its effectiveness in handling disturbances and separating dynamics.

3.1 System Modeling and Control Architecture

The lateral dynamics of a quadrotor drone can be significantly simplified for the purpose of path tracking control design. By commanding a small, constant pitch angle ($\theta_{cmd} \approx 1^\circ$), the drone maintains a steady forward velocity $V_{forward}$. The primary control objective is to adjust the roll angle $\phi$ to generate lateral acceleration, thereby controlling the lateral position $y$. A simplified model for the lateral dynamics is:

Position Loop: $\ddot{y} \approx g \cdot \phi + d_1(t)$
Velocity Loop (from Optical Flow): $\dot{y} = v_y$
Where $g$ is gravity, $\phi$ is the roll angle (control input for position), and $d_1(t)$ represents the aggregated “total disturbance” affecting the position dynamics, including unmodeled aerodynamics, wind gusts, and model inaccuracies.

The cascade control structure is implemented as follows:
1. Outer Loop (Position): Takes the lateral error $\Delta x$ (scaled to meters as $e_y$) and outputs a desired lateral velocity $v_{y,des}$.
2. Inner Loop (Velocity): Takes the velocity error $v_{y,des} – v_y$ (from optical flow) and outputs a desired roll angle $\phi_{des}$.
3. Attitude Controller: The drone’s existing, high-rate attitude stabilization controller (typically PID) takes $\phi_{des}$ and the current $\phi$ from the IMU to generate motor thrust differentials.

This structure allows the inner loop to quickly reject disturbances affecting velocity, while the outer loop focuses on achieving accurate position tracking.

3.2 Linear Active Disturbance Rejection Control (LADRC) for Position Loop

For the outer position loop, we employ LADRC due to its notable robustness against both internal dynamics uncertainty and external disturbances. LADRC consists of two main parts: a Linear Extended State Observer (LESO) and a Linear State Error Feedback (LSEF) law.

1. Linear Extended State Observer (LESO):
The key innovation is to treat the total disturbance $d_1(t)$ as an extended state $x_3 = d_1(t)$. The second-order position system is rewritten as a third-order state-space model:
$$
\begin{cases}
\dot{x}_1 = x_2 \\
\dot{x}_2 = x_3 + b_0 u \\
\dot{x}_3 = \dot{d}_1(t) \\
y = x_1
\end{cases}
$$
where $x_1 = y$, $x_2 = \dot{y}$, $u = \phi$ is the control signal, and $b_0 \approx g$ is a rough estimate of the control gain. The LESO is designed to estimate all three states $(x_1, x_2, x_3)$ in real-time from the measured output $y$ (the lateral position derived from vision):
$$
\begin{cases}
e = z_1 – y \\
\dot{z}_1 = z_2 – \beta_{01} e \\
\dot{z}_2 = z_3 – \beta_{02} e + b_0 u \\
\dot{z}_3 = -\beta_{03} e
\end{cases}
$$
In discrete time for implementation ($h$ is the sampling period):
$$
\begin{cases}
e(k) = z_1(k) – y(k) \\
z_1(k+1) = z_1(k) + h[z_2(k) – \beta_{01} e(k)] \\
z_2(k+1) = z_2(k) + h[z_3(k) – \beta_{02} e(k) + b_0 u(k)] \\
z_3(k+1) = z_3(k) + h[-\beta_{03} e(k)]
\end{cases}
$$
Here, $(z_1, z_2, z_3)$ are the estimates of $(x_1, x_2, x_3)$. The observer gains $\beta_{01}, \beta_{02}, \beta_{03}$ are tuned by placing the observer’s characteristic polynomial’s poles at $-\omega_o$ (the observer bandwidth):
$$
s^3 + \beta_{01} s^2 + \beta_{02} s + \beta_{03} = (s + \omega_o)^3
$$
This yields: $\beta_{01} = 3\omega_o$, $\beta_{02} = 3\omega_o^2$, $\beta_{03} = \omega_o^3$. Tuning is simplified to adjusting a single parameter $\omega_o$: a higher $\omega_o$ leads to faster disturbance estimation but increased noise sensitivity.

2. Linear State Error Feedback (LSEF) and Disturbance Compensation:
With the LESO providing accurate estimates, the control law is designed simply as:
$$
u_0 = k_p (r – z_1) – k_d z_2
$$
$$
u = \frac{u_0 – z_3}{b_0}
$$
where $r$ is the desired lateral position (usually 0 for centered tracking). The term $u_0$ is a standard PD controller acting on the estimated state error. The brilliance lies in the term $-z_3/b_0$, which actively cancels out the estimated total disturbance $z_3$ in real-time. This compensation eliminates the need for an integral term in the PD controller to counteract steady-state disturbances, avoiding integrator windup issues. The controller gains $k_p$ and $k_d$ are tuned by placing the closed-loop poles at $-\omega_c$ (the controller bandwidth):
$$
s^2 + k_d s + k_p = (s + \omega_c)^2
$$
Thus, $k_p = \omega_c^2$ and $k_d = 2\omega_c$. The entire LADRC is parameterized by just three intuitive parameters: $b_0$, $\omega_c$, and $\omega_o$.

3.3 Velocity Loop and Overall Cascade Control

The desired lateral velocity $v_{y,des}$ output by the LADRC position controller becomes the setpoint for the velocity inner loop. This loop uses a standard discrete-time PID controller to compute the desired roll angle $\phi_{des}$:
$$
\phi_{des}(k) = K_p e_v(k) + K_i \sum_{j=0}^{k} e_v(j) \cdot h + K_d \frac{e_v(k) – e_v(k-1)}{h}
$$
where $e_v(k) = v_{y,des}(k) – v_y(k)$. The integral term $K_i$ is effective here because the velocity loop’s main disturbance (e.g., slight imbalances) is more constant, and the optical flow provides a direct, low-latency measurement.

3.4 Bang-Bang Control for Heading Correction

While the cascade controller handles smooth path following, discrete events like sharp 90-degree corners require an immediate, substantial change in the drone’s yaw heading $\psi$. A simple yet effective bang-bang control logic is applied to the yaw setpoint:
$$
\psi_{cmd}(k+1) = \begin{cases}
\psi_{cmd}(k) + \Delta \psi_{turn} & \text{if } \theta_{path} > \theta_{threshold} \text{ (Left Curve)} \\
\psi_{cmd}(k) – \Delta \psi_{turn} & \text{if } \theta_{path} < -\theta_{threshold} \text{ (Right Curve)} \\
\psi_{cmd}(k) + \Delta \psi_{corner} & \text{if Left Corner detected } (flag_4=1) \\
\psi_{cmd}(k) – \Delta \psi_{corner} & \text{if Right Corner detected } (flag_5=1) \\
\psi_{cmd}(k) & \text{otherwise}
\end{cases}
$$
For example, $\theta_{threshold} = 20^\circ$, $\Delta \psi_{turn} = 20^\circ$, and $\Delta \psi_{corner} = 90^\circ$. This logic provides prompt, decisive heading adjustments to re-align the quadrotor drone with the path after sharp turns.

The complete control block diagram for the autonomous quadrotor drone is synthesized below:

Vision System → $\Delta x, \theta_{path}, Flags$ → LADRC (Position) → $v_{y,des}$ → PID (Velocity) → $\phi_{des}$ → Attitude ControllerQuadrotor Drone Motors
Yaw Bang-Bang Controller (triggered by $\theta_{path}$ and Flags) → $\psi_{cmd}$ → Attitude Controller

4. Experimental Validation and Results

To validate the proposed autonomous tracking system, a custom quadrotor drone platform was constructed, integrating all the described hardware components. The ground path was defined using black tape on a light-colored floor, forming an “8”-shaped track that included straight segments, constant-radius curves, and crossover points, effectively testing all identified path elements.

4.1 Test Platform and Procedure

The quadrotor drone was manually launched and set to autonomous mode at an altitude of approximately 1 meter. The forward pitch angle was fixed at $1^\circ$. The vision algorithm, LADRC, and PID controllers ran simultaneously on their respective processors, with communication between the OpenMV and the flight controller established via a serial protocol. The drone’s task was to complete multiple laps of the “8”-shaped track autonomously.

4.2 Performance Metrics and Analysis

The primary metric for tracking performance is the lateral deviation $\Delta x$ in the image plane, which directly reflects the controller’s ability to center the path. A secondary metric is the smoothness of the flight and successful navigation of corners.

Data logged via wireless telemetry over multiple laps showed consistent performance. The lateral error $\Delta x$ typically remained bounded within ±40 pixels from the image center (x-center = 80 pixels). This boundary confirms that the path was always kept within the camera’s field of view, preventing catastrophic loss of tracking. The error signal exhibited characteristics of a well-damped system: it reacted promptly to path curvature (visible as low-frequency oscillations corresponding to the “8” shape) without high-frequency chatter, indicating stable and robust control action from the LADRC-based cascade system.

The quadrotor drone successfully navigated all track elements:
Straightaways and gentle curves: The drone maintained a centered position with minimal lateral deviation.
Crossover point: The vision system correctly identified the cross intersection. With a simple “go straight” rule, the drone proceeded through the intersection without hesitation.
Sharp turns in the “8” shape: The bang-bang yaw controller was triggered appropriately by the large $\theta_{path}$ angles detected during tight turns, causing the drone to rotate its heading and realign with the new path segment. The combination of yaw adjustment and lateral control allowed it to smoothly transition around curves.

The following table summarizes the key controller parameters used in the successful experiment:

Control Loop / Element Algorithm Key Parameters
Position Outer Loop LADRC $b_0 = 9.8$, $\omega_c = 1.5 \, \text{rad/s}$, $\omega_o = 15 \, \text{rad/s}$
Velocity Inner Loop PID $K_p = 2.0$, $K_i = 0.5$, $K_d = 0.1$
Yaw Correction Bang-Bang $\theta_{threshold} = 20^\circ$, $\Delta\psi_{turn}=20^\circ$, $\Delta\psi_{corner}=90^\circ$
Vision Processing Region-based Blob Detection Threshold $T=80$, Area Min=200, Area Max=400 pixels

5. Conclusion

This article detailed the complete design and implementation of an autonomous ground path tracking system for a quadrotor drone. The system synergistically combines embedded machine vision for perception with advanced control strategies for robust actuation. The region-based vision algorithm provides a computationally efficient and reliable method for detecting the path, estimating lateral and angular errors, and identifying distinct track features like intersections and corners. The cascade control architecture, featuring a disturbance-rejecting LADRC in the outer loop, effectively translates these estimates into stable and accurate flight commands. The supplemental bang-bang logic ensures prompt heading corrections for sharp turns. Experimental results on a challenging “8”-shaped track demonstrate that the integrated system enables a quadrotor drone to autonomously, accurately, and stably follow a ground line. Future work may involve extending the vision algorithm to handle more complex paths (e.g., dashed lines, color-coded routes), integrating obstacle avoidance, and optimizing the controller parameters through online adaptation for varying flight conditions and different quadrotor drone platforms.

Scroll to Top