RyanJuckett.com

Constraint Relaxation IK in 2D - Reaching the Target Print E-mail
  
Monday, 13 April 2009 00:00
Article Index
Constraint Relaxation IK in 2D
Reaching the Target
Resolving Constraints
Implementing for Higher Dimensions
Local Minima
Writing the Code
All Pages

  

Reaching the Target

At the end of the day, we want the root joint to remain at its initial position, the length of each joint to stay rigid, and the end effector (end of the final joint)  to touch the target. The first step is to get the position of all of our joints and the target in a common space. Bones are often stored as rotations relative to a parent bone's orientation. If this is the case, we need to concatenate all of the bone transformations up to the root of the bone chain and convert our target into the same space as our joint positions.

 

Now that we have our joint positions in a common space, we can start the constraint relaxation process. Let's walk through an example iteration.

 

The root joint is located at the origin in the initial kinematic chain orientation (figure 1a).

figure 1a

figure 1a

 

As our first step, we move the final joint (bone3) to be in range of the target. In other words, we place the end effector at the target position by pointing the bone towards the target and sliding is appropriately. Note that this will stretch or compress the parent.  In the example, bone2 is stretched (figure 1b). We are basically, snapping the end effector to the target and then constraining the base of the end bone (bone3) to be the appropriate length from the end effector.

figure 1b

figure 1b

 

We now need to constrain the next bone up the chain to be the appropriate length. In our case, that means bone2 will be compressed back down to its original size (figure 1c). We can adjust the length of the bone by moving either end point. In the example, half of the modification is applied to each end (shrinking the bone towards its center). We could also have weighted each end differently to prefer modification of the child joint position or the current joint position. Weighting the relaxation process with different ratios can be used create different relaxation behavior. For example, weighting motion towards the parent bones will distribute the relaxation down the bone chain and create a smoother curve along the bones.

 

For a longer bone chain, this step is repeated for each bone along the chain up to and not including the root bone.

figure 1c

figure 1c

We can now resolve the root bone's length. In doing so, we want to leave the base of the chain at its original location. We can only modify the end connected to the first child bone (bone2). In the example, bone1 is stretched to match its original length (figure 1d).

figure 1d

figure 1d

We now have a series of points that are a much closer representation to a solution than we started with. If we want to find an even better approximation, we can repeat multiple constraint relaxation passes along the bones. This would consist of once again constraining the end bone (figure 1b), followed by the interior bones (figure 1c), and finally the root bone (figure 1d). Once we have iterated a reasonable number of times (up to a max number or until the positions come to rest), we can apply the results back onto the bone chain.

Our relaxed joint positions are not guaranteed to be at a solution with the proper bone lengths. We may have stopped iterating before a valid solution was found, or there may have been no valid solution leaving the bones stretched. There are a number of ways to interpret the results of the relaxation. We could actually just use the stretched results if stretched bones are a valid option for the use case. We could also reconstrain the bone lengths looping from the root bone out to the end effector. In this example, I have chosen to extract the resulting angles from the single relaxation iteration result and apply them back onto the bones of appropriate length (figure 1e).

figure 1e

figure 1e

 

Due to only using a single relaxation iteration, a valid result was not found on this frame, but if your use case allows, this updated chain can be used as the initial pose on the next frame to distribute the problem over time.

 



Last Updated ( Sunday, 02 May 2010 06:30 )
 

Creative Commons License
RyanJuckett.com site content by Ryan Juckett is licensed under a Creative Commons Attribution 3.0 United States License.