**5. Direct kinematics**

As mentioned in the previous chapter, reverse kinematics needs the position of the final effector as input parameters to calculate the angles between links of the robot. So, the direct kinematics is the counterpart of inverse kinematics, since its initial data are the angles established between each actuator and what is calculated is the position of the final effector. A very common method of using is Denavit-Hartenberg, explained by Barrientos, which follows a 16-step algorithm to get a single homogeneous transformation matrix from the premultiplication of submatrices of homogeneous transformation. The steps of this methodology are the following [14]:

DH1. Number the links starting with 1 (first mobile link in the chain) and ending with *n* (last mobile link). The fixed base of the robot will be numbered as link 0.

DH2. Number each joint starting with 1 (the one corresponding to the first degree of freedom) and ending in n.

DH3. Locate the axis of each joint. If this is rotary, the axis will be its own axis of rotation. Yes it is prismatic, it will be the axis along which the displacement occurs.

DH4. To *i* from 0 to *n* � 1, place the axis *zi* on the axis of the joint *i* þ 1.

DH5. Place the origin of the base system f g *S*<sup>0</sup> at any point on the *z*<sup>0</sup> axis. The axes *x*<sup>0</sup> and *y*<sup>0</sup> are they will place so that they form a dextrogyre system with *z*0.

DH6. For *i* from 1 to *n* � 1, place the system f g *S*<sup>0</sup> (in solidarity with the link) at the intersection of the axis *zi* with the normal line common to *zi*�<sup>1</sup> and *zi*. If both axes were cut, it would be located f g *Si* at the point of cut. If they were parallel *S*0, it would be located in the joint *i* � 1.

DH7. Place *xi* on the normal line common to *zi*�<sup>1</sup> and *zi*.

DH8. Position *yi* so that it forms a dextrogyre system with *zi* and *xi*.

DH9. Position the system f g *Sn* at the end of the robot so that *zn* matches the direction of *zn*�<sup>1</sup> and *xn* be normal to *zn*�<sup>1</sup> and *zn*.

DH10. Get *θ<sup>i</sup>* as the angle to be rotated around *zn*�<sup>1</sup> so that *xn*�<sup>1</sup> and f g *Si* remain parallel.

DH11. Get *di* as the distance measured along *zi*�1, which should be displaced f g *Si* so that *xi*�<sup>1</sup> and *xi* were aligned.

DH12. Obtain *α<sup>i</sup>* as the distance measured along *xi* (which would now match *xi*�1), so that the new f g *Si*�<sup>1</sup> would have to be moved so that its origin coincided with f g *Si* .

DH13. Get *α<sup>i</sup>* as the angle that should be turned around *xi* (which would now match *xi*�<sup>1</sup> so that the new f g *Si*�<sup>1</sup> totally coincided with f g *Si* .

*Stewart-Gough Platform: Design and Construction with a Digital PID Controller Implementation DOI: http://dx.doi.org/10.5772/intechopen.91817*

DH14. Obtain the transformation matrices *<sup>i</sup>*�<sup>1</sup>*Ai* defined as:

$${}^{i-1}A\_i = \begin{bmatrix} c\theta\_i & -ca\_i s\theta\_i & s\alpha\_i s\theta\_i & a\_i c\theta\_i \\ s\theta\_i & c\alpha\_i c\theta\_i & -s\alpha\_i c\theta\_i & a\_i s\theta\_i \\ \mathbf{0} & s\alpha\_i & c\alpha\_i & d\_i \\ \mathbf{0} & \mathbf{0} & \mathbf{0} & \mathbf{1} \end{bmatrix} \tag{3}$$
