# System Design and Monitoring Method of Robot Grinding for Friction Stir Weld Seam
## 2 Method
### Monitor Method of Grinding Process Based on PSO-SVM
#### 2.3.4 Classification Method  
Since the grinding result can only be observed after processing, it is not possible to obtain a specific time in the experiment where excessive grinding occurs. Therefore, some state estimation methods such as Hidden Markov Models cannot be used because the time points of state transition cannot be labeled. So, the output of the monitor method is the state of the workpiece after grinding, which is normal processing (0) and excessive grinding (1).  
As shown in Figure 7, the classification method based on Particle Swarm Optimization-Support Vector Machine (PSO-SVM) is presented to identify the status of the grinding process. In the PSO-SVM framework, the input includes force features in the past period of time \(f_{1},f_{2},f_{3},f_{4},f_{5}\) and the calculated weld seam characteristic values \(p_{1}\) and \(p_{2}\) in advance.  
Support Vector Machine (SVM) is used to solve the classification problem and regression problem, and to find the decision boundary of edge maximization. In general, it can be considered as the optimal form of Lagrangian function under the constraint condition in its dual problem:  
\[\bar{L}\left(\mathbf{a}\right)=\sum_{n=1}^{N}a_{n}-\frac{1}{2}\sum_{n=1}^{N} \sum_{m=1}^{N}a_{n}a_{m}t_{n}t_{m}k\left(x_{n},x_{m}\right). \tag{19}\]  
\[s.t.\sum_{i=1}^{n}\alpha_{i}y_{i}=0.\]  
\[0\leq\alpha_{i}\leq C,for\ i=1,2,\ldots,n,\]  
Figure 7: Classification method for monitor.  
where \(\mathbf{a}\) is the Lagrange multiplier, \(t\) is the label term, \(x\) is the feature space, and \(C\) is the penalty parameter. For samples in high dimensional space, Gaussian kernel function is used to represent inner product in feature space, namely:  
\[K(x,y)=e^{-\gamma||x-y||^{2}}, \tag{20}\]  
where \(\gamma\) is the parameter of Gaussian kernel function.  
In this method, the seven parameters are input into the SVM classifier, and to improve the accuracy, a particle swarm optimization (PSO) method is combined, as shown in Algorithm 1. In the algorithm, the input is the seven features and the label (normal processing (0) or excessive grinding (1)) of all the samples. This algorithm improves the accuracy of classification by continuously optimizing the parameters \(C\) and \(\gamma\) in the SVM model. For the case that the total number of samples is not very large, the authors use the cross-validation method to calculate the accuracy of each particle.  
```
\(\{f_{1i}\}\), \(\{f_{2i}\}\), \(\{f_{3i}\}\), \(\{f_{4i}\}\), \(\{f_{5i}\}\), \(\{p_{1i}\}\), \(\{p_{2i}\}\), \(\{label_{i}\}\) \(c_{o}\), \(\gamma_{o}\)  Initialize particle swarm and parameters \(\{c_{n}\}\), \(\{\gamma_{n}\}\).  Set generation time \(T=1\)  Compute SVM accuracy \(Acc_{a}\) for each particle \(\{c_{a}\}\), \(\{\gamma_{a}\}\) using 5-fold cross validation.  Set fitness of every particle \(fitness=Acc_{a}\).  Update individual optimal value \(P_{best}\) and group optimal value \(G_{best}\). while Convergence condition not satisfied do  Update position and velocity vectors for each particle.  Compute fitness of every particle using the above method.  Update individual optimal value \(P_{best}\) and group optimal value \(G_{best}\).  Set \(T=T+1\) endwhile \(\{c_{o},\gamma_{o}\}=P_{best}\)
```  
**Algorithm 1** Classification Method based on PSO-SVM