L12 Inverse Kinematics
L12 Inverse Kinematics
Inverse Kinematics:
Planar Arms
Assigning Link Frames
𝑥2 is collinear with the
origin of Frame 1
𝑥2
𝜃2 is the angle from 𝑥1 to 𝑥2
𝑦0
• 𝑥1 is collinear with the origin of Frame 0
𝑥1
• Frame 𝑛 is the end-effector frame. It can be attached to link 𝑛 in any manner that is
convenient.
• In this case, 𝑛 = 2, so Frame 2 is the end-effector frame.
The Forward Kinematic Map
𝑥2 is collinear with the
origin of Frame 1
𝑥2
𝜃2 is the angle from 𝑥1 to 𝑥2
𝑦0
• 𝑥1 is collinear with the origin of Frame 0
𝑥1
𝑥0
Solving for 𝜃2 Denote the coordinates of the
origin of frame 2 by 𝑜2,𝑥 , 𝑜2,𝑦 .
𝑥2
2 2
The Law of Cosines:
𝑟2 = 𝑜2,𝑥 + 𝑜2,𝑦 𝑟 2 = 𝑎12 + 𝑎22 − 2𝑎1 𝑎2 cos 𝛼
Define:
𝑦0 𝜃2 = 𝜋 − 𝛼
𝑎12 + 𝑎22 − 𝑟 2
𝛼 𝐷≝ = cos 𝛼
𝑥1 2𝑎1 𝑎2
𝑥0 Then sin 𝛼 = ± 1 − 𝐷2
Finally,
With this set of equations, we can solve for 𝜃2 2
± 1 − 𝐷
using simple solutions to closed-form equations. 𝛼 = tan−1
We never need to solve a nonlinear system! 𝐷
What about existence and uniqueness?
−1 ± 1−𝐷2
Does a solution always exist for 𝛼 = tan ?
𝐷
No solution exists if 𝐷2 > 1:
2 2 2 2
𝑎1 + 𝑎2 − 𝑟
𝐷2 = ≤1
2𝑎1 𝑎2
𝑎1 ± 𝑎2 2 ≤ 𝑟2
∣ 𝒂𝟏 ± 𝒂𝟐 ∣ ≤ 𝒓
In this case, a solution exists!
What about existence and uniqueness?
−1 ± 1−𝐷 2
Is the solution unique for 𝛼 = tan ?
𝐷
Clearly, the solution is not unique, since we may choose
either square root!
−1 − 1−𝐷2
The second solution uses 𝛼 = tan which results
𝐷
in an “elbow UP” configuration.
𝑥2
𝑥1
Elbow UP
NOTE: when ∣ 𝒂𝟏 ± 𝒂𝟐 ∣= 𝒓
the two solutions “collapse” 𝑦0
into a single solution.
𝑥1
𝑥0 Elbow DOWN
Degenerate Solutions
𝑦0 Arm fully extended
𝑟
𝑥0 𝑥1 𝑥2
𝑎1 + 𝑎2 = 𝑟
𝑦0
𝑟
Arm “folds back” on itself
𝑥2
𝑥0 𝑥1
𝑎1 − 𝑎2 = 𝑟
Solving for 𝜃1 Denote the coordinates of the
origin of frame 2 by 𝑜2,𝑥 , 𝑜2,𝑦 .
𝑥2
2
𝑟 2 = 𝑜2,𝑥 2
+ 𝑜2,𝑦 𝜃1 = 𝛽 − 𝛾
𝑎2 −1
𝑜2,𝑦
𝛽= tan
𝑦0 𝑜2,𝑥
𝛾 𝑥1
𝜃1 𝛽 The Law of Cosines, this time for 𝛾:
𝑥0
𝑎22 = 𝑎12 + 𝑟 2 − 2𝑎1 𝑟 cos 𝛾
With this set of equations, we can solve for 𝜃1
using simple solutions to closed-form equations.
We never need to solve a nonlinear system!
Elbow up is left as an exercise for you!
Position and Orientation
Suppose we wish to position the end effector frame at a specific position, and with a specific
orientation.
• We can parameterize the end effector frame by (𝑿𝒆 , 𝒀𝒆 , 𝝓)
• (𝑿𝒆 , 𝒀𝒆 ) give the position of the origin of the frame
• 𝝓 gives the orientation of the frame:
cos 𝜙 − sin 𝜙 𝑋𝑒
𝑇20 = sin 𝜙 cos 𝜙 𝑌𝑒
0 0 1
• We can’t do this with a two-link arm.
• Intuitively, we have three inputs (𝜃1 and 𝜃2 ) and three outputs.
• Our solution to the two-link arm shows that once we choose 𝜃1 and 𝜃2 the orientation of
the end-effector frame is fully determined.
Add another link!
𝑥3
Three-Link Planar Arm 𝑦3 𝜙
𝜙
(𝑜2,𝑥 , 𝑜2,𝑦 )
(𝑋𝑒 , 𝑌𝑒 )
𝑜2,𝑥 = 𝑋𝑒 − 𝑎3 cos 𝜙
𝑜2,𝑦 = 𝑦𝑒 − 𝑎3 sin 𝜙
𝑥1
𝜃1
𝑥0
𝜽𝟐 = 𝟎 since 𝒙𝟏 and 𝒙𝟐 axes are parallel
1 0 0 1 0 𝑎2 1 0 𝑎2 1 0 𝑎2
𝑇21 = 0 1 0 0 1 0 = 0 1 0 𝑇21 = 0 1 0
0 0 1 0 0 1 0 0 1 0 0 1
Prismatic Joints
• Define Frames 0 and 1 as before: 𝑥1 is collinear
Joint 2 is prismatic.
with the origin of Frame 0.
• Define Frame 2 such that 𝑥2 is collinear with 𝑥1
𝑎2
𝑥2
𝑦0
𝑥1
𝜃1
𝑥0
Inverse Kinematic Solution
As before, let (𝑜2,𝑥 , 𝑜2,𝑦 ) denote the coordinates of the origin of Frame 2.
𝑎2
𝜃3
𝑦0 Joint 2 is prismatic.
𝑥2
𝑥1
𝑥0
𝑎2
𝝓
𝑦0 𝑥2
(𝑜2,𝑥 , 𝑜2,𝑦 )
𝑥1
𝑥0
We’ll need to find other ways to solve the inverse kinematics for such
robots.
Let’s see an example…
Prismatic Joint with link offset
Joint 2 is prismatic.
𝑙2
𝑎2
𝑥2
𝑦0
𝑥1
𝜃1
𝑥0
1 0 0 1 0 𝑎2 1 0 𝑎2
𝑇21 = 0 1 0 0 1 𝑙2 = 0 1 𝑙2
0 0 1 0 0 1 0 0 1
Prismatic Joint with link offset
𝑙2 1 0 𝑎2
𝑎2
𝑥2 𝑇21 = 0 1 𝑙2
𝑦0
0 0 1
𝑥1
𝜃1
𝑥0 cos 𝜃1 − sin 𝜃1 𝑎1 cos 𝜃1 1 0 𝑎2
𝑇20 = sin 𝜃1 cos 𝜃1 𝑎1 sin 𝜃1 0 1 𝑙2
0 0 1 0 0 1
𝑥1
𝜃1
𝑥0
cos 𝜃1 − sin 𝜃1 (𝑎1 +𝑎2 ) cos 𝜃1 − 𝑙2 sin 𝜃1 cos 𝜃3 − sin 𝜃3 𝑎3 cos 𝜃3
𝑇30 = sin 𝜃1 cos 𝜃1 (𝑎1 +𝑎2 ) sin 𝜃1 + 𝑙2 cos 𝜃1 sin 𝜃3 cos 𝜃3 𝑎3 sin 𝜃3
0 0 1 0 0 1
𝑓1 (𝑞)
𝐹 𝑞1 , … , 𝑞𝑛 = ⋮
𝑓𝑚 (𝑞)
• For the two-link arm, we would have
𝑥(𝜃1 , 𝜃2 )
𝐹 𝜃1 , 𝜃2 =
𝑦(𝜃1 , 𝜃2 )
• Denote by 𝑥 𝑑 the desired value of the end-effector pose.
• For the two-link arm we would have
𝑑
𝑜2,𝑥
𝑥𝑑 =
𝑑
𝑜2,𝑦
• Generate a sequence of values 𝒒𝟎 , 𝒒𝟏 , 𝒒𝟐 … until we find some 𝒒𝑵 such that 𝑭 𝒒𝑵 is sufficiently close
to 𝒙𝒅 , i.e.,
𝑭 𝒒𝑵 − 𝒙𝒅 < 𝝐
𝒒𝒊+𝟏 = 𝒒𝒊 + 𝜹𝒒
• To solve the inverse kinematics problem, we wish to minimize the error between 𝑭 𝒒 and 𝒙𝒅 .
• Let’s define 𝐿(𝑞) in terms of the squared error:
1 𝑇
𝐿 𝑞 = 𝐹 𝑞 − 𝑥𝑑 𝐹 𝑞 − 𝑥𝑑
2
• For this problem, we define the iteration as
𝒒𝒊+𝟏 = 𝒒𝒊 − 𝜶𝒊 𝛁𝐋(𝐪𝐢 )
• We can use the scalar 𝜶𝒊 to determine the magnitude of the step size.
𝜕 𝜕 1 2 2 𝜕 𝜕 1
𝐿 𝑞 = 𝑓1 𝑞 − 𝑥1𝑑 + 𝑓2 𝑞 − 𝑥2𝑑 𝐿 𝑞 = 𝑓1 𝑞 − 𝑑 2
𝑥1 + 𝑓2 𝑞 − 𝑑 2
𝑥2
𝜕𝑞1 𝜕𝑞1 2 𝜕𝑞2 𝜕𝑞2 2
𝒒𝒊+𝟏 = 𝑞𝑖 − 𝛼𝑖 𝛻L qi = 𝒒𝒊 + 𝜶𝒊 𝑱𝑻 𝒒𝒊 (𝒙𝒅 − 𝒇 𝒒𝒊 )
Inverse Jacobian Method
Let’s take a look at the Taylor series expansion for the forward kinematic map
around the i-th iteratate:
𝐹 𝑞 𝑖 + 𝛿𝑞 𝑖 = 𝐹 𝑞 𝑖 + 𝐽 𝑞 𝑖 𝛿𝑞 𝑖 + ℎ. 𝑜. 𝑡.
Here, h.o.t. refers to higher order terms (these go to zero quickly as 𝛿𝑞 𝑖 → 0).
If we neglect the higher order terms, the ideal choice for 𝛿𝑞 𝑖 would be
𝛿𝑞 𝑖 = 𝑞 𝑑 − 𝑞 𝑖
in which case we would step to the goal configuration in a single step!
In this case,
𝐹 𝑞 𝑖 + 𝛿𝑞 𝑖 − 𝐹 𝑞 𝑖 ≈ 𝐽 𝑞 𝑖 𝛿𝑞 𝑖
or
𝑥 𝑑 − 𝐹 𝑞 𝑖 ≈ 𝐽 𝑞 𝑖 𝛿𝑞𝑖
and this leads to the update Remember – we don’t know 𝒒𝒅 .
𝜹𝒒𝒊 = 𝑱−𝟏 𝒒𝒊 (𝒙𝒅 − 𝑭 𝒒𝒊 ) Happily, 𝒒𝒅 does not appear on the r.h.s!
What about redundant arms…
• For the two-link arm, we can position the end-effector origin anywhere in the
arm’s workspace: two inputs (𝜃1 , 𝜃2 ) and two “outputs” (𝑋𝑒 , 𝑌𝑒 ).
• For the three-link arm, we can position the end-effector origin anywhere in the
arm’s workspace, and we can choose the orientation of the frame: three inputs
(𝜃1 , 𝜃2 , 𝜃3 ) and three “outputs” (𝑋𝑒 , 𝑌𝑒 , 𝜙).
• Suppose we had a four-link arm?
• Infinitely may ways to achieve a desired end-effector configuration (𝑋𝑒 , 𝑌𝑒 , 𝜙).
The case for 𝑛 > 𝑚
In this case, there are “extra” joints:
𝐹 𝑞𝑖 + 𝛿𝑞𝑖 − 𝐹 𝑞𝑖 ≈ 𝐽 𝑞𝑖 𝛿𝑞𝑖
If we write this out in detail, we see
𝜕𝑓1 𝜕𝑓1
⋯
𝑓1 𝑞𝑖 + 𝛿𝑞𝑖 𝑓1 𝑞𝑖 𝜕𝑞1 𝜕𝑞𝑛 𝛿𝑞1𝑖
⋮ − ⋮ ≈ ⋱ ⋮
𝑓𝑚 𝑞𝑖 + 𝛿𝑞𝑖 𝑓𝑚 𝑞𝑖 𝜕𝑓𝑚 𝜕𝑓𝑚 𝛿𝑞𝑛𝑖
⋯
𝜕𝑞1 𝜕𝑞𝑛
Since 𝑱 is not square, we can’t invert it.
• Suppose 𝑟𝑎𝑛𝑘 𝐽 = 𝑚.
• Then 𝐽𝐽𝑇 ∈ ℝ𝑚×𝑚 and 𝑟𝑎𝑛𝑘 𝐽𝐽𝑇 = 𝑚
• Then 𝐽𝐽𝑇 −1 exists
What can we do with this…
Pseudoinverses
• Define 𝐽+ = 𝐽𝑇 𝐽𝐽𝑇 −1
• Suppose we let 𝛿𝑞 𝑖 = 𝐽+ 𝐹 𝑞 𝑖 + 𝛿𝑞 𝑖 − 𝐹 𝑞 𝑖
Then
𝐽𝛿𝑞 𝑖 = 𝐽𝐽+ 𝐹 𝑞 𝑖 + 𝛿𝑞 𝑖 − 𝐹 𝑞 𝑖 = 𝐹 𝑞 𝑖 + 𝛿𝑞 𝑖 − 𝐹 𝑞 𝑖
• In other words,
𝐽+ 𝐹 𝑞 𝑖 + 𝛿𝑞 𝑖 − 𝐹 𝑞 𝑖 = 𝛿𝑞 𝑖
is a solution to the equation
𝐹 𝑞 𝑖 + 𝛿𝑞 𝑖 − 𝐹 𝑞 𝑖 = 𝐽 𝑞 𝑖 𝛿𝑞 𝑖
• 𝐽+ is called a pseudoinverse.