The post D-H convention – tutorial 3 appeared first on R2R's robotic research.

]]>The problem is to derive the transformation matrix of the following manipulator:

By using standard D-H convention we can orient axes in the following way:

In the initial configuration the position of the end effector on *x*-axis is \(l_1\), and on the *y*-axis is \(l_2\), and \(z=l_3\).

It can be seen that the orientation of axis \(^2 x\) can be perpendicular to the previous and the current *z*-axes in many various ways. However, choosing it in the left or right direction would be a mistake, because the \(l_2\) distance would be missing (please see tutorial 2). It must be chosen as a **common normal**, so as presented in the picture.

Let’s assume that the base frame and the end effector frame must be oriented as is visualized on the picture. In this case we can find the D-H parameters as:

\(i\) | \(a_i\) | \(\alpha_i\) | \(d_i\) | \(\theta_i\) |

1 | \(\sqrt{l_1+l_2}\) | 0 | \(0\) | \(\theta_1^* + atan\big(\frac{l_2}{l_1}\big)\) |

2 | 0 | 0 | \(l_3\) | \(\theta_2^* – atan\big(\frac{l_2}{l_1}\big)\) |

It can be seen that equations become complicated since there is \(cos(\theta_i + arctg(\frac{l_2}{l_1}))\) and \(sin(\theta_i + arctg(\frac{l_2}{l_1}))\) inside the matrix. In order to simplified the calculations we can substitute:

\(\zeta_1=\theta_1^* – arctg(\frac{l_2}{l_1})\)

and

\(\zeta_2=\theta_2^* + arctg(\frac{l_2}{l_1})\)

After doing so, the homogonous transformation matrices become:

\(^0 H_1 = \begin{bmatrix}C_{1} & -S_{1} & 0 & \sqrt{l_1^2+l_2^2} C_1\\S_{1} & C_1 & 0 & \sqrt{l_1^2 + l_2^2} S_1\\0& 0 & 1 & 0\\0&0&0&1\end{bmatrix}\)

what after multiplication gives:

\(^0 H_2 = \begin{bmatrix}C_{12} & -S_{12} & 0 & \sqrt{l_1^2+l_2^2}C_1\\S_{12} & C_{12} & 0 & \sqrt{l_1^2+l_2^2} S_1\\0& 0 & 1 & l_3\\0&0&0&1\end{bmatrix}\)It can be also seen, that:

\(\zeta_{12}=\theta_1+atan(\frac{l_2}{l_1})+\theta_2-atan(\frac{l_2}{l_1})=\theta_1+\theta_2\)

while \(x\) and \(y\) position can be simplified as follows:

\(\sqrt{l_1^2+l_2^2}cos(\theta_1+atan(\frac{l_2}{l_1}))=\\= \sqrt{l_1^2+l_2^2}\Big(cos(\theta_1)cos(atan(\frac{l_2}{l_1}))-sin(\theta_1)sin(atan(\frac{l_2}{l_1}))\Big)\)\(sin(atan(\frac{l_2}{l_1}))\) and \(cos(atan(\frac{l_2}{l_1}))\) can be calculated directly by looking at the triangle defined below:

By looking at the triangle the following equations can be derived:

$$tg(\alpha)=x$$

$$\alpha=atan(x)$$

$$cos(\alpha)=\frac{1}{\sqrt{x^2+1}}$$

so

$$cos(\alpha)=cos(atan(x))=\frac{1}{\sqrt{x^2+1}}$$

and

$$sin(\alpha)=sin(atan(x))=\frac{x}{\sqrt{x^2+1}}$$

In the presented case the value of $$x$$ equals $$x=\frac{l_2}{l_1}$$.

This lead to the following equation on $$x$$-coordinate:

\(\sqrt{l_1^2+l_2^2}cos(\theta_1+atan(\frac{l_2}{l_1}))= \sqrt{l_1^2+l_2^2}\Big(cos(\theta_1)\frac{1}{\sqrt{(\frac{l_2}{l_1})^2+1}}-sin(\theta_1)\frac{(\frac{l_2}{l_1})}{\sqrt{\frac{l_2}{l_1}^2+1}}\Big)=\\=\sqrt{l_2^2+l_1^2}\Big(\frac{l_1 cos(\theta_1)}{\sqrt{l_2^2+l_1^2}}-\frac{l_2 sin(\theta_1)}{\sqrt{l_2^2+l_1^2}}\Big)=l_1 cos(\theta_1)-l_2 sin(\theta_1)\)

and the result on \(y\) coordinate is:

\(\sqrt{l_1^2+l_2^2}sin(\theta_1+atan(\frac{l_2}{l_1}))= \sqrt{l_1^2+l_2^2}\Big(sin(\theta_1)\frac{1}{\sqrt{(\frac{l_2}{l_1})^2+1}}+cos(\theta_1)\frac{(\frac{l_2}{l_1})}{\sqrt{\frac{l_2}{l_1}^2+1}}\Big)=\\=\sqrt{l_2^2+l_1^2}\Big(\frac{l_1 sin(\theta_1)}{\sqrt{l_2^2+l_1^2}}+\frac{l_2 cos(\theta_1)}{\sqrt{l_2^2+l_1^2}}\Big)=l_1 sin(\theta_1)+l_2 cos(\theta_1)\)

The final result is:

\(^0 H_2 = \begin{bmatrix}C_{12} & -S_{12} & 0 & l_1 C_1 – l_2 S_1\\S_{12} & C_{12} & 0 & l_1 S_1 + l_2 C_1\\0& 0 & 1 & l_3\\0&0&0&1\end{bmatrix}\).

As illustrated above to get this result is was necessary to solve equations with arcus function tangled in standard trigonometric functions. This might be complicated in a case a manipulator has got more than 2 DoF.

The post D-H convention – tutorial 3 appeared first on R2R's robotic research.

]]>The post D-H convention – tutorial 2 appeared first on R2R's robotic research.

]]>Let’s consider the manipulator which is presented in Fig. 1 below:

After assigning the frame we can get the following relationships:

It can be seen that axis \(^2 x\) must be oriented on the top-down direction according to *x*-axis definition.

In this case if we use the strict interpretation of definition of parameters we would get the following result (this result is wrong):

*Table 1. D-H parameters of a manipulator ( this is wrong!!)*

\(i\) | \(a_i\) | \(\alpha_i\) | \(d_i\) | \(\theta_i\) |

1 | 0 | \(-\frac{\pi}{2}\) | \(l_1\) | \(\theta_1^*\) |

2 | 0 | \(-\frac{\pi}{2}\) | 0 | \(\zeta_2^* = \theta_2^* -\frac{\pi}{2}\) |

3 | 0 | 0 | \(l_3\) | \(\theta_3^*\) |

This is wrong, because \(l_2\) distance is missing. The right table should look like this:

*Table 2. Correct D-H parameters of a manipulator presented in Fig. 1.*

\(i\) | \(a_i\) | \(\alpha_i\) | \(d_i\) | \(\theta_i\) |

1 | 0 | \(-\frac{\pi}{2}\) | \(l_1\) | \(\theta_1^*\) |

2 | 0 | \(-\frac{\pi}{2}\) | 0 | \(\zeta_2^* = \theta_2^* -\frac{\pi}{2}\) |

3 | 0 | 0 | \(l_2+l_3\) | \(\theta_3^*\) |

In this case it was necessary to add previously missing distance \(l_2\).

The individual homogenous transformations matrix in this case are:

\(^0 H_1 = \begin{bmatrix}C_{1} & 0 & -S_{1} & 0\\S_{1} & 0 & C_{1} & 0\\0& -1 & 0 & l_1\\0&0&0&1\end{bmatrix}\) \(^1 H_2 = \begin{bmatrix}C_{2} & 0 & -S_{2} & 0\\S_{2} & 0 & C_{2} & 0\\0& -1 & 0 & 0\\0&0&0&1\end{bmatrix}\)In the matrix \(^1 H_2\) index *2* refers to \(\zeta_2^*\) and not to \(\theta_2^*\).

and the final result is:

\(^0 H_3=^0H_1 \times ^1H_2 \times ^2H_3=\\\begin{bmatrix}C_1 C_2 C_3 + S_1 S_3 & -C_1 C_2 S_3 + S_1 C_3 & -C_1 S_2 & -C_1 S_2(l_2 + l_3)\\S_1 C_2 C_3 – C_1 S_3 & -S_1 C_2 S_3 – C_1 C_3 & -S_1 S_2 & -S_1 S_2(l_2 + l_3)\\-S_2 C_3& S_2 S_3 & -C_2 & -C_2(l_2 + l_3) + l_1\\0&0&0&1\end{bmatrix}\)

In this matrix index \(1\) refers to \(\theta_1^*\), index \(2\) refers to \(\zeta_2^*\) and index \(3\) refers to \(\theta_3^*\).

You can use the methods presented in *D-H tutorial 1* in order to check the correctness of the solution.

Now, let’s see what happens if someone forgets to include the initial offset of the second joint, so when someone assumes, that \(\zeta_2^* = \theta_2^*\). In order to visualize this lets calculate the matrix \(^0 H_3\) when \(\theta_1=0\), \(\zeta_2^ = \theta_2^=0\) and \(\theta_3^=0\). The result is:

\(^0 H_3 = \begin{bmatrix}1 & 0 & 0 & 0\\0 & -1 & 0 & 0\\0& 0 & -1 & l_1 -(l_2+l_3)\\0&0&0&1\end{bmatrix}\)It can be clearly seen, that in this case most of the element are wrong. The manipulator should look like in Fig. 1 and Fig. 2 but instead the matrix shows that it is oriented in a different way. For example according to a Fig. 1 the *x*-position should be \(x=l_2 + l_3\), *y*-position should be \(y=0\) and \(z=l_1\). Only \(y\) element from a matrix is ok. The same analysis can be done to rotation matrix – many elements are wrong.

Meanwhile, when we solve the equation with \(\zeta_2^*=\theta_2^*-\frac{pi}{2}\) how it should be, then we get the following result:

\(^0 H_3 = \begin{bmatrix}0 & 0 & 1 & l_2 + l_3\\0 & -1 & 0 & 0\\1& 0 & 0 & l_1\\0&0&0&1\end{bmatrix}\)Look at the Fig. 1 or 2, everything seems ok now.

Conclusion:**Always remember to include the initial offset**

There is also one thing to explain.

According to resulted parameters, the 3rd joint of the manipulator is in the same place, what the 2nd joint. This is not consistent with a given Fig. 1. Don’t worry. This is OK. Sometimes it happens- it’s just the properties of D-H convention (**what matter in the end is the relation between the world frame and end-effector frame**).

The post D-H convention – tutorial 2 appeared first on R2R's robotic research.

]]>The post Denavit-Hartenberg convention – tutorial 1 appeared first on R2R's robotic research.

]]> *Fig. 1. Manipulator consists of 1 revolute joint oriented perpendicular to a floor and 2 revolute joints parallel to the floor.*

- It can be assumed that the length of links, which are not given, equal 0.
- We can also assume that given distances are in fact distances between rotational/translational axis of joints.

**1st STEP – ATTACHING THE COORDINATES FRAMES**

The first step is to attach Cartesian coordinate systems to individual joints. Variables and parameters of a manipulator will be designated based on these frames. We will use frames to transform systematically among them using matrix transformations in order to get the final model later.

In this example right-sided Cartesian coordinate frames are used:

Z-axes must have direction compatible with joints rotation axes (in case of revolute joints) or moving axes (in case of prismatic joints). |

X-axes lie on common normal to the previous z-axis and actual z-axis. The x-axis is oriented towards joints with higher numbers (from a base to a gripper). |

Common normal generally means that the axis is perpendicular to the previous and current axis.

It is no need to draw *y-axis*, since its direction is known when we already have *x-* and *z-axes*.

Another important part of the convention:

- The
*x-axis*of the 1st coordinate system can be chosen arbitrarily. - The coordinate system of an end effector also can be chosen arbitrarily and usually is selected based on a gripper geometry.
- The assignment of coordinate systems start from 0, so the final index which is assigned to an end effector equals the number of joints (in case there are no passive joints).

After assigning the frames, the manipulator looks like in Fig. 2. You can also assign \(^1 z\), \(^2 z\) and \(^3 z\) in another direction.

**2nd STEP – PARAMETERS AND VARIABLES**

In the D-H convention, there are 3 parameters and 1 variable, or 4 parameters (if there is no active motor in a joint for which parameters belong to).

alpha (\(\alpha\)) – is the angle which is measured about the actual x-axis from the previous z-axis to actual z-axis with a right-hand threaded screw notation (the angle is positive when the rotation is compatible with clock motion). |

Assigning parameters for the 1st joint is done by treating the coordinate system number 1 as the actual coordinate system and the coordinate with index 0 as the previous coordinate frame. By looking at our example, we can derive the first alpha angle after extending \(^0 z\) axis until it crosses the \(^1 x\) axis. After that when we project is on the plane, we get the following relationship:

It is important to look at the [latex]^1 x\)-axis in the direction of increasing the numbers, otherwise, you get result for a left-sided Cartesian coordinate frame. Generally, we cannot mix left- and right-frames since they are characterized by different matrices.

We can see that the angle between \(^0z\) and \(^1 z\) is \(-\frac{pi}{2}\) (rotate \(^0 z\) axis to cover \(^1 z\) axis).

a – is a distance for the first joint which is measured along the current axis from the previous z-axis to current z-axis. If we draw this coordinate frame we can get something like this: |

by looking at the \(^1 x\) from above we get:

The distance between \(z-axes\) is 0 for both figures. Looking at designation methods of alpha and \(a\) can be seen how important it is to assign all axes properly.

d is a distance which is measured along the previous z-axis from the previous x-axis to the current x-axis (for the 1st joint it is measured along \(^0z\) axis from \(^0 x\) to \(^1 x\)). |

when we extend in mind the \(^0z\) axis in this way to intersect \(^0x\) and \(^1x\) axis we will get the following view (*xz*-plane):

The same result we also get by looking from *yz-*plane point of view:

Thus, the distance \(d\) equals \(d_1\)

So the distance \(d\) equals \(d_1\).

theta (\(\theta\)) is an angle which is measured about the previous z-axis from the previous x-axis to the current x-axis, according to right-hand threaded screw (positive angle is in clock-rotation direction). |

When we project previous and current *x-axis* on \(^0 z\) we can see that the angle is zero. This is an initial angle.

However, this angle can change because the \(^0 z\) axis is assigned to let’s say some motor’s shaft. This is why we treat it as a variable.

Remember to always mark the initial angle too if it is different from 0 (you will see in some other tutorial why).

………………..

In the next step we change the index of a frame (now the current coordinate system is a system marked with index 2, and the previous one – the coordinate system marked with index 1) and we repeat the whole procedure once again.

After doing it for the whole robot, we get the following result:

………….

\(i\) | \(a_i\) | \(\alpha_i\) | \(d_i\) | \(\theta_i\) |

1 | 0 | \(-\frac{\pi}{2}\) | \(d_1\) | \(\theta_1^*\) |

2 | \(a_2\) | 0 | 0 | \(\theta_2^*\) |

3 | \(a_3\) | 0 | 0 | \(\theta_3^*\) |

*The variables are marked with a star.

**3rd STEP – HOMOGONOUS TRANSFORMATION MATRIX**

The homogonous transformation matrix can be designated from the following equation:

\(^0 H_3=^0H_1 \times ^1H_2 \times ^2H_3\)

The matrix \(^0 H_3\) tell us what is the relation in the sense of rotation and translation between the base of the robot (index 0) and its end effector (index 3).

The individual matrices can be designated immediately by using the general D-H formula:

where \(C_{\theta_i}=cos(\theta_i)\), \(C_{\alpha_i}=cos(\alpha_i)\), \(S_{\theta_i}=sin(\theta_i)\) and \(S_{\alpha_i}=sin(\alpha_i)\).

after substituting parameters and variables from the table we get:

\(^0 H_1 = \begin{bmatrix}C_{1} & 0 & -S_{1} & 0\\S_{1} & 0 & C_{1} & 0\\0& -1 & 0 & d_1\\0&0&0&1\end{bmatrix}\)

We can see that the matrix for the 2nd and 3rd joint has the same form. It should be like this, because they are situated in the same way.

Once multiplying these matrices we get:

\(^0 H_3=^0H_1 \times ^1H_2 \times ^2H_3=\\\begin{bmatrix}C_{23}C_1 & -S_{23}C_1 & -S_1 & C_1 (a_3 C_{23}+a_2 C_2)\\S_1 C_{23} & -S_{23}S_1 & C_1 & S_1(a_3 C_{23} + a_2 C_2)\\-S_{23}& -C_{23} & 0 & d_1-a_3 S_{23} – a_2 S_2\\0&0&0&1\end{bmatrix}\)

where

\(cos\theta_1=C_1\\sin\theta_1=S_1\\cos(\theta_1+\theta_2)=C_{12}\\sin(\theta_1+\theta_2)=S_{12}\)

**4th STEP – THE ANALYSIS OF THE RESULT**

It is useful to check if the result is correct, since action which comes after that (kinematic and dynamic modeling, simulation, control, programming) is very time consuming. Thus, we must be sure that we are working on the good model.

- The first thing is that the matrix should have a block structure.

\(\begin{bmatrix}R&p\\0&1\end{bmatrix}\)

Our matrix from the example has the block structure, so this is ok. - The rotation matrix (part of the matrix 1:3,1:3) should have properties of a rotation matrix. These properties are generally defined below: Let’s assumed, that column of the rotation matrix can be written as \(R=[a b c]\). The following relationships apply:
- \(R^T=R^{-1}\)
- \(det(R)=\pm1\)
- \(R\) is normalized, so the squares of elements in any row or column must equal \(1\).
- \(R\) is orthogonal, so the dot product between any column must equal 0 \(a \cdot b=b \cdot c=c \cdot a=0\)
- The vector product of rotation matrix: \(a \times b=c\), \(b \times c=a\) and \(c \times a=b\).

- Another thing is to look at the rotation matrix and see if everything is ok. For example, since the 2nd and 3rd joints are situated in the same way, there is a sum of angles in the matrix. Also, the 3rd column is quite simple to quick analysis. The relation between \(^0 x[latex] and [latex]^3 z\) is \(-sin\theta_1\). Look at Fig. 2 – this is OK. A similar situation also applies between \(^0 y\) and \(^3 z\) \(-cos\theta_1\), and the relation between \(^0 z\) and \(^3 z\) is \(0\) (so the angle is always \(90 \;deg\) and we cannot change it in this manipulator).
- We can easily calculate how the matrix looks like in certain configurations, for example after substituting \(0\) angles for \(\theta_1\), \(\theta_2\) and \(\theta_3\) we get:

The translation vector tells us what is the position of the end effector frame in relation to world frame. This configuration is presented in Fig. below. We can see that \(x=a_2 + a_3\) and \(z=d_1\) so everything matches values from a matrix.

The analysis of matrix rotation elements, for example:

*x-axis*of a base frame and*x-axis*of an effector are oriented in the same direction. This is why we have \(1\) on position (1,1) of the rotational matrix;- \(^0 z\) and \(^3 y\) are opposite to each other this is why in position (3,2) we can find \(-1\);
- The \(^0 x\) and \(^3 z\) are perpendicular to each other, this is why we have \(0\) on position (1,3).

After doing above presented analysis we can assume, that the result is correct. Eventually you can also make a simulation study, which will be presented in some of the other tutorials.

The post Denavit-Hartenberg convention – tutorial 1 appeared first on R2R's robotic research.

]]>The post Cyber-protozoans appeared first on R2R's robotic research.

]]>Please download the files from here and run them locally (my current server cannot do it):

The post Cyber-protozoans appeared first on R2R's robotic research.

]]>The post C.A.M.E.R.A. project appeared first on R2R's robotic research.

]]>And some info about robots in general:

The post C.A.M.E.R.A. project appeared first on R2R's robotic research.

]]>The post Hello world appeared first on R2R's robotic research.

]]>The post Hello world appeared first on R2R's robotic research.

]]>