Suppose we have the 2-link chain below. We wish to compute rotations for
joint 1 and joint 2 so that joint 3's position is located at a target pd.
The root joint position p1 is located at the origin.
The next joint position p2 is offset from p1 by (3,0,0)T
The next joint position p3 is offset from p2 by (2,0,0)T
The target position is p0d=(−3,√7,0)T.
This approach has two parts.
Kinematic equation
To begin, let's write the kinematic equation for this joint chain. [p031]=[R01d0101][R12d1201][R23d2301][01] where
To start, each Rji=I. We want p03 to equal p0d
Step 1: Length
We will compute the rotation for joint 2 that makes the length between p03 and p01 match the length between p03 and p0d. Because our joint chain extends along the x axis, this rotation will be around z. Let's call this rotation θ2z.
Recall that the law of cosines gives us the relationship between the angle at joint 2 and distance between p03 and p01. r2=(l1)2+(l2)2−2(l1)(l2)cos(ϕ) where
Once we have ϕ, we can compute the corresponding rotation angle at joint 2 as θ2z=ϕ−π. With this configuration, our final rotation will be Rz(θ2z)
Let's compute the rotation for joint 2.
because lengths cannot change, we can simply compute the magnitude of the offset between joint 2 and joint 1. ||d12||=3
The length will be the magnitude of the offset between joint 3 and joint 2. ||d23||=2
The new global position of joint 3 is (3.5, -1.93649, 0)T, so
the distance is
||p03−p01||=4
Step 2: Orientation - Polar coordinate method
Now that p01 and p03 are the correct distance apart, we need to compute the rotation for joint 1 that points the vector p03−p01 towards p0d.
Step 2a: Point the limb along the x-axis
The new global position of joint 3 is (4, 0, 0)T. Because joint 1 is located at the origin, we can see that the direction p03−p01 points along the x-axis.
Step 2b: Point the limb to the target
Compute the euler angles YZX for p1 which points towards pd. In this formulation the heading will be used to construct a Y rotation and the elevation will be used to construct a Z heading. The X rotation is zero because this only casues the limb to twist, so it doesn't affect the position of joint 3.
The global position of joint 3 in now (-3, √7, 0)T.
Step 2: Orientation - angle/axis method
Now that p01 and p03 are the correct distance apart, we need to
compute the rotation for joint 1 that points the vector p03−p01 towards
p0d.
This time, let's use the angle/axis computation from our CCD algorithm. When using this approach, the nudge factor is one. In this context, we wish to solve directly for the full angle. Because this method computes a relative angle, it often looks better if we reset the joint rotation to identity before computing the angle/axis. (Watch out: we do not want to reset to identity when implementing the CCD algorithm!)
The global position of joint 3 in now (-3, √7, 0)T.