Robot Tool Center Point Calibration Using Computer Vision - Johan Hallenberg PDF
Robot Tool Center Point Calibration Using Computer Vision - Johan Hallenberg PDF
Johan Hallenberg
Distributed by:
Linköpings University
Department of Electrical Engineering
SE-581 83, Sweden
Robot Tool Center Point Calibration
using Computer Vision
Master’s Thesis at Computer Vision Laboratory
University of Linköping
by
Johan Hallenberg
Reg nr: LITH - ISY - EX - - 07/3943 - - SE
Ivan Lundberg
ABB Corporate Research Center, Sweden
Linköping 2007 - 02 - 05
Abstract
v
Acknowledgements
I have had the opportunity to write my Master’s Thesis at ABB Corporate Re-
search Center, Mechatronics department, in Västerås. This period has been a
great experience for me and I have really enjoyed working with the project.
I want to thank my supervisor Development Engineer Ivan Lundberg at ABB
Corporate Research Center for his great enthusiasm, all the conversations, and for
the extremely good supervision throughout the project.
I also want to thank my supervisor and examiner Associate Professor Klas
Nordberg at Linköping University, for all the great phone conversations, the good
tips and all the support and guidance throughout the project.
Special thanks also to PhD. Mats Andersson at the Center for Medical Image
Science and Visualization for his great interest in the project and helpfully ideas.
vii
Notation
Symbols
• f (x, y) denotes a 2D function or an image.
• x, X denote scalar values.
• x, X denote vectors or coordinates.
• X denotes a matrix.
Operators
• f (x, y) ∗ g(x, y) denotes the convolution between the image f (x, y) and the
image g(x, y).
• f (x, y) ? g(x, y) denotes the cross correlation between the image f (x, y)
and the image g(x, y).
• XT denotes the transpose of X.
• X† denotes the pseudo inverse of X.
Glossary
TCP Tool Center Point.
Jog Manually move the robot with joystick.
Base frame The robot’s base coordinate system.
Robtarget Cartesian target.
DOF Degrees of freedom.
Q.E.D ”Quod Erat Demonstrandum” a latin phrase meaning
”which was to be demonstrated”.
ix
Contents
1 Introduction 1
1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Problem Specification/Objectives . . . . . . . . . . . . . . . . . . 2
1.3 Delimitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Thesis Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Robotics 3
2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Coordinate Systems . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2.1 Tool Center Point, TCP . . . . . . . . . . . . . . . . . . . 4
2.2.2 Base frame . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2.3 World frame . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.4 Wrist frame . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.5 Tool frame . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 TCP Calibration algorithm . . . . . . . . . . . . . . . . . . . . . 7
3 Theory 9
3.1 Image Processing Theory . . . . . . . . . . . . . . . . . . . . . . 9
3.1.1 Threshold . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.2 Morfological operations . . . . . . . . . . . . . . . . . . 9
3.1.3 Structure Element . . . . . . . . . . . . . . . . . . . . . . 9
3.1.3.1 Erosion . . . . . . . . . . . . . . . . . . . . . . 10
3.1.3.2 Dilation . . . . . . . . . . . . . . . . . . . . . 10
3.1.3.3 Opening . . . . . . . . . . . . . . . . . . . . . 11
3.1.3.4 Closing . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Computer Vision Theory . . . . . . . . . . . . . . . . . . . . . . 12
3.2.1 Camera System . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.2 Pinhole Camera Model . . . . . . . . . . . . . . . . . . . 13
3.2.3 Camera Calibration . . . . . . . . . . . . . . . . . . . . . 14
3.3 Transformation Theory . . . . . . . . . . . . . . . . . . . . . . . 16
3.3.1 Homogeneous Transformation . . . . . . . . . . . . . . . 16
xi
xii CONTENTS
3.3.1.1 3D translation . . . . . . . . . . . . . . . . . . 16
3.3.1.2 3D Rotation . . . . . . . . . . . . . . . . . . . 16
3.3.1.3 Homogeneous Transformation Matrix . . . . . 16
3.3.2 Screw Axis Rotation representation . . . . . . . . . . . . 17
3.3.3 Rodrigues´s formula . . . . . . . . . . . . . . . . . . . . 18
6 Results 55
6.1 Repetition Accuracy of the Camera . . . . . . . . . . . . . . . . . 55
6.1.1 Averaging to achieve higher accuracy . . . . . . . . . . . 56
6.1.2 How does the number of points affect the repetition accuracy 57
6.2 Camera versus Robot measurements . . . . . . . . . . . . . . . . 59
6.2.1 Rotation measurements . . . . . . . . . . . . . . . . . . . 59
6.2.2 Translation measurements . . . . . . . . . . . . . . . . . 61
6.2.2.1 Averaging to achieve higher accuracy . . . . . . 64
6.3 Accuracy of the TCP Calibration method . . . . . . . . . . . . . 67
6.3.1 Averaging to obtain a higher accuracy . . . . . . . . . . . 69
6.4 Repetition Accuracy of the TCP Calibration method . . . . . . . . 69
6.4.0.1 How does the number of points affect the repe-
tition accuracy of the TCP calibration method . 72
7 Discussion 73
7.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
7.1.1 Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . 73
7.1.2 Major Problems/known difficulties . . . . . . . . . . . . . 74
7.1.2.1 Finding distinct points . . . . . . . . . . . . . . 74
7.1.2.2 Light reflections in the tool . . . . . . . . . . . 74
7.1.3 Fulfillment of objectives . . . . . . . . . . . . . . . . . . 75
7.2 Future Development . . . . . . . . . . . . . . . . . . . . . . . . 75
7.2.1 Rotation symmetric tools . . . . . . . . . . . . . . . . . . 75
7.2.2 Light reflections in the tool . . . . . . . . . . . . . . . . . 76
7.2.3 Image Segmentation controlled by CAD drawings . . . . 76
7.2.4 Neural network based methods . . . . . . . . . . . . . . . 76
7.2.5 Online correction of the TCP calibration . . . . . . . . . . 76
7.2.6 Other image processing libraries . . . . . . . . . . . . . . 77
A Appendix 79
A.1 Finding intrinsic parameters . . . . . . . . . . . . . . . . . . . . 79
Bibliography 87
Chapter 1
Introduction
This chapter begins with a short background, then the problem is specified and the
objectives and delimitations are determined. Finally the disposition of the thesis
is presented.
1.1 Background
All robots delivered by ABB are calibrated in the production. When the calibra-
tion procedure is done the robot is calibrated up to the last axis and is thereby able
to calculate the positions of all axes during a movement. When a tool is mounted
on the last axis (the tool flange) the robot needs to know the actual position of the
active point of the tool, the tool center point, which for instance can be the muzzle
of a spot welding tool. For this reason a tool center point calibration has to be
performed every time the tool is changed.
Today the TCP calibration is done manually by moving the robot, letting the
TCP brush against a fixed point in the environment. The fixed point is typically
the tip of a nail. The tool center point needs to brush against the tip of the nail
with great precision and from at least four different angles. Then the coordinate
of the tool center point can be calculated by the robot in relation to the robot’s tool
flange coordinate system. The method is time consuming and the result may vary
due to how skilled the robot operator is. The resulting accuracy of todays method
is approximately ±1 mm.
Products for automating the TCP calibration exist, for instance BullsEye for
calibration of arc welding tools and TCP-Beam for calibration of spot welding
tools. The disadvantage with these methods are that they are specialized to one
single type of robot tools.
1
2 CHAPTER 1. INTRODUCTION
1.3 Delimitation
To deliver a method with the ability to calibrate all kinds of robot tools during a
5 months Master’s thesis is of course impossible. Instead the method is of impor-
tance, and any kind of tool is permitted to be used to demonstrate the method.
Robotics
This chapter will give an overview of robots and their coordinate systems. The
chapter concludes with a description of a four point tool center point calibration
algorithm used in the robots today.
2.1 Overview
Traditionally a robot consists of a mechanical arm and a computer controlling its
position and movement. In this project only serial kinematics manipulators will be
concerned. The serial kinematics manipulators consist of several axes connected
by joints see figure 2.1.
3
4 CHAPTER 2. ROBOTICS
Usually the mechanical arm (the manipulator) is divided into an arm, a wrist
and an end-manipulator (the tool). All the manipulators used during this project
have got six degrees of freedom, making it possible to position the tool anywhere
in the robot workspace with a given orientation. Internally the robot end effector
orientation is represented by quaternions.
The ABB robots can be manually controlled by using the flexpendant. The
flexpendant is a hand held controller connected to the computer controlling the
robot. A robot program telling the robot how to move can be written in the
program language RAPID. The RAPID programs can be written directly in the
flexpendant but it is also possible to develop the RAPID program on a PC and
then transfer the program (by a TCP-IP connection or a USB connection) to the
computer controlling the robot.
The robot base coordinate system is located on the robot base. The origin of the
base frame is located at the intersection of axis 1 and the robot’s mounting surface.
The x axis is pointing forward, the y axis points in the robot’s left side direction
and the z axis coincides with the rotational axis of axis 1. Figure 2.2 illustrates
the base frame [1].
2.2. COORDINATE SYSTEMS 5
of the tool flange and the z axis coincides with axis six of the robot. There is a
calibration mark at the tool flange, see figure 2.5. The x-axis of the wrist frame
is always pointing in the opposite direction of the calibration mark and the y-axis
is achieved by constructing an orthogonal coordinate system axis to the x and z
axes.
[1]
[1]
0 0 0 1
It is obvious that equation 2.1 is satisfied, due to the fact that the tool center
point is at the same coordinate independent of which of the N robot positions that
is examined.
T1i Q = T1j Q (2.1)
Where i, j ∈ [1...N ] and i 6= j.
Denote:
a11 a12 a13 a14
Ra ta
a a22 a23 a24
21
T1i = =
(2.2)
a31 a32 a33 a34
0 0 0 1
a41 a42 a43 a44
⇔
8 CHAPTER 2. ROBOTICS
(a11 − b11 )T CPx + (a12 − b12 )T CPy + (a13 − b13 )T CPz = −(a14 − b14 ) (2.4)
For every equation 2.1 a system of three equations like equation 2.4 is retrieved.
The system of three equations can be rewritten as
h i T CPx h i
Ra − Rb T CPy = − ta − tb
(2.5)
T CPz
Theory
This chapter will describe theories necessary for understanding the rest of the the-
sis. The chapter is divided in image processing theories, computer vision theories
and transformation theories.
9
10 CHAPTER 3. THEORY
3.1.3.1 Erosion
The erosion operation is accomplished by setting all object pixels within a certain
distance from a background pixel to 0. In practice a structure element is used. The
origin of the structure element is then translated to every object pixel. If all of the
structure element is accommodated in the object at a certain position the pixel is
set to 1 in the resulting image, otherwise 0.
Notice, a(x, y) f (x, y) 6= f (x, y) a(x, y) due to the fact that correlation
does not fulfill the commutative law
Figure 3.2: Erosion operation applied to figure 3.1. A 8 × 8 structure element was
used.
3.1.3.2 Dilation
The dilation operation is the opposite of the erosion operation. It is accomplished
by setting all background pixels within a certain distance from an object point to
3.1. IMAGE PROCESSING THEORY 11
Figure 3.3: Dilation operation applied to figure 3.1. A 4 × 4 structure element was
used.
3.1.3.3 Opening
The opening operation consists of one erosion operation followed by one dilation
operation, where the distance is the same in both of the operations. When im-
plemented with a structure element the same structure element is used in the two
operations.
The opening operation will split two objects which border on each other.
3.1.3.4 Closing
The closing operation consists of one dilation operation followed by one erosion
operation, where the distance is the same in both of the operations. When im-
plemented with a structure element the same structure element is used in the two
operations.
The closing operation will merge two objects which border on each other.
12 CHAPTER 3. THEORY
1 1 1
+ = (3.1)
α β f
Where α is the distance between the lens and the object, β is the distance between
the lens and the image plane and f is the focal length. Figure 3.4 illustrates the
lens law.
By the lens law it is obvious that an object at the distance α from the lens
will be reproduced with complete sharpness on the image plane. If the distance
between the object and the lens differs from α, the reproduction on the image
plane will be more or less blurred. How blurred the image will be, is determined
by the depth of field s. !
f
s = 2λ (3.2)
D
Where D is the diameter of the aperture and λ is the wavelength of the incoming
ray of light. The depth of field can also be defined as the interval where the
3.2. COMPUTER VISION THEORY 13
1 1
resolution is greater than 2d
where the resolution d
is defined as following
1 1D
= (3.3)
d λf
[3]
Figure 3.5: Illustration of the pinhole camera model, image plane in front of the
lens to simplify calculations (Courtesy of Maria Magnusson Seger).
X
un U h i Y
W vn = V = R t (3.4)
Z
1 W
1
h iT h iT
Where U V W are the camera coordinates, un vn are the ideal nor-
h iT
malized image coordinates and X Y Z are the world coordinates.
14 CHAPTER 3. THEORY
h i
Matrix R t is the extrinsic parameters and describes the translation and
the rotation between the coorinate systems, e.g. how the camera is rotateted and
translated in relation to the origin of the world coordinate system.
The real image plane usually differs from the ideal normalized image plane.
Equation 3.5 describes the relation between the two planes.
u un
v = A vn
(3.5)
1 1
0 0 1
" #
u0
Where α and β are scaling factors for the u and v axes. are the image
v0
coordinates of the intersection between the image plane and the optical axis. γ
describes the skewing between the u and v axes.
Observe, the relation in equation 3.5 implies equation 3.4 can be rewritten as
X
u h i Y
W v = kA R t (3.6)
Z
1
1
W
Where k is an arbitrary constant. Let s = k
implies equation 3.6 can be rewritten
as
X
u h i Y
s v = A R t (3.7)
Z
1
1
[3]
h iT h iT
If N corresponding points in the image ui vi and the world Xi Yi Zi
are found and i ∈ [1 . . . N ] then C can be determined to up a scale factor.
C11 C12 C13 C14
C = C21 C22 C23 C24 (3.9)
Dc = f (3.10)
c is then given by
−1
c = DT D D T f = D† f (3.11)
Note, at least six corresponding points are needed to determine the intrinsic
and extrinsic parameters.
[3]
16 CHAPTER 3. THEORY
3.3.1.2 3D Rotation
h iT 0
Let point P = x y z be rotated θ◦ around the Z axis to a point P =
h iT 0
x0 y 0 z 0 . Point P can be expressed according to [4] as
Let:
cos θ − sin θ 0
Rz = sin θ − cos θ 0
0 0 1
0
Then P can be written as
0
P = Rz P (3.16)
0 0 0 1
A complete transformation of a rigid body e.g. a transformation between two
different coordinate systems can be expressed as a homogeneous transformation
matrix T.
r11 r12 r13 tx
r
21 r22 r23 ty
T=
r31 r32 r33 tz
0 0 0 1
Equation 3.26 is called the screw axis representation of the orientation. [5]
h iT
Given a rotation matrix R, the angle of rotation θ and the rotation axis nx ny nz
can be obtained by the following equations.
a11 + a22 + a22 − 1
θ = cos−1 (3.27)
2
a32 − a23
nx = (3.28)
2 sin θ
a13 − a31
ny = (3.29)
2 sin θ
a21 − a12
nz = (3.30)
2 sin θ
This representation makes it possible to compare two different measuring units
which uses different coordinate systems to measure the rotation. In this project
the method was used to ensure the camera measured the same rotation angle as
the robot, when the robot was told to perform a rotation.
r 2 = 1 R2 r 1 (3.32)
This chapter describes how the problem of finding the tool center point was solved.
The chapter starts by describing the proposed method for determination of the
camera to tool, tool to robot wrist and camera to robot base coordinate system
transformations respectively. The chapter also describes the proposed iterative
method for finding the tool center point. The iterative method is used to remove
uncertainties due to camera calibration errors and robot calibration errors.
21
22 CHAPTER 4. DETERMINATION OF TOOL CENTER POINT
4.1.1 Equipment
The robot used during the project was an IRB 1400 ABB robot controlled by an
IRC5 computer. A laptop computer with an Intel PentiumM 1600Mhz processor
and 1Gb RAM was connected to the IRC5 computer by a TCP-IP cable. A pro-
gram was then developed in C# and C/C++ making it possible to control the robot
movements directly from the laptop. The laptop computer was also used for im-
age segmentation of the tool. The images were retrieved at 50 frames per second
by an uEye (UI221x-M V2.10) CCD grayscale USB camera with a resolution of
640 × 480 pixels.
Except for the equipment, four different transformations T1 , T2 , X1 and X2
are displayed in figure 4.1.
By defining a tool coordinate system TF (tool frame) with its origin at the tool
center point, the problem of finding TCP actually becomes equivalent by finding
the transformation X1 from the tool frame TF to the TFF (Tool Flange Frame)
coordinate system fixed at the last axis of the robot manipulator.
To make it possible to determine transformation X1 , a closed loop of homo-
geneous transformation matrixes can be written as an equation.
T2 X1 = X2 T1 (4.1)
Transformation matrix T1 in Equation 4.1 is the robot’s forward kinematics.
Consequently T1 is known, making the problem of finding X1 become equivalent
by determine X2 and T2
4.2 Determine T2
By calibrating the camera using the method proposed by Zhengyou Zhang [6]
the intrinsic parameters of the camera were determined and the lens distortion
coefficients were retrieved, see Appendix A.
h iT h iT
Let m = u v denote a 2D image point and M = X Y Z de-
note a 3D point. The augmented representations of these vectors are achieved
h iT
by adding 1 as the last element of the vector. mf = u v 1 and Mf
=
h iT
X Y Z 1 . By modeling the camera as a perfect pinhole camera, the re-
lation between a 3D point M and its projected image point m is fulfilling equation
4.2
smf = ATM f
(4.2)
Where A is the intrinsic parameters, s is a scale factor and T is the extrinsic
parameters. h i
T = r1 r2 r3 t
4.2. DETERMINE T2 23
By setting up a plane in the world, the homography between the plane and its im-
age can be determined. Let the plane fulfilling the constraint of Z = 0. Equation
4.2 is then rewritten as
X
u h i Y h i X
v = A r1 r2 r3 t
s = A r1 r2 t Y
0
1 1
1
h i h i
Let the homography H = h1 h2 h3 = A r1 r2 t . According to [6]
this implies the extrinsic parameters can be determined as
r1 = λA−1 h1
r2 = λA−1 h2
r3 = r1 × r1
t = λA−1 h3
Where λ = || A−11 h || = || A−11 h ||
1 2
By letting the plane be expressed in the tool coordinate system TF, finding trans-
formation
h T2 in figurei4.1 becomes equivalent of finding the extrinsic parameters
T = r1 r2 r3 t . From 4.2 it is obvious that T is totally determined by the
intrinsic parameters A and the homograpghy H. The camera calibration toolbox
for Matlab was used to determine the intrinsic parameters, A, for the camera. See
Appendix A. This toolbox uses theh same technique i as mentioned in this section
and in [6]. The homography H = h1 h2 h3 can be obtained according to
[6] by minimizing
T
T T
mi − 1 h1 Mi (σ 2 I)−1 mi − 1 h1 Mi
P
i T T i T T
h3 Mi h2 M i h3 Mi h2 M i
Where hj is the j:th row of H, I is the identity matrix and σ is the standard
deviation of the Gaussian noise that is assumed to affect mi . The problem can be
solved as a non-linear least square problem.
2
T
h1 Mi
P 1
minH i mi − T T
h3 Mi h2 M i
Due to the fact that a plane is by definition defined of at least three points, at
least three corresponding points mi and Mi belonging to the plane needs to be
determined. An image segmentation method for finding three distinct points in
the plane lying in the tool coordinate system TF, is described in chapter 5. The
tool used for the segmentation was a calibration tool with an awl looking shape.
The TCP of the tool was the tip of the awl, and the TCP was one of the points
determined by the method.
24 CHAPTER 4. DETERMINATION OF TOOL CENTER POINT
By multiply the inverse of equation 4.4 by equation 4.3 equation 4.6 will be
obtained.
⇔
X−1 −1
1 T22 T21 X1= T−1 −1
12 X2 X2 T11
⇔
T−1 −1
22 21 1 = X1 T12 T11
T X
⇔
AX1 = X1 B (4.6)
Where A = T−1 −1
22 T21 and B = T12 T11 are known. Observe, A and B are the
transformations from position 1 to position 2 of the tool flange frame and the tool
frame respectively. See figure 4.2
The transformation matrixes A,B,X1 are all homogeneous matrixes. A ho-
mogeneous matrix consists of one rotation matrix R and one translation vector
t.
4.3. FINDING X1 AND X2 TRANSFORMATION MATRIXES 25
!
RX1 tX1
X1 =
0 0 0 1
!
RA tA
A=
0 0 0 1
!
RB tB
B=
0 0 0 1
By using a modified
h version of Rodrigues
i formula, see section 3.3.3, a func-
tion Pr depending on n1 n2 n3 and θ can be defined as
θh i
Pr = 2 sin n1 n2 n3 , 0≤θ≤π (4.8)
2
Let:
PA , PB , PX1 be the rotation axes defined according to equation 4.8
for RA , RB , RX1 respectively.
0 1
PX1 = q (4.9)
4 − |PX1 |2
0
By setting up a system of linear equations according to equation 4.11, PX1
can be solved by using linear least square techniques.
0
Skew(PB + PA )PX1 = PA − PB (4.11)
Proof:
0
PA − PB ⊥ PX1 (4.12)
PA − PB ⊥ PA − PB (4.13)
0
PA − PB = s(PA + PB ) × PX1 (4.14)
Where s is a constant
0
PA − PB and (PA + PB ) × PX1 has got the same length implying s = 1.
4.3. FINDING X1 AND X2 TRANSFORMATION MATRIXES 27
0
Let α be the angle between PX1 and (PA + PB ).
0 0
|(PA + PB ) × PX1 | = |PA + PB ||PX1 | sin α =
, ,
= Use equation 4.9 =
1
|PA + PB |2 sin 2θ (4 − 4 sin2 2θ )− 2 sin α =
|PA − PB |
Q.E.D
|PX1 |2 1 T
q
RX1 = (1 − )I + (PX1 PX1 + 4 − |PX1 |2 Skew(PX1 )) (4.17)
2 2
Let:
1 0 0 |
0 1 0 tX1
TX1 = (4.18)
0 0 1 |
1 0 0 1
28 CHAPTER 4. DETERMINATION OF TOOL CENTER POINT
1 0 0 |
0 1 0 tA
TA = (4.19)
0 0 1 |
1 0 0 1
1 0 0 |
0 1 0 tB
TB =
(4.20)
0 0 1 |
1 0 0 1
⇔
RB T X1 − T X 1 = RX1 T A − T B
⇔
(RB − I)TX1 = RX1 TA − TB
Q.E.D.
At least three different positions of the robot are needed to calculate the equa-
tions 4.11 and 4.21 by a linear least square technique. In the implementation, four
4.4. IMPORTANCE OF MEASURE A AND B WITH 6 DOF 29
different positions were used. The result varied much due to how the positions
were chosen. The best estimation of X1 was achieved when the positions were
fulfilling the constraint of completely exciting all degrees of freedom. In practise
this constraint is equivalent of ensuring the three first positions differ in both a lin-
ear movement along orthogonally axes x, y, z and rotations around each axis. The
h iT h iT
fourth position was chosen to be a movement in x y z = 1 1 1
and a rotation around the same axis.
Proof:
First four lemmas have to be defined.
Lemma1 :
Matrixes A and B are similar if a matrix X exists such as
B = X−1 AX
⇔
AX = XB
If A and B are similar then A and B has got the same
trace, determinant and eigenvalues.[11]
Lemma2 :
The eigenvalues of a rotation matrix R are
λ1 = 1
λ2 = cos θ + i sin θ
λ3 = cos θ − i sin θ
Where θ is the angle of rotation specified by equation 4.7
[12]
30 CHAPTER 4. DETERMINATION OF TOOL CENTER POINT
Lemma3 :
A rotation matrix R fulfills according to [13] the orthogonality conditions
R−1 = RT
and
RT R = I
Lemma4 :
For a matrix R fulfilling the ortogonality conditions,
the trace of R is the sum of the eigenvalues of R according to [12].
P
T r(R) = i λi
⇔
!
T r(R) − 1
θ = arccos (4.22)
2
If the robot is told to perform a rotation θ around the axis of symmetry, the robot
will measure a rotation θB = θ. However the camera will not be able to distinguish
any difference between the orientation before and after the rotation around the axis
of symmetry. This implies the camera will measure a rotation θA = 0.
It is then obvious by equation 4.22 that in general T r(A) 6= T r(B) implying
according to Lemma1, there is no solution X1 to equation AX1 = X1 B.
Q.E.D
The robot can then be told to perform a linear movement of −. Ideally this would
32 CHAPTER 4. DETERMINATION OF TOOL CENTER POINT
T CPz
from the origin of the tool flange coordinate system to the tool center point.
Let:
1 0 0 T CPx
0 1 0 T CPy
Q=
0 0 1 T CPz
0 0 0 1
Due to the fact that the tool center point is at the same coordinate independent
of which of the six robot positions that is examined, the algorithm described in
section 2.3 on page 7 can be used to determine the true position of the tool center
point. By using the iterative procedure and calculating the tool center point as a
least square solution described in section 2.3, the accuracy of the TCP calibra-
tion method becomes independent of the camera calibration errors and the robot
calibration errors. Instead, only the accuracy of the camera when registering a
movement between two different positions, affects the final accuracy of the tool
center point calibration achieved by the iterative method. This can be assured by
considering that the camera is an external observer during the iterative procedure,
and the method will iterate until the camera measures (with the desired accuracy)
the true tool center point is at the same location as the initial guess point.
4.6. ALTERNATIVE METHOD FOR ROTATION SYMMETRIC TOOLS 33
The translational scaling factor between the two coordinate systems is also possi-
ble to determine, because the distances the robot moves in the X, Y and Z direc-
tions are known and the distances of the same movements measured by the camera
are also retrieved. This assures it is possible to find the translation error between
TCPguess and the true coordinate of the tool center point TCPcorrect , even if the
robot tool is rotation symmetric. It is thereby possible to perform a tool center
point calibration, even if the robot tool is rotation symmetric.
Chapter 5
This chapter will describe the methods evaluated during this project for image
segmentation of the robot tool.
5.1 Overview
Since one of the goals of this thesis was to deliver a software program made in
C/C++ and C# , all of the image processing had to be written in either of these
program languages. The HMI part of the program was written in C# and the image
processing functions were written in C/C++.
To keep the production costs as low as possible only open source libraries were
allowed to be used during this project. Due to this constraint the image processing
functions in Open Computer Vision Library 1.0 (OpenCV 1.0) were mainly used
for image segmentation.
35
36 CHAPTER 5. IMAGE SEGMENTATION OF ROBOT TOOL
ConstraintI :
The image can locally be described as a sloping plane.
I(x, t) = I(x, t) − ∇I T (x, t)v(x) + ∆t
∆t = I(x,"t + 1) − I(x, t) #
∇x I(x, t + 1)
∇I(x, t) =
∇y I(x, t + 1)
Let:
I1 = Ix,t+1
I2 = Ix,t
v(x) = B(x)p
" #
1 0 x y 0 0
B(x) =
0 1 0 0 x y
p1
.
p = ..
p6
Then 5.2 can be written as
Let:
∇I2 (x1 )T B(x1 )
A= ..
.
∇I2 (xn )T B(xn )
I1 (x1 ) − I2 (x1 )
b= ..
.
I1 (xn ) − I2 (xn )
Where n is the number of pixels in I2 . Equation 5.3 is then rewritten to equation
5.4.
Ap = b (5.4)
This implies p and v(x) are determined as
The new location I2new of the reference image is then obtained by interpolating
I2 from v(x). The method is then iterated with I2new as I2 until |v(x)| < β, where
β is the desired accuracy.
The method described in this section was implemented and evaluated in Mat-
lab. Unfortunately the method was not reliable. The resulting position of the
38 CHAPTER 5. IMAGE SEGMENTATION OF ROBOT TOOL
reference image I2 was heavily affected by the light condition. Although, when
using the method on synthetic binary test images the method performed very well.
Of course it would be possible to threshold the image I1 retrieving a binary
image Ibinary , and then apply the image registration method on the binary image.
Although, finding the threshold value that separates the background completely
from the tool is a hard problem to solve.
Of course there might exist image registration methods, better suited for solv-
ing the problem. A phase based image registration method would perhaps give
a better result than the method described here. However, due to the fact that it
is possible to move the robot to different positions, the background subtraction
method was instead evaluated.
The resulting binary mask image will of course have its pixels set to one in
both the start location and the final location for the object. To distinguish between
the object’s true location and the last location, the object can be moved to a third
position and a new image f3 can be retrieved.
By applying the background subtraction method to f1 − f3 and f2 − f3 sep-
arately and applying a pixel wise logical AN D operator to the resulting binary
images, a new binary mask image only giving the last location of the object will
be retrieved.
In practise the resulting binary mask image was not perfect, several holes oc-
curred in the object region see figure 5.1.
5.2. CREATION OF BINARY MASK IMAGE 39
To fill the holes in the mask image, morphological operations were applied to
the binary image. By gradually apply dilate and erode operators (cvDilate and
cvErode in OpenCV) on the mask image the holes were filled.
However, due to the quadrangular structure element used by the morpholog-
ical operators the tip structure of the object mask image was deteriorated. Later
on during the segmentation process the damaged tip structure showed to be an
obvious drawback.
Instead of using the morphological operators, a new method referred to as the
Hough Filling Method (HFM) was invented.
Figure 5.2: Binary mask image from background subtraction after applying the
HFM.
40 CHAPTER 5. IMAGE SEGMENTATION OF ROBOT TOOL
And such a function will always have a gradient. The easiest way of finding the
gradient is probably to convolve the image with the sobel operators.
1 0 −1 −1 2 −1
Gx = 2 0 −2 , Gy = 0 0 0
1 0 −1 1 2 1
q
The edge image may then be retrieved as fedge = (f ∗ Gx )2 + (f ∗ Gy )2
Unfortunately this method won’t, according to [2], work properly in noise af-
fected environments. Irregular light conditions will also decrease the functionality
of this method.
Where b(x, y) is the resulting image given from the background subtraction and
HFM methods. To ensure that all of the tool was left in the masked image fmasked ,
the dilation operator was applied to b(x, y) before calculating fmasked according
to equation 5.7.
5.4. CONTOUR RETRIEVING 41
After applying the Canny edge detection algorithm on the masked image fmasked ,
the binary edge image bedge was obtained. The Canny algorithm is implemented
in the OpenCV library function cvCanny [18].
The threshold values in the cvCanny function had to be determined according
to the current environment. If the image contained a lot of noise, the threshold had
to be set to a high value to ensure the elimination of the noise. Unfortunately the
high threshold sometimes resulted in discontinuities of the tool edges in the edge
image bedge . To solve the problem of discontinuities of the tool edges the Hough
Filling Method (see section 5.2.2.1 on page 39) was used with an excellent result.
Another disadvantage was the presence of a light reflection in the metallic surface
of the tool. The contour of the reflection had the same shape as the actual tool,
resulting in a possible false hit later in the segmentation procedure. To avoid the
influence of light reflections the tool was painted in a non-reflecting colour.
The spline function is affected by internal forces Eint (v(s)), external forces
Eimg (v(s)) and Econ (v(s)).
The internal forces affecting the active contour are divided in tension forces
and rigidity forces. The tension forces imply spring behaviour of the spline func-
tion, while the rigidity forces make the spline function resist bending.
dv(s) 2 d2 v(s) 2
Eint (v(s)) = α(s)
+ β(s)
ds2
ds
Where α(s) specifies the elasticity and β(s) specifies the rigidity of the spline
function.
The external forces consist of image forces Eimg and user specified constraint
forces Econ . The image force is an image, where each pixel value defines a force.
The constraint forces can be used to guarantee that the active contour is not getting
stuck at a local minima. The constraint forces might be set by a higher level
process.[21]
One can compare the snake algorithm to a rubber band expanded to its maxi-
mum when the algorithm is initialized. The rubber band then iteratively contract
until the energy function in each node has reached equilibrium.
By using the binary edge image as the external force and defining the initial
contour to be the result of applying the Freeman scan line method to the binary
mask image, the active contour will successively contract until it perfectly en-
closes the object, see figure 5.5
Figure 5.5: The snake contour at initial state to the left and at the final state to the
right. The contour is randomly color coded from the start point to the end point of
the contour.
In fact the mask image and the initial active contour have to be larger than
the object itself to be able to enclose the object. If there are structures or patterns
44 CHAPTER 5. IMAGE SEGMENTATION OF ROBOT TOOL
behind the object, the active contour might get stuck due to forces in the edge
image belonging to these structures see figure 5.6. This drawback together with
the fact that the algorithm is iterative and therefore time consuming made the
Freeman method better suited for retrieving the contour.
Figure 5.6: The snake contour could get stuck at the background pattern. The
contour is randomly color coded from the start point to end point of the contour.
were then compared two by two to find the two lines being most parallel to each
other. See figure 5.8. By this method four out of five of the desired points were
easily determined. Finding the last point (TCP) of interest, was then becoming
easy while it was the only point lying on the complex hull fulfilling the constraint
of being a nearest neighbour of two of the points already found. The method
was fast and performed well as long as the robot only made reorientations around
axis five during the background subtraction method. When more complex robot
movements were used, a huge number of defect points in the convex hull were
found resulting in that the method became time consuming. Instead the polygonal
approximation method was evaluated.
Figure 5.7: The green lines is the convex hull found by the method, and the red
dots are the points defining the convex hull and the defect points.
Figure 5.8: The four lines are illustrated in this figure. The green lines are the two
lines being most parallel and found by the logics. The red lines are not parallel
and will therefore be neglected.
the OpenCV library). The reason of using a polygon approximation method was
due to the possibility to set the approximation accuracy to a level where the tool
object only consisted of five points see figure 5.9
All three points had one thing in common, their locations were at corners. By
matching the three points given by polygonal approximation algorithm with the
closest points of high certainty being a corner, the three points in the figure 5.11
was found.
To find the three points of high probability being corners in the neighbourhood
of the points given by the polygonal approximation, three different methods were
evaluated.
The Harris corner detection algorithm makes use of the information stored in
the eigenvalues of M.
R |R| Result
> 0 Large Corner
< 0 Large Edge
− Small Flat
Table 5.2: Interpretation of R.
Figure 5.12: Image of robot tool used for Harris corner detection.
Figure 5.14: Accurate sub pixel corner detection. The blue arrows are the image
gradients and the green vectors are the vectors from q to pi .
50 CHAPTER 5. IMAGE SEGMENTATION OF ROBOT TOOL
Observe, all vectors qpi are orthogonal to ∇Ii . To retrieve the corner point q
with sub pixel accuracy, i in equation 5.15 was minimized for several points pi
resulting in a system of equations giving q.
Please, refer to [18] for more information about sub pixel accuracy.
The fast radial algorithm resulted in more points of interest in relation to the
Harris corner detector. In this particular case the algorithm found many false hits.
Due to this effect, the fast radial algorithm was rejected.
Let:
−X 2
g(x) = e 2σ2
−Y 2
g(y) = e 2σ2
∂g(x) −X −X 2
= 2 e 2σ2
∂x σ
∂g(y) −Y −Y 2
= 2 e 2σ2
∂y σ
∂g(x)
h1 (x, y) = ∗ g(y)
∂x
∂g(y)
h2 (x, y) = ∗ g(x)
∂y
Figure 5.16 shows h1 (x, y) and h2 (x, y). By performing a 2D convolution of
h1 (x, y) and image I(x, y) the image Ix was retrieved. Observe, a faster way to
implement the function is to perform a sequence of 1D convolutions on image
I(x, y).
∂g(y)
Ix = I(x, y) ∗ g(x) ∗
∂y
The double angle representation of orientation can be retrieved from the ori-
entation tensor T.
Let v be the double angle orientation vector.
! ! !
v1 T11 − T22 Ix2 − Iy2
v= = =
v2 2T12 2Ix Iy
By finding the orientation tensor to the image achieved by the camera and
calculating the orientation image, figure 5.19 was retrieved. For every pixel a line
was drawn in the direction specified by the orientation image. If all lines were
accumulated the three points could be found by applying a high threshold.
Observe, by calculating the histogram of the orientation image it is possible to
tell if the tool was found in the image. Figure 5.20 shows the histogram. Three
peaks are observed, the highest peak is the orientation of the two longest sides
of the tool, while the two lower peaks are the orientations of the two shortest
sides of the tool. The relations between these three orientations are specific for
the tool. Of course the tool has to be segmented before calculating the histogram,
otherwise the tool specific orientations would be impossible to determine among
all the orientation information in the image. The histogram can also be used to
find the orientation of the tool (the highest peek in the histogram), after the tool
has been segmented.
Results
In this chapter the results of different tests will be presented. The tests were
performed to determine the accuracy of the method.
To be able to determine the repetition accuracy of the camera the start position
h iT
of the TCP found by the method was stored in a vector POS1 = x1 y1 z1 .
The robot was then randomly moved to a second position. The new position of
h iT
TCP was measured by the method several times and stored as POSi = xi yi zi .
55
56 CHAPTER 6. RESULTS
Where i is the estimation number. The tool used during this test was the chess
board in figure 4.3 and 24 points of the chess board pattern were used to determine
the transformationq between the camera and the tool (chess board). For all i the
movement mi = (x1 − xi )2 + (y1 − yi )2 + (z1 − zi )2 was calculated.
Figure 6.2 shows the result of mi .
By the graph it is possible to determine the difference between the maximum
and minimum interval to approximately 0.03 mm, resulting in that the camera is
not able to measure distances shorter than 0.03 mm.
P10
i=1 mi
mj = (6.1)
10
During the test every mj was the average of ten different mi . The result is illus-
trated in figure 6.3. The difference between the maximum and minimum interval
was still determined to 0.03 mm. It is then obvious that averaging the result does
not increase the repetition accuracy of the camera when 24 points are used for
measuring the transformation between the camera and the tool (chess board).
6.1. REPETITION ACCURACY OF THE CAMERA 57
6.1.2 How does the number of points affect the repetition ac-
curacy
To investigate how the amount of points in the chess board pattern affects the
repetition accuracy of the camera, the same test (not with averaging) was done
again. Although, this time only the three most upper left points of the chess board
pattern were used to measure the transformation between the camera and the tool
(chess board).
Observe, three points are minimum for finding the transformation between the
camera and the tool. This is due to the fact that a plane is needed to be observed
by the camera to determine the homography, see section 4.2. A plane is by its
definition defined of at least three points.
The result of the new test is illustrated in figure 6.4 The difference between
the maximum and minimum interval was determined to approximately 0.58 mm.
The greater difference between the maximum and minimum interval indicates the
number of points used during the test affects the repetition accuracy. Although,
still using only three points the camera repetition accuracy is better than 1 mm.
58 CHAPTER 6. RESULTS
Figure 6.4: Movment mi plotted for all i when only 3 points of the chess board
were observed.
6.2. CAMERA VERSUS ROBOT MEASUREMENTS 59
Figure 6.5: Difference of rotation measured by the robot versus the camera.
6.2. CAMERA VERSUS ROBOT MEASUREMENTS 61
dif fzi
Figure 6.6 illustrates |diff | during movements in the X direction of the robot
base coordinate system. Figure 6.7 and Figure 6.8 illustrates |diff | during move-
ments in Y direction and Z direction of the robot base coordinate system respec-
tively. Table 6.1 shows the resulting differences between maximum and minimum
intervals and the maximum deviations. Observe, the accuracy is higher in the Y
and Z directions in relation to the X direction.
Figure 6.12: Distance dcamera registered by the camera when a movement of 0.1
mm in X-direction was performed by the robot. The dashed line is the camera
repetition accuracy.
68 CHAPTER 6. RESULTS
Figure 6.13: Distance dcamera registered by the camera when a movement of 0.1
mm in Y-direction was performed by the robot.
Figure 6.14: Distance dcamera registered by the camera when a movement of 0.1
mm in Z-direction was performed by the robot.
6.4. REPETITION ACCURACY OF THE TCP CALIBRATION METHOD 69
d dcamera
T CPz
result of T CPx , T CPy , T CPz for the different runs of the method are illustrated
in figure 6.15, figure 6.16 and figure 6.17 respectively. Table 6.4 shows the dif-
ferences between the maximum and minimum interval for each of the results. By
observing the information in table 6.4, it is obvious the desired accuracy of 1 mm
was obtained.
70 CHAPTER 6. RESULTS
Figure 6.15: Repetition accuracy of T CPx measured by the proposed TCP cali-
bration method.
Figure 6.16: Repetition accuracy of T CPy measured by the proposed TCP cali-
bration method.
6.4. REPETITION ACCURACY OF THE TCP CALIBRATION METHOD 71
Figure 6.17: Repetition accuracy of T CPz measured by the proposed TCP cali-
bration method.
T CPx 0.97
T CPy 0.52
T CPz 0.48
q
T CPx2 + T CPy2 + T CPz2 0.66
Table 6.4: Difference of max and min interval of |TCP| and for the elements of
TCP respectively.
72 CHAPTER 6. RESULTS
6.4.0.1 How does the number of points affect the repetition accuracy of the
TCP calibration method
To investigate how the number of points affect the repetition accuracy of the pro-
posed TCP calibration method, the same procedure was executed but only the
three most upper left points of the chess board pattern were observed. The method
managed to give a satisfying result most of the times, but the method became un-
reliable and very time consuming. Sometimes the robot diverged from the correct
TCP point during the iterative phase. This implies more than three points have to
be observed to make the method reliable.
Although, the reason why the robot sometimes diverged during the iterative
procedure might be that the wrong solution to the three points was found. If
three points with almost the same distances to each other are observed, it might
be difficult for the algorithm to distinguish between the points. This results in
three possible solutions, but only one of the solutions is correct. If the mirrored
solutions are concerned, six different solutions are possible to find. The mirrored
solutions were removed during the test by only permitting solutions with Z > 0,
where Z is the camera coordinate axis coinciding with the optical axis.
Chapter 7
Discussion
This chapter presents the conclusion of this Master’s thesis. Problems and diffi-
culties are described and the chapter concludes with a discussion of future devel-
opment.
7.1 Conclusion
This thesis has proposed a new method for tool center point calibration. The
method can be split into three different parts.
1. Calculation of a good guess of the Tool Center Point, by solving a closed
loop of transformations resulting in a homogeneous equation AX1 = X1 B.
7.1.1 Accuracy
Tests have been performed with regard to investigate the accuracy of the pro-
posed method. The tests showed the need of the iterative method to achieve a
satisfying accuracy. Due to the fact that only accuracy of the camera when reg-
istering a movement between two different positions limits the accuracy of the
73
74 CHAPTER 7. DISCUSSION
To be able to determine the transformation between the camera and the tool, at
least three distinct points on the tool have to be observed by the camera. In this
thesis results have been presented, showing that it is possible to perform a cal-
ibration by only observing three points. However, to make the method reliable
and fast, more points are needed. If the tool has a very simple geometry it might
be difficult to find several points and assure it is the same points found in every
frame.
This problem can be solved by for instance painting the tool with a certain
pattern. Another possibility would be to press a matrix pattern on the tool. The
matrix pattern could then also store information about what kind of tool it is.
The best idea though, would probably be to ensure that the tool has some kind
of structure e.g. not a simple geometric shape.
A major problem during the development of the image segmentation part of the
method, was the influence of light reflections in the tool. This is a well known
problem within the field of image segmentation. Several methods exist to make
image segmentation robust against reflections, but no suitable functions for solv-
ing this problem exist in the Open Computer Vision library. Instead the problem
was solved by painting the tool in a non reflecting color.
Before using the method in an industrial environment, this problem must be
solved.
7.2. FUTURE DEVELOPMENT 75
Observe, other methods for solving this problem exist. For instance the rota-
tion symmetry can be removed by painting the tool with a non symmetric pattern.
Attaching a blinking light emitting diode (LED) to the tool, easy to find by image
segmentation, can also remove the symmetric geometry.
By fasten a calibration pattern, for instance a chess board pattern, at the tool
it is possible to determine the transformation between the camera frame and the
robot’s base frame. The iterative method then works even though the tool is rota-
tion symmetric. Instead of fasten a calibration pattern at the tool, a matrix pattern
can be pressed on the tool. Pressing a pattern on the tool will also solve the prob-
lem of finding distinct points, see section 7.1.2.1.
configured for correction of the current TCP calibration. By placing the camera
at a fixed position and once and for all determine the relation between the camera
and the robot base frame, only the iterative part of the method is needed to deter-
mine the correct placement of the tool center point. The initial guess of the TCP
is then of course chosen to be the current tool center point.
Appendix
This appendix will present the results of the camera calibration done during this
project.
79
80 APPENDIX A. APPENDIX
Table A.1: The camera calibration result given by camera calibration toolbox for
Matlab.
A.1. FINDING INTRINSIC PARAMETERS 81
[1] ABB, Rapid reference manual Industrial robot controller system. ABB.
[4] Donald Hearn, M.Pauline Baker, Computer Graphics with OpenGL. Pearson
Education, Inc. Upper Saddle River: Pearson Prentice Hall, third ed., 2004.
[5] Lung-Wen Tsai, Robot Analysis The Mechanics of Serial and Parallel Ma-
nipulators. 605 Third Avenue, New York, N.Y. 10158-0012: John Wiley &
Sons, INC., 1998.
[6] Z. Zhang, “A flexible new technique for camera calibration,” technical re-
port, Microsoft Research, http://research.microsoft.com/ zhang, 8 2002.
[7] Jintao Wang, Daokui Qu and Fang Xu, “A new hybrid calibration method
for extrinsic camera parameters and hand-eye transformation,” International
Conferance on Mechatronics and Automation Niagara Falls, Canada, July
2005.
[9] Fadi Dornaika and Radu Horaud, “Simultaneous robot-world and hand-eye
calibration,” IEEE Transaction on Robotics and Automation, vol. 14, August
1998.
[10] Roger Y. Tsai and Reimark K.Lenz, “A new technique for fully au-
tonomous and efficient 3d robotics hand/eye calibration,” IEEE Transaction
on Robotics and Automation, vol. 5, June 1989.
87
88 BIBLIOGRAPHY
[21] F. Albregtsen, “Active contours and region based segmentation,” INF 269
Digital Image Analysis, p. 25, 10 2002. Lecture 6.
[22] C. Harris and M.J. Stephens, “A combined corner and edge detector,” Alvey
Vision Conference, pp. 147–152, 1988.
[23] G. Loy and A. Zelinsky, “Fast radial symmetry for detecting points of in-
terest,” IEEE Transaction on Pattern Analysis and Machine Intelligence,
vol. 25, pp. 959–973, August 2003.
[24] Gösta H. Granlund, Hans Knutsson, Signal Processing for Computer Vision.
P.O Box 17, 3300 AA Dordrecht The Netherlands: Kluwer Academic Pub-
lishers, 1995.
BIBLIOGRAPHY 89
[25] C. Mota, I. Stuke, and E. Barth, “Analytic solutions for multiple motions,”
International Conference on Image Processing, 2001. Institute for Signal
Processing, University of Lübeck Ratzeburger Allee 160, 23538 Lübeck,
Germany.
In English
The publishers will keep this document online on the Internet - or its possible
replacement - for a considerable time from the date of publication barring
exceptional circumstances.
The online availability of the document implies a permanent permission for
anyone to read, to download, to print out single copies for your own use and to
use it unchanged for any non-commercial research and educational purpose.
Subsequent transfers of copyright cannot revoke this permission. All other uses
of the document are conditional on the consent of the copyright owner. The
publisher has taken technical and administrative measures to assure authenticity,
security and accessibility.
According to intellectual property law the author has the right to be
mentioned when his/her work is accessed as described above and to be protected
against infringement.
For additional information about the Linköping University Electronic Press
and its procedures for publication and for assurance of document integrity,
please refer to its WWW home page: http://www.ep.liu.se/
© [Johan Hallenberg]