# XOR Binary Gravitational Search Algorithm with Repository: Industry 4.0 Applications
## 6 Industry 4.0 Applications
### Motion Planning of Industrial Robots Inside a Digital Twin Created by V-REP Software
#### 6.1.2 Kinematic and Inverse Kinematic of UR5  
The UR5 robot benefits from 6-degrees of freedom. Position and orientation of this robot and its end-effector in 3D work-space is represented by \(x\in R^{6}\). While the first three dimensions of this vector present three translational variables, the next three dimensions represent its orientation. The joint angles, represented by \(q=\left[ \begin{array}{cccc}q_{1}&q_{2}&\ldots&q_{6}\end{array} \right]\), are solutions to the inverse kinematic problem. \begin{table}
\begin{tabular}{l l l l} \hline \hline \multicolumn{2}{l}{**Movements**} & \multicolumn{2}{l}{**Rotations**} \\ \hline
**Value** & **Interpretation** & **Value** & **Interpretation** \\ \hline
0 & \(x=x+0.025\) & 4 & \(z=z+0.025\) \\ \hline
1 & \(x=x-0.025\) & 5 & \(z=z-0.025\) \\ \hline
2 & \(y=y+0.025\) & 6 & \(x=x+0.025\) \\ \hline
3 & \(y=y-0.025\) & 7 & \(x=x-0.025\) \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Interpretation of values of array generated by the proposed XOR BGSA. Figure 9: Digital twin of manufacturing environment developed in V-REP. The forward kinematic function is the function used to compute the position and orientation of the robot corresponding to its assigned joint angles. \[x=\mathcal{FK}(\mathbf{q}) \tag{73}\]  
The standard Denavit-Hartenberg (DH) convention to represent the forward kinematics of the robot is used in this paper. The DH parameters associated with UR5 are presented in Table 6. Using such convention, inverse kinematic of the robot can be found as follows:  
\[x{=}T_{1}^{0}T_{2}^{1}T_{3}^{2}T_{4}^{3}T_{5}^{4}T_{6}^{5} \tag{74}\]  
where \(T_{i}^{i-1}\) presents the homogeneous transformation matrix which makes the transform from frame \(i-1\) to frame \(i\) defined as follows:  
\[T_{i}^{i-1}=\left[ \begin{array}{cccc}c(q_{i})&-s(q_{i})c(\alpha_{i})&s(q_{i} )s(\alpha_{i})&r_{i}c(q_{i})\\ s(q_{i})&c(q_{i})c(\alpha_{i})&-c(q_{i})s(\alpha_{i})&r_{i}s(q_{i})\\ 0&s(\alpha_{i})&c(\alpha_{i})&d_{i}\\ 0&0&0&1\end{array} \right] \tag{75}\]  
where \(s(. )\) and \(c(. )\) represent the sinus and cosine of their arguments. The values obtained from the movement array need to be translated in terms of robot movements. To enable this a transformation matrix that represents position and orientation of robot is obtained based on work by [30; 31]. The transformation matrix for frame 6 with respect to frame 0 is as follows:  
\[{}_{0}^{6}T\left(\theta_{1},\theta_{2},\theta_{3},\theta_{4},\theta_{5},\theta _{6}\right)=\left[ \begin{array}{cccc}0&R&0P\\ 6&R&6P\\ 0&1\end{array} \right]=\left[ \begin{array}{cccc}0&\hat{\zeta}_{x}&0\hat{ \zeta}_{x}&0\hat{\zeta}_{x}&0\hat{\zeta}_{x}&0P_{x}\\ 0&\hat{\zeta}_{y}&0\hat{\zeta}_{y}&0\hat{\zeta}_{y}&0\hat{\zeta}_{y}\\ 0&\hat{\zeta}_{z}&0\hat{\zeta}_{z}&0\hat{\zeta}_{z}&0\hat{\zeta}_{z}&0\hat{ \zeta}_{z}\\ 0&0&0&1\end{array} \right] \tag{76}\]  
where \({}_{6}^{0}\hat{\zeta}\), \({}_{6}^{0}\hat{\zeta}\) and \({}_{6}^{0}\hat{Z}\) are unit vectors defining the axis of frame 6 in relation to frame 0 and:  
\[{}_{6}^{0}R=R_{x}\left(a\right)R_{y}(b)R_{z}(c)\]  
in which the rotational matrices are obtained as follows:  
\[R_{x}{=}\left[ \begin{array}{cccc}1&0&0\\ 0&cosa&-sina\\ 0&sina&cosa\end{array} \right] \tag{77}\]  
\[R_{y}{=}\left[ \begin{array}{cccc}cosb&0&sinb\\ 0&1&0\\ -sinb&0&cosb\end{array} \right] \tag{78}\]  
\[R_{z}{=}\left[ \begin{array}{cccc}cosc&-sinc&0\\ sinc&cosc&0\\ 0&0&1\end{array} \right] \tag{79}\]Inverse kinematics are then used to find joint angles of robot to move to a desired position given by proposed XOR BGSA. The angles of the robot are then obtained as [30; 31]:  
\[\theta_{1} = atan2\left( \begin{matrix}0\\ 5y\end{matrix} P \begin{matrix}0\\ 5x\end{matrix}