Processing math: 100%


Two-link anaytical method - Worksheet


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)22(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.

  1. What is desired length r between joint 1 and the target? r=||p0dp01||=4
  2. What is l1?

    because lengths cannot change, we can simply compute the magnitude of the offset between joint 2 and joint 1. ||d12||=3

  3. What is l2?

    The length will be the magnitude of the offset between joint 3 and joint 2. ||d23||=2

  4. What is ϕ? cos(ϕ)=r2(l1)2(l2)22(l1)(l2)=(4)2(3)2(2)22(3)(2)=0.25 ϕ=arccos(0.25)=1.8235radians
  5. What is θ2z? θ2z=ϕπ=1.3181radians
  6. Verify that p03 and p01 are the correct distance apart by plugging Rz(θ2z) into the kinematic equation for these joints. [p031]=[Id0101][Rz(θ2z)d1201][Id2301][01]

    The new global position of joint 3 is (3.5, -1.93649, 0)T, so the distance is ||p03p01||=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 p03p01 towards p0d.

Step 2a: Point the limb along the x-axis

  1. What is the angle θ1z? sin(θ1z)=(l2)sin(θ2z)r=(2)(sin(1.3181))4=0.48412 θ1z=arcsin(0.48412)=0.50536radians
  2. Verify that the limb now points along the x axis by pluggin in θ1z into the kinematic equation. [p031]=[Rz(θ1z)d0101][Rz(θ2z)d1201][Id2301][01]

    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 p03p01 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.

  1. What is the heading β? β=atan2(p0dz,p0dx)=atan2(0,3)=π
  2. What is the elevation γ? γ=arcsin(p0dyr)=arcsin(74)=0.72272
  3. Verify that the p03 is at p0d by plugging in the rotation for joint 1 into the kinematic equation. [p031]=[Ryzx(0,β,γ)Rz(θ1z)d0101][Rz(θ2z)d1201][Id2301][01]=[Ry(β)Rz(γ)Rz(θ1z)d0101][Rz(θ2z)d1201][Id2301][01]

    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 p03p01 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!)

  1. What is the limb direction r0? r0=p03p01=[3.51.936490][000]=[3.51.936490]
  2. What is the error direction e0? e0=p0dp03=[370][3.51.936490]=[6.54.582240]
  • What is the direction r0×e0? r0×e0=[003.45065]
  • What is the angle of rotation ϕ and axis of rotation u0? ϕ=atan2(||r0×e0||,r0r0+r0e0)=2.9242radians u0=r0×e0||r0×e0||=[001]
  • Verify that the p03 is at p0d by plugging in the rotation for joint 1 into the kinematic equation. [p031]=[Ru(ϕ)d0101][Rz(θ2z)d1201][Id2301][01]

    The global position of joint 3 in now (-3, 7, 0)T.