## 2 Online 3D Trajectory Generation for Deburring Processing
### Fit the Equations of Boundary Contour Curves (S130, S140) in Linear Contour Scanning  
In metal and plastic processing, many processes (e.g., casting, forging, and injection molding) can be used to mold workpieces quickly. However, they also produce high engineering tolerances, resulting in large discrepancies between the actual workpiece dimensions and standard dimensions. When this happens, using the original contour curves obtained from the CAD model as the contours of the actual workpieces is impossible, and linear contour scanning sensors must be used to determine the boundary contours. This method can use the engineering tolerances obtained during processing to identify  
Figure 3: Residual plot analyses: (**a**,**b**) nonconstant residuals, and (**c**) unsuitable model. Figure 2: Deburring regions: (**a**) processed edges, (**b**) parting lines, and (**c**) gates/risers. the actual workpiece contours, compensate for robotic arm dynamic errors online, and improve the precision of robotic arm control. The calculation procedure is as follows:  
1. After the mathematical models for the boundary contour curves of the target workpieces are determined, the workpiece contour cross-sectional information is obtained using linear contour scanning sensors. When the sensors move and scan the workpiece contours, they obtain as much information regarding the contours near burrs as possible by setting the burrs as the center of the scans (Figure 4). 2. The contour information obtained using the linear contour scanning sensors is processed, and the random sample consensus (RANSAC) method [22] is used to perform the fitting. This prevents burr information from influencing the curve fitting results. * Letting \(i=0\), \(t=0\), \(m_{\text{best}}=\text{null}\), \(f_{\text{best}}=\text{null}\), and \(t_{\text{max}}=\text{null}\), the mathematical models for the boundary curves are selected (similar to Step 3). * A total of \(n\) samples are randomly selected, and the models are fit to obtain the curve equation \(f_{i}\). * Letting \(m_{i}=0\) and \(n_{i}=0\), the data points are substituted into the curve equations to calculate the errors (\(\delta_{k}\)), where \(m_{i}\) and \(n_{i}\) are the number of interior points and exterior points, respectively. * \(\delta_{k}\) is compared with the allowable error (\(\epsilon\)): if \(\delta_{k}<\epsilon\), \(m_{i}=m_{i}+1\); otherwise, \(n_{i}=n_{i}+1\). * If \(m_{\text{best}}<m_{i}\), then \(m_{\text{best}}=m_{i}\) and \(f_{\text{best}}=f_{i}\). * When \(t=t+1\), if \(t_{\text{max}}\
eq\text{null}\) and \(t>t_{\text{max}}\), the RANSAC procedure is performed with \(t_{\text{max}}\) as the number of iterations. If not, the number of iterations is updated to \(t_{\text{max}}=\frac{\log(1-P)}{\log(1-r^{4})}\), where \(P\) is the expected probability of RANSAC obtaining the correct model, and \(r\) is the ratio \(\frac{m_{i}}{m_{i}+n_{i}}\), which is based on the numbers of interior and exterior points. 3. Curve fitting is performed on the curve models obtained using the CAD cross-sectional contour characteristics. Using a fourth-order polynomial boundary curve equation as an example, the procedure is as follows: * The fourth-order polynomial model is expanded to \(f(x)=a_{0}+a_{1}x+a_{2}x^{2}+a_{3}x^{3}+a_{4}x^{4}\). * If the contour curves are the curves of two different models, the contour points obtained from linear contour scanning are divided into head and tail sections for fitting; if the contour curves are the curves of a single model, the head and tail contour points obtained from linear contour scanning are substituted into the equations for fitting.