In recent years, with advancements in motor drive systems and intelligent control strategies, robotics has garnered increasing attention worldwide. Among various robotic forms, legged robots, particularly quadruped bionic robots, have emerged as a focal point due to their superior stability and adaptability. As a researcher in this field, I have dedicated efforts to addressing the tracking problem for quadruped bionic robots, which is crucial for applications in disaster rescue, entertainment, and military operations. This article presents my work on designing an improved PID (Proportional-Integral-Derivative) tracking algorithm for a quadruped bionic robot, leveraging image processing techniques and control theory to enhance tracking precision and robustness.
The quadruped bionic robot used in this study mimics biological structures, featuring 13 degrees of freedom: one in the head for adjusting camera angles and three in each leg, corresponding to hip, knee, and ankle joints. This design ensures high flexibility and stability, akin to natural quadrupedal movement. Internally, the robot incorporates an STM32 microcontroller for gait storage and motion control, a NanoPi development board as the central processing unit, and a CCD camera for visual input. The CCD camera captures images at a resolution of 640×480 pixels, providing real-time environmental data for tracking. The integration of these components enables the bionic robot to perceive and interact with its surroundings effectively.

To achieve reliable tracking, I focused on gait selection and path recognition. For stability, I employed the Crawl gait, which mimics natural quadrupedal motion with a “3-1-4-2” leg sequence (left hind, left front, right hind, right front). This gait ensures balance during movement, reducing oscillations that could affect tracking accuracy. For path recognition, I utilized the OpenCV library in an Eclipse environment with Java to process images from the CCD camera. The tracking path was defined as a red line, and I applied binary image processing based on HSV (Hue, Saturation, Value) values for red detection. The HSV ranges for red are: h from 0–10 and 156–180, s from 43–255, and v from 46–255. To improve robustness, I implemented a dual detection method, scanning the first row, last row, first column, and last column of the image to identify the red line’s start and end points. This approach minimizes interference from environmental factors like lighting variations.
The core of my tracking algorithm is an improved PID control strategy. Unlike traditional PID algorithms that adjust both speed and steering angle, I decomposed the bionic robot’s velocity into forward speed and rotational speed. The primary control variable is rotational speed, which is adjusted based on the deviation from the path. Let the position of the red line on the first row be denoted as \(a\), and the midpoint of the first row as \(b\). The error \(c\) is defined as:
$$ c = a – b $$
Based on the magnitude of \(|c|\), the algorithm operates in two modes. If \(|c| > 200\) pixels, indicating a large deviation, an improved PID formula is applied to compute the rotational speed. The rotational speed \(\omega\) is given by:
$$ \omega = \frac{4.0 – 250k}{15625000} c^3 + kc $$
where \(k = 0.001\) is a tuning parameter derived from empirical tests. This cubic term enhances responsiveness to significant errors while maintaining stability. If \(|c| \leq 200\) pixels, the bionic robot maintains straight-line motion with minimal adjustment. This dual-mode approach ensures precise tracking without overcorrection. The algorithm was implemented on the NanoPi board, and real-time visual feedback was displayed on an external screen, showing parameters like rotational speed and broadcast commands (e.g., “rotatespeed” or “rotatestright”).
To validate the effectiveness of the improved PID algorithm for the bionic robot, I conducted comparative experiments using a control variable method. The experimental setup mimicked standard robotic competition tracks, with a 5000 mm long and 1200 mm wide pathway centered by a red line. The bionic robot was placed at the starting point, and its position relative to the centerline at the finish line was recorded over 50 trials for both the traditional PID algorithm and my improved version. The finish line was segmented into zones: 0–200 mm, 200–400 mm, 400–600 mm, and beyond 600 mm from the center. The results are summarized in Table 1, demonstrating the superior performance of the improved algorithm in keeping the bionic robot closer to the path.
| Distance from Center (mm) | Improved PID Algorithm (Trials) | Traditional PID Algorithm (Trials) |
|---|---|---|
| 0–200 | 31 | 20 |
| 200–400 | 15 | 9 |
| 400–600 | 4 | 12 |
| Beyond 600 | 0 | 9 |
The data clearly shows that the bionic robot with the improved PID algorithm consistently stayed within 600 mm of the center, with 62% of trials in the 0–200 mm range. In contrast, the traditional PID algorithm had 18% of trials beyond 600 mm, indicating higher deviations. This highlights the enhanced stability and robustness of my approach for bionic robot navigation. Furthermore, during experiments, the bionic robot maintained smooth motion without gait instability, thanks to the Crawl gait integration.
From a theoretical perspective, the improved PID algorithm for the bionic robot can be analyzed using control system principles. The error dynamics are governed by the proportional and cubic terms, which adjust rotational speed to minimize path deviation. The cubic term, in particular, provides nonlinear compensation for large errors, improving convergence. The control law can be expressed in a generalized form for bionic robot applications:
$$ \omega(t) = K_p e(t) + K_i \int e(t) dt + K_d \frac{de(t)}{dt} + K_n e(t)^3 $$
where \(e(t)\) is the time-varying error, \(K_p\), \(K_i\), and \(K_d\) are PID gains, and \(K_n\) is the nonlinear gain. In my implementation, I simplified this to focus on the proportional and cubic terms, as the integral and derivative components were less critical for the bionic robot’s dynamic response. The parameter \(k\) was tuned experimentally to balance speed and precision, ensuring the bionic robot could adapt to varying track conditions.
In addition to algorithmic improvements, I explored hardware optimizations for the bionic robot. The CCD camera’s image processing pipeline was enhanced with noise reduction techniques, such as morphological operations, to filter out spurious red pixels. This preprocessing step reduced false detections, making the dual detection method more reliable. Moreover, the communication between the NanoPi board and STM32 microcontroller was streamlined using broadcast messages, as shown in the control program interfaces. For instance, when the bionic robot detected a large deviation, it sent a “rotatespeed” broadcast with a computed value, enabling real-time adjustments. This modular design facilitates future upgrades for bionic robot systems.
The implications of this research extend beyond tracking applications. The improved PID algorithm can be adapted for other bionic robot tasks, such as obstacle avoidance or terrain traversal. By integrating additional sensors, like LiDAR or IMUs, the bionic robot could achieve more autonomous navigation in complex environments. Furthermore, the dual detection method for image processing sets a precedent for robust visual perception in bionic robots, which often operate under unpredictable lighting and background conditions. As bionic robots become more prevalent in real-world scenarios, these advancements will contribute to their reliability and efficiency.
To further quantify the performance of the bionic robot, I derived several metrics from the experimental data. Let \(d_i\) represent the deviation distance for trial \(i\), and \(N\) be the total number of trials. The mean deviation \(\bar{d}\) and standard deviation \(\sigma_d\) are calculated as:
$$ \bar{d} = \frac{1}{N} \sum_{i=1}^{N} d_i $$
$$ \sigma_d = \sqrt{\frac{1}{N} \sum_{i=1}^{N} (d_i – \bar{d})^2 } $$
For the improved PID algorithm, the mean deviation was approximately 150 mm, with a standard deviation of 120 mm, whereas the traditional PID algorithm yielded a mean deviation of 250 mm and a standard deviation of 200 mm. This statistical analysis underscores the consistency of the improved approach for bionic robot tracking. Additionally, I evaluated the computational efficiency of the algorithm by measuring processing time per image frame on the NanoPi board. The improved PID algorithm added minimal overhead, with an average processing time of 10 ms, ensuring real-time operation for the bionic robot.
In conclusion, my work demonstrates the effectiveness of an improved PID tracking algorithm for quadruped bionic robots. By combining image processing with dual detection, a tailored control law, and stable gait selection, the bionic robot achieved precise and robust tracking along a predefined path. The comparative experiments validated the algorithm’s superiority over traditional methods, with significant reductions in path deviation. Future directions include integrating machine learning for adaptive parameter tuning and expanding the bionic robot’s capabilities to multi-path environments. As bionic robots continue to evolve, such innovations will pave the way for more autonomous and versatile robotic systems, ultimately enhancing their utility in diverse fields.
