# An Algorithm for Painting Large Objects Based on a Nine-Axis UR5 Robotic Manipulator
## 4 The Inverse Solution Model of Kinematics of the 9-Axis UR5 Robot
### Inverse Solution Model for Recommended Regions  
The three joint axes of the UR5 robot, joint axes 2, 3 and 4, which are shown in Figure 14, are parallel, and their spatial structure satisfies the Pieper criterion. The closed-form solution method can be harnessed to solve the angular sequence of the UR5 robot joint under the target pose constraints.  
Equation (14) determines the pose of the end-effector of the UR5 robot.  
\[\underset{i=1}{\overset{6}{\prod}}\mathbf{I}_{i}^{i-1}\mathbf{T}=(\mathbf{Trans }(t_{x},\ t_{y},\ t_{z})\mathbf{Rot}(x,\pi))^{-1}\cdot\mathbf{T}\cdot(\mathbf{ T}_{tool}\cdot\mathbf{T}_{dis})^{-1}=\begin{bmatrix}n_{x}&o_{x}&a_{x}&x^{ \prime}\\ n_{y}&o_{y}&a_{y}&y^{\prime}_{\prime}\\ n_{z}&o_{z}&a_{z}&z\\ 0&0&0&1\end{bmatrix} \tag{14}\]  
The main idea of the closed-form solution is creating the constraint equation established by matrix changes. The constraint matrix of the UR5 robot, which is shown in Equation (15), is established in accordance with Equation (11). The third row of the left and right sides of Equation (15) is expanded to establish Equation (16). Equation (16) can be regarded as the equation set of \(\theta_{1}\), \(\theta_{5}\), and \(\theta_{6}\).  
The procedure for finding the values of \(\theta_{2}\), \(\theta_{3}\), and \(\theta_{4}\) is similar.  
\[\mathbf{L}=(\overset{0}{1}\mathbf{T}^{-1})\mathbf{T}_{\text{robot}}=\underset {i=2}{\overset{6}{\prod}}i^{i-1}\mathbf{T}=\mathbf{R} \tag{15}\]  
\[\begin{bmatrix}\c\theta_{6}\text{s}\theta_{5}\\ \text{s}\theta_{6}\text{s}\theta_{5}\\ \text{c}\theta_{5}\\ d_{2}+d_{3}+d_{4}+d_{6}\text{c}\theta_{5}+a_{5}\text{s}\theta_{5}+a_{6}\text{c} \theta_{6}\text{s}\theta_{5}\end{bmatrix}^{T}=\begin{bmatrix}n_{y}\text{c} \theta_{1}+n_{x}\text{s}\theta_{1}\\ o_{y}\text{c}\theta_{1}+o_{x}\text{s}\theta_{1}\\ a_{y}\text{c}\theta_{1}+n_{x}\text{s}\theta_{1}\\ y\text{c}\theta_{1}+x\text{s}\theta_{1}\end{bmatrix}^{T} \tag{16}\]  
By employing Equations (15) and (17), the result can be obtained in Equation (18),  
\[\mathbf{L}=(\overset{0}{1}\mathbf{T}^{-1})\overset{0}{6}\mathbf{T}(\overset{ 4}{5}\mathbf{T}^{-1})(\overset{5}{6}\mathbf{T}^{-1})=\underset{i=2}{\overset{ 4}{\prod}}i^{i-1}\mathbf{T}=\mathbf{R} \tag{17}\]  
Figure 14: The axes of the UR5 robot.  
\[\mathbf{R}=\begin{bmatrix}\ctheta_{234}&0&-8\theta_{234}&a_{3}\cdot\c\theta_{23}+a_{ 3}\cdot\c\theta_{2}+a_{4}\cdot\c\theta_{234}\\ -8\theta_{234}&0&\c\theta_{234}&-a_{3}\cdot\c\theta_{23}-a_{3}\cdot\c\theta_{2} -a_{4}\cdot\c\theta_{234}\\ 0&-1&0&d_{2}+d_{3}+d_{4}\\ 0&0&0&1\end{bmatrix} \tag{18}\]  
where \(\theta_{i_{1}i_{2}\cdots i_{n}}\) is defined in Equation (19).  
\[\theta_{i_{1}i_{2}\cdots i_{n}}=\sum_{j=1}^{n}\theta_{ij} \tag{19}\]  
In Equation (18), \(\theta_{234}\), \(\theta_{23}\), and \(\theta_{2}\) can be acquired by the fourth column of \(\mathbf{R}\) in Equation (17); \(\theta_{2}\), \(\theta_{3}\), and \(\theta_{4}\) can be obtained afterwards. In Equations (16) and (18), s represents the sine function and c represents the cosine function. Nonetheless, the solution involves a large number of inverse trigonometric functions, and the range of the angles within which the UR5 robot's joints move is \(-2\pi\) to \(2\pi\), which results in multiple solutions. Therefore, the solution with the smallest Euler distance from the initial joint angle sequence is selected.