Documentation
Documentation
thomas-hiemstra Hiemstra
June 2017
1 kinematics
First off some notations which are used for the DH matrices. Since there
are a lot of sines and cosines of the angles q1 , ...., q6 a shorthand is used for
the sine and cosine of these angles. Namely: cos(qi ) = ci , sin(qi ) = si and
cos(qi + qj ) = cij .
In short:
1
These 4 parameters are then plugged into the DH matrix which then in turn
gives the full
rotation and translation between
the 2 links:
cθi −sθi cαi sθi sαi ai cθi
i cθi cαi −cθi sαi ai sθi
sθ
Ai−1
i (qi ) = 0 s αi cαi di
0 0 0 1
Here the upper left 3x3 matrix represents the rotation and the right 1x3
column vector represents the translation.
Notice that frame 3 here is left hanging since it is not possible to directly
attatch something like a gripper to it in it’s current configuration. Because
the Z-axis of a gripper would be in the gripping direction whereas the Z-axis
of the final frame is pointing sideways, this will become important later on.
2
Next the wrist and it’s parameters:
Notice again here that the wrist cannot be directly connected to the arm
since the Z-axis of frame 3 does not coincide with frame 3 of the arm. Also
notice the orientation of frame 5 with respect to frame 4 which determines
the behaviour of θ5 . In figure 2 the wrist is drawn for θ5 = π/2.
3
Finally the full arm:
Notice here that the parameters for frame 3 and 4 are different than for the
arm and wrist given above. The reason as stated before is that the wrist
cannot be directly connected to the arm since frame 3 of the arm and frame
3 of the wrist do not coincide. Changing α fixes that.
IMPORTANT: this has the consequence that θ3 behaves in a weird way,
when the arm is stretched out θ3 would have been 0 for the case without the
wrist, now θ3 = π/2!! This explains the ”angles[3] += pi/2” in the code.
The DH matrices for the full arm are worked out in the mathematica note-
book.
4
1.2 Inverse kinematics
The general inverse kinematics problem is generally impossible to solve an-
alytically. However the case of a 6 axis robotic arm where the last 3 joints
are intersection at a point is a special case. Here it is possible to decouple
the inverse kinematics into 2 simpler problems. Namely inverse position
kinematics and inverse orientation kinematics.
The input for a given position should counting 6 parameters. 3 for position
and 3 for orientation. From the orientation parameters the wrist center can
be computed since distance from center to gripper is a constant. Next the
position of the arm is calculated using the position inverse kinematics. Then
using the (now calculated) values of the first 3 joints the orientation of the
arm is computed. Finally we need to go from the orientation of the arm to
the desired orientation of the gripper which is done by calculating the values
of the last 3 joints.
The input for our location are an origin O and a rotation matrix R. From
this we have:
xc ox − d6r13
yc = oy − d6r23 (1)
zc oz − d6r33
where the subscript c denotes the origin of the wrist and r are the elements
of the input rotation matrix. Using the position as the wrist for the desired
location of the arm we can perform the inverse position kinematics which
are worked out in [1]. The resulting formulas are:
θ1 = Atan2(yc , xc ) (2)
p
θ3 = Atan2(− 1 − D2 , D) (3)
p
θ2 = Atan2(zc − d1, x2c + yc2 ) − Atan2(k2, k1) (4)
5
R63 is obtained from the DH matrix of the full robot arm. This is a matrix
in terms of θ4 , θ5 , θ6 and has the form of the ZYZ euler matrix. So now we
are left with the matrix equation:
nx sx ax
R63 = ny sx ax (6)
nz sx ax
Where the left hand side contains the unknown angles and the right hand
side is (R63 )T R which is known (AKA just a bunch of numbers). (n,s and a
stand for normal, sliding and approach direction respectively). Since R63 is
the ZYZ euler matrix the solution for the angles can be found in the litera-
ture and it reads:
θ4 = Atan2(ay , ax ) (7)
q
θ5 = Atan2( (ax )2 + (ay )2 , az ) (8)
θ6 = Atan2(sz , −nz ) (9)
6
moves in a line through x=0. Since θ4 ∈ (−π, π) it cannot go to 181 degrees,
in order to achieve this the entire configuration of the robot arm will flip.
This is why moving the gripper in straight lines can be problematic since it
is very hard to figure out where the configuration flips might occur. In order
to avoid this you have to either pick the correct flip (and flip the wrist at
points where it causes minimal arm movement) or you simply let the joints
go smoothly from their starting configuration to their ending configuration,
this is done in the pointToPoint function.
1.3 singularities
a quick note on singularities, when θ5 = 0 the Atan2 function becomes
undefined (divide by 0 error) which is called a wrist singularity. I avoid
this by adding epsilon to θ5 when this happens but this still causes numeric
instability. There are other singularities such as the robot having to move
extremely fast to make the gripper move a constant rate, many of such
things are shown in this video: [5]
7
2 robot vision
References
[1] Dr. Rainer Hessmer. Kinematics for Lynxmotion Robot Arm. url:
http://www.hessmer.org/uploads/RobotArm/Inverse%2520Kinematics%
2520for%2520Robot%2520Arm.pdf.
[2] Inverse kinematics video. url: https://www.youtube.com/watch?v=
rA9tm0gTln8.
[3] robot arm with vision. url: https://github.com/thomashiemstra/
robot_arm_with_vision.
[4] Lorenzo Sciavicco and Bruno Siciliano. Modelling and control of robot
manipulators. Springer Science & Business Media, 2012.
[5] Singularities of a six-axis robot. url: https : / / www . youtube . com /
watch?v=zlGCurgsqg8.