## 4 Weld Seam Tracking
### Trajectory Planning  
After preprocessing the 3D data points acquired by the laser vision sensor, curve interpolation is performed on the discrete data points to generate a continuous and smooth 3D spatial curve for weld seam tracking. Non-Uniform Rational B-Splines (NURBS) are used to create this 3D interpolation trajectory. The NURBS curve is defined as follows:  
\[C(u)=\frac{\sum_{i=0}^{n}N_{i,k}(u)\cdot w_{i}\cdot P_{i}}{\sum_{i=0}^{n}N_{i,k }(u)\cdot w_{i}} \tag{22}\]  
Here, \(n\) is the number of interpolation points, \(u\) is the control parameter ranging from [0,1], \(k\) is the order of the curve, \(C(u)\) is a point on the curve, \(P_{i}\) are the control points, \(w_{i}\) are the weights corresponding to these control points, and \(N_{i,k}(u)\) is the B-spline basis function corresponding to the knot vector \(U=[u_{0},u_{1},...,u_{k},u_{k+1},...,u_{n},u_{n+1},...,u_{n+k+1}]\) and order \(k\).  
In this study, a cubic NURBS curve is used, with k = 3. The knot vector U is defined as \(U=[u_{0},u_{1},...,u_{n+1},...,u_{n+3+1}]\). The 3D data points obtained from the sensor serve as the control points for the NURBS curve. The modified chord length parameterization method [33] is employed to ensure that the NURBS curve passes through a set of given control points \(p_{i}(i=0,1,\ldots,m)\).  
After determining the knot vector, a system of m + 1 linear equations is formed from the m + 1 given control points. Since there are \(n+1=m+3\) control points to solve for, two additional equations are required to find all unknowns. These equations are typically derived by adding boundary conditions at both ends of the curve, which allows for determining the NURBS curve's control vertices and subsequently deriving its parametric equation.  
To reduce computational load and enhance system real-time performance, a local interpolation method is used to generate the weld seam trajectory. A threshold \(\alpha\) for the number of feature points is set. When the number of new feature points reaches \(\alpha\)  
Figure 10: Cylindrical filtering process. (**a**) New data point inside the cylindrical space; (**b**) new data point outside the cylindrical space. The blue dots in the figure represent the feature points previously detected by the sensor, while the yellow dots indicate the most recently detected feature points. The red dashed lines illustrate the principal components derived from the PCA algorithm, which correspond to the cylinder’s axis.  
interpolation is performed on these \(\alpha\) points. The initial boundary conditions for the new interpolated NURBS curve use the tangent vector method, with the tangent direction taken from the last point of the previous NURBS curve. The endpoint boundary condition is set to a free endpoint condition [34]. During system initialization, free endpoint conditions are applied at both ends, thus achieving NURBS local interpolation.  
For posture adjustment, a simple and effective spatial vector-based algorithm is used, as shown in Figure 11. The steps are as follows:  
Step 1: Align the laser vision sensor with the weld seam and obtain the vector between the welding torch tip and the weld seam starting point as the reference vector \(V_{ref}\). Set a rotation angle threshold \(\varepsilon\) to complete initialization.  
Step 2: When the laser vision sensor captures a new weld seam coordinate point, determine the vector between the welding torch tip and this coordinate point as the current vector \(V_{cur}\).  
Step 3: Compute the cross product between the current vector \(V_{cur}\) and the reference vector \(V_{ref}\) to determine the rotation axis \(l\), and use the dot product to calculate the rotation angle \(\theta\).  
Step 4: Compare the rotation angle \(\theta\) with the threshold \(\varepsilon\). If \(\theta\) is less than \(\varepsilon\epsilon\), maintain the original posture. Otherwise, if \(\theta\) is greater than \(\varepsilon\), control the robot arm to rotate around axis \(l\) by an angle of \(K\cdot\theta\), where \(K\) is the rotation angle gain.