# Automatic Assembly Technology of Dense Small Screws for Flat Panel Parts
## 2 Methods
### Screw Assembly Quality Assessment
#### 2.4.2 Screw Assembly Quality Assessment  
The process of the screw assembly assessment method is shown in Figure 16. First, the actual angle-torque curve is obtained by the torque sensor and motor encoder. The Frechet distance between the curve and each template is then calculated to determine similarity. Subsequently, the assembly quality of the screw is assessed. Through experiments, several angle-torque curves can be obtained during screw assembly. The curve representing a satisfactory screw assembly is selected as the reference curve, and point \((x_{i},y_{i})\) on multiple reference curves is fitted by a polynomial given by Equation (11):  
\[\hat{y}=a_{0}+a_{1}x+a_{2}x^{2}+\ldots+a_{n-1}x^{n-1}+a_{n}x^{n} \tag{11}\]  
Solving the \(n+1\) best-fit coefficients, \(a_{0}\)-\(a_{n}\), in the polynomial of degree \(n\) is necessary. The square sum of the residuals was used as the error function to determine the fitting effect. The smaller the square sum of the residuals, the better the fitting effect. The abscissa, \(x_{i}\), of the sample is inserted into the fitted polynomial, \(\hat{y}\), to obtain the new ordinate, \(\hat{y}_{i}\). The sum of the squares of residuals is obtained by Equation (12):  
\[\varepsilon=\sum_{i=1}^{n}\left(\hat{y}_{i}-y_{i}\right)^{2} \tag{12}\]  
The least squares method is applied to solve the group \((a_{0},a_{1},a_{2},\ldots,a_{n-1},a_{n})\) and minimize the sum of the squares of residuals (i.e., the polynomial). After the calculation, the fitting curve shown in Figure 17 is obtained; the curve is the template for the successful assembly of screws. Figure 16: Assessment process of screw assembly quality. **Definition 1**. : _Let a curve be a continuous mapping of \(f\):\([a,b]\to\mathrm{V}\), among \(a,b\in R,a\leq b\), where (\(\mathrm{V}\),\(d\)) is a metric space. Then, two curves can be formed: \(f\):\([a,b]\to\mathrm{V}\) and \(g\):\([a^{\prime},b^{\prime}]\to\mathrm{V}\). The Frechet distance between the two curves is defined by Equation (13) [21]:_  
\[\delta_{F}(f,g)=\inf_{\alpha,\beta\in[0,1]}\{d(f(\alpha(t)),g(\beta(t)))\} \tag{13}\]  
where  
\(\alpha\) is any continuous non-decreasing function from \([0,1]\) to \([a,b]\),  
\(\beta\) is any continuous non-decreasing function from \([0,1]\) to \([a^{\prime},b^{\prime}]\). If the angle-torque curve to be identified is \(\mathrm{L}_{1}\) and the curve template for successful screw assembly is \(\mathrm{L}_{2}\), then the calculation process of the Frechet distance between \(\mathrm{L}_{1}\) and \(\mathrm{L}_{2}\) is as follows. (1) Discretize \(\mathrm{L}_{1}\) into m points, as follows:  
\[P=\{(x_{1},y_{1}),(x_{2},y_{2}),\ldots,(x_{m},y_{m}),\ldots,(x_{M},y_{M})\} \tag{14}\]  
where \(x_{m}\) and \(y_{m}\) are the abscissa and ordinate of the \(m\)th point, respectively. (2) Similarly, discretize \(\mathrm{L}_{2}\) into \(n\) points as follows:  
\[Q=\left\{(x_{1}{}^{\prime},y_{1}{}^{\prime}),(x_{2}{}^{\prime},y_{2}{}^{\prime }),\ldots,(x_{n}{}^{\prime},y_{n}{}^{\prime}),\ldots,(x_{N}{}^{\prime},y_{N}{} ^{\prime})\right\} \tag{15}\]  
where \(x_{n}{}^{\prime}\) and \(y_{n}{}^{\prime}\) are the abscissa and ordinate of the \(n\)th point, respectively. (3) Calculate the Euclidean distance from each point on curve \(P\) to each point on curve \(Q\) (expressed by distance matrix \(D\)):  
\[D= \begin{bmatrix}d_{11}&\cdots&d_{1n}&\cdots&d_{1N}\\ \vdots&\ddots&\vdots&\ddots&\vdots\\ d_{m1}&\cdots&d_{mm}&\cdots&d_{mN}\\ \vdots&\ddots&\vdots&\ddots&\vdots\\ d_{M1}&\cdots&d_{Mn}&\cdots&d_{MN}\\ \end{bmatrix}  \tag{16}\]  
Figure 17: Angle–torque curve of successfully assembled screws. where \(d_{mn}\) is the Euclidean distance from the \(m\)th point on curve L\({}_{1}\) to the \(n\)th point on curve L\({}_{2}\). (4) Create a matrix, \(F\), whose element values are given by Equation (17):  
\[F_{ij}= \begin{cases}\max\ (d_{ij},\min(d_{i-1,j-1},d_{i,j-1},d_{i-1,j}))&i>0,j>0\\ \max\ (d_{ij},d_{0j-1})&i=0,j>0\\ \max\ (d_{ij},d_{i-1,0})&i>0,j=0\\ d_{ij}&i=0,j=0\end{cases}