## 2 Proposed Screw Unfastening Strategy
### Screw-Tool Engagement Method Based on Screw Pose Calculation
(**a**) Edges extracted with _Canny_ filter. (**b**) Edges used to describe the screw-head feature. between a beginning point and the corresponding end point can be fitted using a linear equation, which can form six sides of a hexagon through extensions. The linear equation includes the following relations:  
\[\left\{ \begin{array}{l}y_{i}=k_{i}x_{i}+b_{i}\\ y_{i}=r_{i}/n_{i}\\ b_{i}=RowBegin_{i}-k_{i}ColBegin_{i}\end{array} \right. \tag{5}\]  
\[\left\{ \begin{array}{l}r_{i}=RowBegin_{i}-RowEnd_{i}\\ n_{i}=ColBegin_{i}-ColEnd_{i}\end{array} \right. \tag{6}\]  
where \(k_{i}\) and \(b_{i}\) means function parameters of the \(i\)-th line. As shown in Figure 17, an intersection \(P_{i}\) and its 2D location denoted by \(P_{i}\big{(}P_{ix},P_{iy}\big{)}\) can be obtained by Equations (3) and (4), based on which the hexagonal center \(P_{c}\big{(}P_{cx},P_{oy}\big{)}\) can be determined as follows:  
\[\left\{ \begin{array}{l}P_{cx}=\sum P_{ix}/i\\ P_{cy}=\sum P_{iy}/i\end{array} \right. \tag{7}\]  
Based on the above-presented processing and calculations, a 2D location of a screw \(O_{xy}^{s}\) in the camera frame can be obtained. Relative relationships between the centers of the screw, tool frame, and camera frame are shown in Figure 18.  
_(2) Engagement motion guided by robot_: In real situations, the bottom of loose screws is always not tightly close to the top surface of a workpiece, which means that it is difficult to estimate the distance between the bottom of the robotic tool and the top of the screw  
Figure 17: Lines, intersections, and center point used to describe the screw head. Figure 18: Locations of centers of the screw, tool frame, and camera frame. precisely based only on the above calculation equations. To solve this problem, an estimation method of distance \(Z_{s}\) is proposed to avoid the damage of the end effector on a screw or workpiece. In the proposed method, the length of a hexagonal side is used to represent the screw size, and its value \(S_{image}\) in the image plane can be calculated as an average length of six sides based on 2D locations of intersections \(P_{i}\big{(}P_{lx},P_{ly}\big{)}\). Then, the distance \(Z_{s}\) between the screw and the camera can be calculated according to the imaging principle of a monocular camera as follows:  
\[Z_{s}=f\cdot S_{real}/S_{image} \tag{8}\]  
where \(S_{real}\) and \(f\) denote the real length of one side and the camera focus, respectively. Then, a 3D location of a screw \(O^{\mathrm{s}}_{xyz}=[O^{\mathrm{s}}_{xy},Z_{s}]\) in the camera frame can be obtained. Based on the conversion matrix \(\mathbf{R}^{tool}_{scam}\) obtained from the hand-eye calibration of the monocular camera [33], the screw position \(O^{t}_{xyz}=\mathbf{R}^{tool}_{scam}\cdot O^{\mathrm{s}}_{xyz}\) in the tool frame can be calculated. Based on the screw position calculation result, the tool center can reach the position of the screw head. However, six vertexes \(P_{i}\) of the screw cannot correspond to points \(P_{i}^{t}\) of the tool, which is significant for the screw-tool engagement, as shown in Figure 19. To achieve a perfect engagement of the screw head and the tool, an angular offset \(\theta\) between the coordinate systems of the screw and tool is introduced and calculated based on the directional vectors of \(xoy\) and \(x_{t}oy_{t}\), which can be determined by the location of the screw center and one intersection \(P_{i}\), and by the forward kinematics of the robot, respectively. Then, the screw can engage with the tool by rotating \(\theta\) along the tool axis. Based on the screw pose \(O^{t}_{xyz}\) and the rotational angle \(\theta\), joint angles \(\mathbf{JA}\) of a robot can be calculated based on its inverse kinematics model, which was presented in detail by [PERSON] [34].