Lab 3
Lab 3
Description:
In this session, mathematical derivation for forward and inverse kinematic problems
are to be discussed, starting from simple coordinate systems, and ending with the
Denavit-Hartenberg convention.
Prerequisites:
- D-H convention.
Contents:
orthogonal. The most common orthogonal coordinates are the Cartesian, cylindrical
and the spherical coordinates. These coordinates offer to represent any point (zero
dimensional) in space.
articulated (only rotational). The most common coordinates are the Euler, and Roll-
A Cartesian robot consist of 3 prismatic joints (linear joints), that are placed in
orthogonal planes. The position of the tool (the last frame) w.r.t the base is given by:
Both forward and inverse kinematics (for positions) are very simple to compute,
the Matlab representation for forward and inverse kinematics for the Cartesian
A cylindrical robot consist of one revolute joint and two prismatic joints that are
placed in orthogonal planes. The position of the tool (the last frame) w.r.t the base
is given by:
R
TP = Tcyl(r,α,l)= Trans(0,0,l)*Rot(z, α)*Trans(r,0,0)
Forward and inverse kinematics for cylindrical robots are only valid to define the
position of the last frame with respect to the base, where the orientation of the last
syms r al l
Tcyl=transl(0,0,l)*trotz(al)*transl(r,0,0) %forward
kinematics
%Example:
Tcyl=subs(Tcyl,[r al l],[2 pi/3 5]);
%inverse kinematics
z= Tcyl(3,4)
theta= atan2(Tcyl(2,4),Tcyl(1,4))
if(Tcyl(1,4)==0)
R=Tcyl(2,4)/sin(theta)
else
R=Tcyl(1,4)/cos(theta)
End
A cylindrical robot consist of two revolute joints and one prismatic joint that are
placed in orthogonal planes. The position of the tool (the last frame) w.r.t the base
is given by:
R
TP = Tsph = Rot(z,γ)*Rot(y,β)*Trans(0,0,r)
Forward and inverse kinematics for spherical robots are only valid to define the
position of the last frame with respect to the base, where the orientation of the last
Exercise 1 (Homework):
Write a simple Matlab code that allows to find forward and inverse kinematics for a
spherical manipulator. (go with symmetry with the code written for the cylindrical
(about x then y then z). Yet, the first order is more used in the course book.
- Forward kinematics: if RPY angles are given, the orientation of the last
frame can be directly computed, and it is unique.
syms tx ty tz
Trpy=trotz(tz)*troty(ty)*trotx(tx)
Substituting the angles with their numerical values gives the final orientation.
- Inverse kinematics: if the desired orientation is given, the values of the RPY
angles can be calculated to achieve the same orientation. Usually, there are
two set of solutions that give the same orientation.
𝑛𝑥 𝑜𝑥 𝑎𝑥 0
𝑛 𝑜𝑦 𝑎𝑦 0
For any RTp = [ 𝑦 ]
𝑛𝑧 𝑜𝑧 𝑎𝑧 0
0 0 0 1
TRPY should be equal to RTp, this will lead us to the following two sets of solutions:
Solution:
clear all
close all
syms tx ty tz
T=[0.354 -0.674 0.649 0;0.505 0.722 0.475 0;-0.788 0.160
0.595 0; 0 0 0 1]
Trpy=trotz(tz)*troty(ty)*trotx(tx)
ty1=atan2(-T(3,1),sqrt(1-(T(3,1)^2)))
ty2=atan2(-T(3,1),-sqrt(1-(T(3,1)^2)))
tx1=atan2(T(3,2)/cos(ty1),T(3,3)/cos(ty1))
tx2=atan2(T(3,2)/cos(ty2),T(3,3)/cos(ty2))
tz1=atan2(T(2,1)/cos(ty1),T(1,1)/cos(ty1))
tz2=atan2(T(2,1)/cos(ty2),T(1,1)/cos(ty2))
Matlab robotic toolbox offers two ready functions that can find both of forward and
inverse kinematics for RPY coordinates, these functions are rpy2tr()and tr2rpy(),
an example for the usage is given below:
rpy2tr(0.9594,0.9076,0.2627,'zyx') % forward kinematics
for RPY
rpy2tr(55,51,15,'deg','zyx')% forward kinematics for
RPY, given the angles in degree
- Forward kinematics: if Euler angles are given, the orientation of the last
frame can be directly computed, and it is unique.
syms t1 t2 t3
Trpy=trotz(t1)*troty(t2)*trotz(t3)
Substituting the angles with their numerical values gives the final orientation.
- Inverse kinematics: if the desired orientation is given, the values of the Euler
angles can be calculated to achieve the same orientation. Usually, there are
two set of solutions that give the same orientation.
𝑛𝑥 𝑜𝑥 𝑎𝑥 0
𝑛 𝑜𝑦 𝑎𝑦 0
For any RTp = [ 𝑦 ]
𝑛𝑧 𝑜𝑧 𝑎𝑧 0
0 0 0 1
1- Derive the inverse kinematic formulas for the Euler angles that achieve any
desired orientation. (find two sets similar to the RPY angles) (Depend on
pages 64-66 in the course book).
0.354 −0.674 0.649 0
0.505 0.722 0.475 0
2- Given RTp = [ ], find all sets of the Euler
−0.788 0.160 0.595 0
0 0 0 1
angles that achieve the same orientation.
3- Matlab robotic toolbox offers two ready functions that can find both of
forward and inverse kinematics for Euler coordinates, these functions are
eul2tr()and tr2eul(). Give one example for the usage of these functions
(similar to the given example for RPY).
4- Both RPY and Euler angles can achieve any orientation in 3D space, these
angles are connected to each other by one transformation and some offset(s).
By inspection, find the angles that replaces the question marks in the
following formula:
In previous, we discussed sequential rotations about x,y and z axes that can achieve
a certain axis (a vector) with the correct angle. This is known by the rotation about
The transformation matrix that correspond to the rotation about a non-zero unit
Rot (k, Ɵ) =
matrix).
- Inverse kinematics:
Given a transformation matrix (the desired orientation) RTp , finding the angle
of rotation about a vector that achieve the same orientation in the inverse
kinematic problem.
𝑛𝑥 𝑜𝑥 𝑎𝑥 0
𝑛 𝑜𝑦 𝑎𝑦 0
For any RTp = [ 𝑦 ]:
𝑛𝑧 𝑜𝑧 𝑎𝑧 0
0 0 0 1
= 𝑛𝑥 + 𝑜𝑦 + 𝑎𝑧
As k is a unit vector:
2cos(𝜃) + 1 = 𝑛𝑥 + 𝑜𝑦 + 𝑎𝑧
𝜃 = cos −1 [( 𝑛𝑥 + 𝑜𝑦 + 𝑎𝑧 − 1)/2]
Then:
There are two values that 𝜃 can take, each value correspond to a different unit
vector.
𝜃2 = −cos−1 [( 𝑛𝑥 + 𝑜𝑦 + 𝑎𝑧 − 1)/2]
Exercise 3 (Homework):
2- Matlab robotic toolbox offers two ready functions that can find both of
forward and inverse kinematics for rotation about an arbitrary axis, these
functions are angvec2tr()and tr2angvec(). Give one example for the
usage of these functions.
3- The ready function tr2angvec() gives only one set of answers for the
writing a function that gives the two sets of vector-angle that can achieve a
Using this convention, any two sequential frames are related to each other by only
n
Tn+1 = An+1 = Rot(z,θn+1)*Trans(0,0,dn+1)*Trans(an+1,0,0)*Rot(x,αn+1)
(Refer to your lecture notes and pages 67-75 in the course book for all details)
Using Matlab, the D-H matrix (the A matrix) can be written as:
syms t al a d
A= trotz(t)*transl(a,0,d)*trotx(al)
If we have the D-H parameters, the function subs() will allow us to find the
Example:
Given the manipulator in Figure 2.26 in the course book, D-H parameters are given
the following table, find all the A matrices, then find UTH.
# θ d a α
1 θ1 0 0 90
2 θ2 0 a2 0
3 θ3 0 a3 0
4 θ4 0 a4 -90
5 θ5 0 0 90
6 θ6 0 0 0
Solution:
syms t al a d
A= trotz(t)*transl(a,0,d)*trotx(al);
syms t1 t2 t3 t4 t5 t6 a2 a3 a4
A1=subs(A,[t d a al],[t1 0 0 pi/2])
A2=subs(A,[t d a al],[t2 0 a2 0])
A3=subs(A,[t d a al],[t3 0 a3 0])
A4=subs(A,[t d a al],[t4 0 a4 -pi/2])
A5=subs(A,[t d a al],[t5 0 0 pi/2])
A6=subs(A,[t d a al],[t6 0 0 0])
Atotal=A1*A2*A3*A4*A5*A6
Atotal=simplify(Atotal)
Forward kinematics: Finding UTH given all joint variables is straight forward (only
Note that, there are no ready functions in the Matlab robotic toolbox that can help
you to derive the forward of inverse kinematics in all symbolics formulas. The
method stated in the lab sheet will be very useful for future topics (Jacobian
analysis).
4- Find the transformation matrix for the tool-frame coordinates w.r.t the base
(the product of the A matrices).
Only Email submissions are accepted (you have exactly 6 days to submit)
- Take clear photos of your paper solutions and combine them all in a single
pdf file.