Skip to main content
3 of 3
Reintroducing guarantee with inner limit, making second circle an annulus
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

Let's attack this in parts: we'll find where to place the end of the first bone, then figure out where the other two go. Once we've arranged the first bone, what remains is a two-bone IK problem, which we already know how to solve analytically.

The trick is to understand the constraints on where the end of the first bone can end up. It can't be further away from the target than the remaining bones can reach, ie.

Distance(1st bone end, target) <= Length(2nd bone) + Length(3rd bone)

And it also can't be closer to the target than the shortest length the remaining bones can fold to, ie.

Distance(1st bone end, target) >= Abs(Length(2nd bone) - Length(3rd bone)

And lastly, the endpoint of the first bone can't be closer or further from the start point than the bone's own length:

Distance(1st bone end, origin) = Length(1st bone)

Taking these three constraints together, we have an interesection between a circle (the sweep of the first bone) and an annulus (the allowable places the remaining bones can start and still reach the target)

Diagram of three potential solutions

Points where your 1st bone circle (red) intersects the outer rim of the annulus (teal) correspond to solutions where the 2nd and 3rd bone are pulled into a straight line to reach their maximum extent.

Points where it intersects the inner rim correspond to solutions where the remaining two bones are forced to fold 180 degrees to collapse as tightly as possible.

Any intermediate point along the arc(s) of overlap between the circle and annulus (fine solid red curves) are solutions where the second elbow bends some intermediate amount - tighter further in, looser further out.

You can pick any point you like along those curves of overlap - each of the infinite choices corresponds to a feasible solution (barring obstacles / joint angle limits). But some options along these arcs might be better than others, based on considerations like...

  • Proximity to the arm's previous pose
  • Continuity with the arm's previous motion
  • Balancing the amount of bending between the joints
  • Prioritizing more bending at freer joints and less at stiffer/more expensive joints

...etc. What heuristics/algorithms you apply here will depend on your context and how you want the arm to behave.

DMGregory
  • 136.3k
  • 22
  • 247
  • 373