# System Design and Monitoring Method of Robot Grinding for Friction Stir Weld Seam
## 2 Method
### Extraction Method of Weld Seam
#### 2.2.1 Weld Seam Detection  
Generally, the welded workpieces have relatively low curvatures, and weld seams generated on the surface have a relatively small size. Although the surface's curvature is low, there still exist lots of problems when using the traditional method to select the part of the weld seam. The authors have tested the least square method and the method based on the slope between points, but the results are not correct. Therefore, a method based on point cloud registration and graph-cut is adopted. Before the detection, a method to remove the noise of the point cloud in [29] is adopted. Then, the detection method is described in detail as follows. Firstly, the initial registration between the scanned point cloud (scan point cloud) and the point cloud (standard point cloud) sampled from the Computer Aided Design (CAD) model is used, and then the initial weld seam part can be obtained. However, since the surface of each workpiece is not precisely equal to the CAD model, especially when the weld seam is small relative to the base metal, a small  
Figure 3: Design of the grinding tool. curvature change easily leads to a large deviation of the result. So the obtained weld seam part is not always correct, and a more elaborate method is necessary. In this paper, in order to detect out a complete and accurate weld seam from each workpiece, the authors model this process as an energy optimization problem. However, simultaneously optimizing all the points in the point cloud is time-consuming. After designing a energy function for weld seam detection, an efficient optimization method is also needed. A coarse-to-fine strategy is adopted in the optimization to speed it up. We define \(\left\{point_{i}\right\}=\left\{\left\{Wpoint_{i}\right\}\right\},\left\{ Bpoint_{k}\right\}\), where \(\left\{Wpoint_{j}\right\}\) are weld seam points and \(\left\{Bpoint_{k}\right\}\) are background points. The whole point cloud is \(\left\{point_{i}\right\}\). The energy is explained as follows,  
\[E_{total}=E_{data}+E_{pairwise}+E_{consist}. \tag{1}\]  
Three parts of the energy function are defined as:  
\[E_{data}=\sum_{p\in\left\{Point_{i}\right\}}R_{p}\left(l_{p}\right), \tag{2}\]  
where \(R_{p}\left(l_{p}\right)\) is a penalty for assigning labels to one point \(p\) in point cloud \(\left\{point_{i}\right\}\). \[E_{pairwise}=\sum_{\left\{p\
ot\in N\right\}}B_{<p,q>}\delta\left(l_{p},l_{q} \right), \tag{3}\]  
where \(q\) is another point,  
\[\delta\left(l_{p},l_{q}\right)=\left\{ \begin{array}{ccc}0&if&l_{p}=l_{q}\\ 1&if&l_{p}\
eq l_{q}\end{array} \right., \tag{4}\]  
and  
\[B_{<p,q>}\propto\exp\left(-\frac{\left(Pr_{p}-Pr_{q}\right)^{2}}{2\sigma^{2} }\right), \tag{5}\]  
where \(\sigma\) is a constant, and  
\[P_{r_{p}}=Ae^{-\left(d-d^{\prime}\right)^{2}}/2, \tag{6}\]  
where \(d\) is scanning result while \(d^{\prime}\) is the result from CAD model. We have assumed that the weld seam is continuous, so  
\[E_{consist}=\left\{ \begin{array}{ccc}0&C(\left\{Wpoint_{j}\right\})=1\\ \infty&C(\left\{Wpoint_{j}\right\})=0\end{array} \right., \tag{7}\]  
where \(C\) is a judgment function, and it aims to judge whether the points are consist. Its function is realized by judging whether the minimum value of the distance between every two points in the point cloud exceeds the threshold. In fact, the energy function \(E_{total}\) can be directly adopted for optimization, and the optimization method in [30] is adopted. However, the scanning point cloud is relatively dense, so this method will lead to slow computing speed. So a coarse-to-fine method is presented in this step for optimization, and it contains:  
(1) Voxel segmentation. First, segment the point cloud into voxels. (2) Initialization. For each voxel, its probability of containing points belonging to the weld seam is defined according to the result of the registration.