# Wheeled Permanent Magnet Climbing Robot for Weld Defect Detection on Hydraulic Steel Gates
## 3 Computer Vision Guided Autonomous Mobility
### Robot Mobility Based on Weld Center Deviation  
Control systems can be categorized into open-loop and closed-loop types based on the presence or absence of a feedback mechanism. Open-loop control, which lacks feedback, generally exhibits low accuracy and is incapable of automatically correcting deviations. To ensure that the climbing robot meets the operational accuracy requirements during task execution, this study adopts a PID-based closed-loop control approach to correct deviations. After the deviation value is obtained, the software system of the robot applies appropriate corrections based on the deviation, thereby ensuring that the robot consistently follows the weld path.  
PID stands for Proportional-Integral-Derivative, representing a control algorithm that integrates three control strategies. The fundamental principle of the PID control system is illustrated in Figure 9.  
The model of the climbing robot tracking the weld trajectory in this study is illustrated in Figure 10. In the figure, the red line AG represents the weld centerline extracted by the visual system, and the rectangular region enclosed by points HIJK corresponds to the camera's field of view, with the camera mounted on the right side of the robot. The robot exhibits symmetry about both the dashed lines ST and MN, which intersect at point P. By offsetting the dashed line ST rightward by a distance d1, a virtual robot centerline AF is obtained. When the virtual centerline AF deviates from the weld centerline AG, it indicates that the robot has deviated from the weld trajectory. In response, the robot control system adjusts the differential steering of the left and right wheels to correct the deviation, thereby ensuring that the virtual centerline AF gradually coincides with the weld trajectory line.  
As illustrated in Figure 10, the actual deviation distance BC between the virtual robot centerline AF and the weld centerline AG can be obtained through geometric transformation. Point B denotes the center of the camera lens, and a line parallel to MN is drawn  
Figure 10: Weld tracking model.  
Figure 9: PID control system.  
through point B, intersecting the weld centerline at point C. The deflection angle \(\theta\) is determined by calculating the angle between the weld centerline AG and the vertical axis of the image. The horizontal offset d, corresponding to segment BC, is calculated as the distance between the weld centerline and the vertical axis at the horizontal midline of the image. Based on these parameters, the actual lateral deviation f of the robot chassis relative to the weld, represented by segment DE, can be calculated using the following formula:  
\[d=\frac{f}{cos\theta}-l\times tan\theta, \tag{11}\]  
In the above formula, d is the offset distance in the weld image; \(\theta\) is the deflection angle in the weld image; l is the distance from the camera center to the robot offset center, which is represented by BE in the figure.  
The actual deviation of the robot relative to the weld is selected as the error value \(\mathbf{e}_{k}\):  
\[e_{k}=f=d\times cos\theta+l\times sin\theta, \tag{12}\]  
The PID control equation of the system is expressed as follows:  
\[u_{k}=K_{P}(d_{k}cos\theta_{k}+l_{k}sin\theta_{k})+K_{i}\sum_{j=0}^{k}\left(d _{j}cos\theta_{j}+lsin\theta_{j}\right)+K_{d}(d_{k}cos\theta_{k}+lsin\theta_{ k}-d_{k-1}cos\theta_{k-1}-lsin\theta_{k-1}) \tag{13}\]  
In the above formula, u denotes the differential speed of the active wheels on both sides of the climbing robot. When the weld coincides with the virtual center line AF, the error e is zero, and the proportional term becomes zero. In this case, the system does not perform proportional control. When the weld deviates from the virtual center line AF, the error e is nonzero, and proportional control serves as the primary adjustment mechanism to correct the deviation.