Robot PDF
Robot PDF
- Topic 4 -
Inverse Kinematics of Robot
Manipulators
Prof. Oscar E. Ramos, Ph.D.
- Week 4 -
Objectives
2
Outline
1. Introduction
3. Multiplicity of solutions
4. Analytic solutions
5. Numeric solutions
{n}
qi+1
4
Kinematics of Robot Manipulators
x f (q)
Forward
Joint Kinematics Operational
space space
q (q1 , , qn ) x ( x, y , z , , , )
- Forward kinematics
Given a joint configuration, find the pose (position/orientation) of some part of
the robot (e.g. end effector)
Given q (q1 , , qn )
0
Find Tn (q) or x f (q) For example: x ( x, y, z , , , )
5
Kinematics of Robot Manipulators
Joint Operational
space space
q (q1 , , qn ) x ( x, y , z , , , )
Inverse
kinematics
q f 1 (x)
- Inverse kinematics
Find the joint configuration needed to achieve a certain position/orientation
(pose) for some part of the robot
0
GIven Tn (q) or x f (q) for some point of the robot (e.g. end effector)
Find q (q1 , , qn )
6
Kinematics of Robot Manipulators
Example: R-R Robot
ŷ
Cartesian Joint
y variables variables
x q
l2 x q 1
q2 y q2
l1 Considering
only position
q1
x x̂
Position and
Orientation
where:
Stanford Manipulator
8
Kinematics of Robot Manipulators
Example: Inverse Kinematics
¡System of nonlinear
trigonometric equations!
Stanford Manipulator
9
Inverse Kinematics
• It is a synthesis problem
• The input data (position and orientation) are of the form:
R t x
T x p
0 0 0 1 xr
Classical formulation: Generalized formulation:
Inverse kinematics for the end effector Inverse kinematics for task variables
• It is a nonlinear problem:
- Is there a solution? Answer: workspace,
- Is there a unique solution, or multiple solutions? redundancy
- How to solve it?
10
Outline
1. Introduction
3. Multiplicity of solutions
4. Analytic solutions
5. Numeric solutions
ŷ
l1 > l2
y p x
y
l2
q2
l1
q1
x̂
x
WS {p 2 :| l1 l2 |‖p‖ l1 l2 }
with q1 ∈ [0, 2π], q2 ∈ [0, 2π]
13
Workspace
Example: R-R Robot
Workspace
ŷ
l1 > l2
y p x
y
l2
q2
l1
q1
x̂
x
14
Workspace
- For all p ∈ WS2 there is (at least) one solution for every orientation
15
Workspace
• Example:
ABB’s IRB 360 robot
1. Introduction
3. Multiplicity of solutions
4. Analytic solutions
5. Numeric solutions
If only position is
considered, the 4
configurations set the end
effector at the same point
Multiplicity of solutions
PUMA 560 20
Multiplicity of Solutions
What solution to choose?
- n joints: q (q1 , , qn )
- Task space: x ( x1 , x2 , , xm )
m: dimension of the task space
22
Inverse Kinematics
Complexity
23
Inverse Kinematics
Solution Methods
• Analytic Solution (exact)
- It is preferred, when it can be found
- Methods:
• Geometric ad-hoc approach
• Algebraic approach (solution of polynomial equations)
• Systematic reduction approach (obtain a reduced set of equations)
• Kinematic decoupling (Pieper): robots with 6 dof
– When the last 3 axes are revolute and they intersect each other (spherical wrist)
24
Outline
1. Introduction
3. Multiplicity of solutions
4. Analytic solutions
5. Numeric solutions
• Example:
Find the inverse kinematics for the position of the R-R robot using a
geometric approach
ŷ
y
l2
l1 q2
q1
x x̂
26
Geometric Solutions
• Example: ŷ
Find the inverse kinematics for the position of
y
the R-R robot using a geometric approach
l l2
Solution q2
l1
For q2 :
q1
- Using the law of cosines: x x̂
l 2 l12 l22 2l1l2 cos(180 q2 )
For q1 (using the geometry of the figure)
x 2 y 2 l12 l22 2l1l2 cos(q2 )
q1
2 2 2 2
x y (l l2 )1
c2 atan2( y, x)
2l1l2
- Using a trigonometric identity:
atan2(l2 s2 , l1 l2 c2 )
s22 c22 1
Inverse kinematics:
2
s2 1 c 2 q1 atan2( y, x) atan2(l2 s2 , l1 l2 c2 )
q2 atan2( s2 , c2 ) q2 atan2( s2 , c2 )
27
Algebraic Solutions
• Example:
Find the inverse kinematics for the position of the RR robot using an algebraic
approach
ŷ
Solution
- Forward kinematics:
y
x l1 c1 l2 c12 y l1 s1 l2 s12 l2
- For q2 : l1 q2
• Example:
Find the inverse kinematics for the position of the RR robot using an algebraic
approach
Solution
- For q1 (expanding terms from forward kinematics): ŷ
x l1c1 l2 (c1c2 s1s2 ) y
y l1s1 l2 ( s1c2 c1s2 )
l2
Equations are linear in c1, s1: solve for them: q2
l1
x c1 (l1 l2 c2 ) s1 (l2 s2 )
y s1 (l1 l2 c1 ) c1 (l2 s2 ) q1
x x̂
In matrix form:
y (l1 l2 c2 ) xl2 s2
s1
l1 l2 c2 l2 s2 c1 x solving det
ls
2 2 l1 l2 c2 s1 y x(l l c ) yl2 s2
c1 1 2 2
det
q1 atan2( s1 , c1 )
det l12 l22 2l1l2 c2
29
Algebraic Solutions
• Example 2
For a 3-dof robot, its end effector pose with respect to its base is given by
where a3 and d1 are constants. The desired pose for the end effector is:
Solution
The procedure consists in obtaining relations between both matrices, and
applying some algebra, so that the value for each joint can be solved.
30
Algebraic Solutions
• Example 2
- Finding :
- Finding :
- Finding :
31
Outline
1. Introduction
3. Multiplicity of solutions
4. Analytic solutions
5. Numeric solutions
f (q)
• They use the Jacobian matrix: J (q) J (q) nm
q
• Usual solution methods:
- Newton’s method
- Gradient descent method
x d f (q k ) J (q k )(q q k )
q k 1 q k J 1 (q k ) x d f (q k )
34
Numeric Solutions
a) Newton’s Method
• Algorithm:
- Start with an initial q0 (usually the current configuration)
- Iteratively update using:
q k 1 q k J 1 (q k ) x d f (q k ) k = 0,1,2,3,…
- Stop when:
‖x d f (q k )‖ or ‖q k 1 q k‖ : small value
Small Cartesian error Small joint increment
• Comments:
- Convergence if we start with q0 (initial value) close to the solution
- When there is redundancy (m < n):
J is not square (and there is no inverse)! → we use the pseudo-inverse
- Disadvantages:
• Computation time of the inverse (or pseudo-inverse)
• Problems near singularities of J (Jacobian matrix)
- Advantage: it is fast (quadratic convergence)
35
Numeric Solutions
a) Newton’s Method
• Example: RR robot
Compute the joint values needed for the end effector to be at x = 1.2, y = 1.2
using Newton’s method. Assume that l1 = l2 = 1.
Solution ŷ
c1 c12
- Forward kinematics: f (q ) s s y
1 12
l2
- Jacobian matrix:
l1 q2
f x f x
f (q) q1 q2 ( s1 s12 ) s12 q1
J (q)
q f y f y c c c12 x x̂
1 12
q1 q2
Desired position:
- Inverse of the Jacobian:
1.2
1 c12 s12 xd
J 1 (q) (c c ) ( s s ) 1.2
s2 1 12 1 12
36
Numeric Solutions
a) Newton’s Method
• Example: RR robot
Compute the joint values needed for the end effector to be at x = 1.2, y = 1.2
using Newton’s method. Assume that l1 = l2 = 1.
Solution
- Expression for Newton’s method:
q k 1 q k J 1 (q k )(xd f (q))
- Replacing the previous values:
- It is iteratively applied
For example, use q1 = 0.5 y q2 = 0.5 as initial values (note: we cannot start with q2 = 0
since J-1 would not exist)
37
Numeric Solutions
a) Newton’s Method
• Example: RR robot
import numpy as np
cos=np.cos; sin=np.sin
• Example: RR robot
- Note that the result depends on the initial value.
- Results:
0.2278 1.3430
q q
1.1157 1.1152
1.4
1.2
0.8
0.6
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1 1.2
39
(Generic Gradient Descent)
• Objective:
- Minimize the generic function g (q)
min g (q)
q
• Idea:
- Start with an initial value q0
- “Move” in the negative direction of the gradient ( g), iteratively
- The step size α > 0 must guarantee a maximum descent of g(q) in every
iteration:
• α very high: it can lead to divergence (the minimum is not found)
• α very small: it generates a slow convergence
q k 1 q k g (q k )
q k 1 q k J T (q k ) x d f (q k )
• Example: RR robot
Compute the joint values for the end effector to be at x = 1.2, y = 1.2 using the
gradient descent method. Assume that l1 = l2 = 1.
Solution ŷ
c1 c12
- Forward kinematics f (q ) s s y
1 12
l2
- Jacobian matrix: q2
l1
f x f x
q1
f (q) q1 q2 ( s1 s12 ) s12
J (q)
f y c c x x̂
q f y c12
1 12
q1 q2
Desired position:
- Transpose of the Jacobian:
1.2
( s s ) c1 c12 xd
J T (q) 1 12 1.2
s12 c12
42
Numeric Solutions
b) Gradient Descent Method
• Example: RR robot
Compute the joint values for the end effector to be at x = 1.2, y = 1.2 using the
gradient descent method. Assume that l1 = l2 = 1.
Solution
- Expression for gradient descent:
q k 1 q k J T (q k )(x d f (q))
- Replacing the previous values:
- It is iteratively applied.
For example, use q1 = 0.5 y q2 = 0.5 as initial values (in this case we can start with
q2 = 0)
43
Numeric Solutions
b) Gradient Descent Method
• Example: RR robot
import numpy as np
cos=np.cos; sin=np.sin
• Newton’s method
- Quadratic convergence rate (it is fast)
- Problems near singularities (singularities can be computed using the singular
values of J)
• Efficient algorithm:
- Start with the gradient descent method (safe, but slow)
- Then switch to Newton’s method
45
Outline
1. Introduction
3. Multiplicity of solutions
4. Analytic solutions
5. Numeric solutions
• Example
Consider the following forward kinematics (R-R Robot with l1 = l2 = 1):
f x (q) cos(q1 ) cos(q1 q2 )
f (q)
f y (q ) sen( q1 ) s en( q1 q )
2
Compute the Jacobian numerically when the joint values are q1 = 0.5, q2 = 1.0
Solution
- The Jacobian is: f x f x
q q2
1
J (q)
f y f y
q1 q2
- Derivatives with respect to q1 (first column):
f x f x (q1 q1 , q2 ) f x (q1 , q2 ) cos(q1 q1 ) cos((q1 q1 ) q2 ) cos(q1 ) cos(q1 q2 )
q1 q1 q1
f y
f y (q1 q1 , q2 ) f y (q1 , q2 )
sen(q1 q1 ) sen((q1 q1 ) q2 ) sen(q1 ) sen(q1 q2 )
q1 q1 q1
48
Numeric Computation of the Jacobian
• Example
Consider the following forward kinematics (R-R Robot with l1 = l2 = 1):
f x (q) cos(q1 ) cos(q1 q2 )
f (q)
f y (q ) sen( q1 ) s en( q1 q )
2
Compute the Jacobian numerically when the joint values are q1 = 0.5, q2 = 1.0
Solution
- The Jacobian is: f x f x
q q2
1
J (q)
f y f y
q1 q2
- Derivatives with respect to q2 (second column):
f x f x (q1 , q2 q2 ) f x (q1 , q2 ) cos(q1 ) cos(q1 (q2 q2 )) cos(q1 ) cos(q1 q2 )
q2 q2 q2
f y
f y (q1 , q2 q2 ) f y (q1 , q2 )
sen(q1 ) sen(q1 (q2 q2 )) sen(q1 ) sen(q1 q2 )
q2 q2 q1
49
Numeric Computation of the Jacobian
• Example
- Using Δq1 = Δq2 = 0.001:
f y
sen(0.5 0.001) sen(0.5 0.001 1.0) sen(0.5) sen(0.5 1.0) 0.9476
q1 0.001
f y
sen(0.5) sen(0.5 1.0 0.001) sen(0.5) sen(0.5 1.0) 0.0702
q2 0.001
• Example
Computationally (using Python):
def fkine(q):
x = np.cos(q[0]) + np.cos(q[0]+q[1]);
y = np.sin(q[0]) + np.sin(q[0]+q[1]);
return np.array([x,y])
q1 = 0.5; q2 = 1.0
delta = 0.001
JT = 1/delta*np.array([
fkine([q1+delta, q2]) - fkine([q1,q2]),
fkine([q1, q2+delta]) - fkine([q1,q2])])
J = JT.transpose()
print(J)
51
Conclusions
52
References
53
Appendix 1: Newton’s Method
• Objective:
- Find the point where the function is zero
- Equivalently: find the intersection of the curve y = f(x) with the x axis, that is:
f(x) = 0
Idea
54
Appendix 1: Newton’s Method
• Example:
Find the intersection with zero for f(x) = 3 + (x-2)3 using the Newton’s method
and 10 iterations
f ( xk ) 3 ( xk 2)3
xk 1 xk xk 1 xk
f ( xk ) 3( xk 2) 2
# Plot
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0,1,0.01)
y = 3 + (x-2)**3 Using Python, the
plt.plot(x,y); plt.plot(xo,0,'o'); intersection is at: 0.55775
plt.grid()
56