# Finding orientation angles of end-effector from the DH parameter table and transformation matrices

Let's say we have a manipulator with the following DH parameter table: and transformation matrices: $$A_{01}= \begin{bmatrix} \cos(q_1) & \sin(q_1) & 0 & 95\cos(q_1)\\ \sin(q_1) & -\cos(q_1) & 0 & 95\sin(q_1)\\ 0 & 0 & -1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}$$ $$A_{12}= \begin{bmatrix} \cos(q_2) & 0 & \sin(q_2) & 89\cos(q_2)\\ \sin(q_2) & 0 & -\cos(q_2) & 89\sin(q_2)\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}$$ $$A_{23}= \begin{bmatrix} \cos(q_3) & -\sin(q_3) & 0 & 147\cos(q_3)\\ \sin(q_2) & \cos(q_2) & 0 & 147\sin(q_2)\\ 0 & 0 & 1 & -28\\ 0 & 0 & 0 & 1 \end{bmatrix}$$ When multiplied, they form the absolute transformation matrix of the end-effector relative to the reference frame: $$A_{03}=A_{01}\cdot A_{12}\cdot A_{23}=$$ $$\begin{bmatrix} \cos(q_3)\cos(q_1-q_2) & -\sin(q_3)\cos(q_1-q_2) & -\sin(q_1-q_2) & 95\cos(q_1)+28\sin(q_1-q_2)+89\cos(q_1-q_2)+147\cos(q_3)\cos(q_1-q_2)\\ \cos(q_3)\sin(q_1-q_2) & -\sin(q_3)\sin(q_1-q_2) & \cos(q_1-q_2) & 95\sin(q_1)-28\cos(q_1-q_2)+89\sin(q_0-q_1)+147\cos(q_3)\sin(q_1-q_2)\\ -\sin(q_3) & -\cos(q_3) & 0 & -147\sin(q_3)\\ 0 & 0 & 0 & 1 \end{bmatrix}$$ We can easily read the position of the end-effector relative to the reference frame just from the fourth column of the $$A_{03}$$ matrix:

$$\begin{bmatrix} x\\ y\\ z \end{bmatrix} =$$ $$\begin{bmatrix} 95\cos(q_1)+28\sin(q_1-q_2)+89\cos(q_1-q_2)+147\cos(q_3)\cos(q_1-q_2)\\ 95\sin(q_1)-28\cos(q_1-q_2)+89\sin(q_0-q_1)+147\cos(q_3)\sin(q_1-q_2)\\ -147\sin(q_3) \end{bmatrix}$$

How can we read the orientation of the end-effector relative to the reference frame?

Your $$A_{0.3}$$ matrix is a 4x4 transformation matrix. In a general form these 4x4 matrices can be subdivided into a 3x3 rotation and a 3x1 translation part. (The remaining parts can be used for scaling, but are not used in robotics)
$$A_{0,3}= T_{4 \times 4}= \begin{pmatrix} R_{3 \times 3} & T_{3 \times 1}\\ 0_{1 \times 3} & 1 \end{pmatrix}$$
The $$R_{3 \times 3}$$ part is a 3x3 rotation matrix, also called a direction cosine matrix. Basically it is built from the coordinates of the unit vectors of the end effector coordinate system expressed in the reference coordinate system. This guide describes how to convert this matrix to Euler angles.