forward and inverse kinematics for arm skeletons with gimble lock controls in maya

20
Forward and Inverse Kinematics for Arm Skeletons with Gimble Lock Controls in Maya By Brian J. Immel This tutorial is only a guide to creating FK-IK arms. The ideas presented here are subject to customization for each character that you apply them to. This tutorial does not cover the Parenting Contraint which makes a lot of these steps unnecessary. Look for that tutorial in the near future. Click here to go straight to the Gimble Lock setup. Click here to explore another method to correct Gimble Lock using SDKs. FK-IK Arms: Joints Controls Constraints and SDKs Known Issues Gimble Lock Fix FK-IK Arm: Joints 1. Create four joints for the right arm (Figure 1). 2. Rename the top joint to armR1. Move down the chain and rename it to armR2. Move down one last time and rename this joint to armR3.

Upload: naniammu

Post on 30-May-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 1/20

Forward and Inverse Kinematics for Arm

Skeletons with Gimble Lock Controls in

MayaBy Brian J. Immel

This tutorial is only a guide to creating FK-IK arms. The ideas presented here are subject

to customization for each character that you apply them to. This tutorial does not cover 

the Parenting Contraint which makes a lot of these steps unnecessary. Look for that

tutorial in the near future.

Click here to go straight to the Gimble Lock setup.

Click here to explore another method to correct Gimble Lock using SDKs.

FK-IK Arms: Joints Controls Constraints and SDKs Known Issues Gimble Lock Fix 

FK-IK Arm: Joints

1. Create four joints for the right arm (Figure 1).

2. Rename the top joint to armR1. Move down the chain and rename it to armR2. Movedown one last time and rename this joint to armR3.

Page 2: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 2/20

3. Create three layers (Figure 2). Name and color each one as follows:

• Real_skel, yellow

• FK_skel, red

• IK_skel, blue

4. Assign armR1 skeleton to Real_skel layer and turn off that layer. With the ArmR1

skeleton still selected, duplicate and assign to FK_skel layer. Duplicate again and assign

it to the IK_skel layer. We're creating all these layers to help you later keep from gettingconfused about which skeleton you should be working with.

5. Select the FK_skel and rename all of the joints to armR_FK# (armR_FK1,

armR_FK2, armR_FK3). This skeleton will be used to drive the Forward Kinematics.

You can use whatever naming conventions you like but I prefer to name them as thefunction they will be serving (i.e. arm = arm joint, R = Right, FK = Forward Kinematics).

Turn this layer off when you are finished renaming all the joints.

Page 3: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 3/20

6. Select the IK_skel and rename all of the joints to armR_IK# (armR_IK1,

armR_IK2, armR_IK3) (Figure 3). This skeleton will be used to drive the Inverse

Kinematics. Please note: Figure 3 is just illustrating the naming conventions of theskeletons! The skeletons should all be sitting on top of each other, not spaced apart as in

the given figure.

7. Select the armR_IK2 joint and disable the X and Z rotations in the attribute editor.

Limit the Y rotation to a maximum of -2. This ensures that this skeleton is always bent.ArmR_IK2 will act as the elbow of the IK skeleton. Try bending this joint at this point to

see if it bends forward or not. If it doesn't, try limiting the Y rotation to a minimum of -2.

Setting the Y rotation limits is dependant on the construction of the skeleton (theorientation of each joint in the chain).

8. Select the armR_IK3 and limit rotation to only X. Turn off the IK_skel layer.

Limiting the rotation of this joint to only X will allow the arm to have a more natural

twisting motion between the lower arm and wrist and allow for the IK to work properly

later on in the tutorial.

9. Turn on the FK_skel layer and select the armR_FK2 joint and disable the X and Z

rotations. Limit the Y rotation to a maximum of -2. This joint will act as the elbow for the

FK arm.

10. Select armR_FK3 and limit rotation to only X. Hide the FK_skel layer. Limiting the

rotation of this joint to only X will allow the arm to have a more natural twisting motion

 between the lower arm and wrist.

11. Turn on the IK_skel layer and set up the IK on the armR_IK skeleton drawing the

IK handle from the top to the very end (Figure 4). Rename the ikHandle1 to armR_IK .

Top

Page 4: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 4/20

 

Controls

1. Create a circle, rotate Z 90 degrees and freeze transform. The freeze transformationwill prevent the circle from rotating the wrong way when we constrain it. Snap to the end

 joint of the armR_IK skeleton and point constrain the IK handle to the circle. Rename

the circle to Right_Arm_IK (Figure 5). Add the Right_Arm_IK to the IK_skel layer.Delete the history of the circle. Lock your Rotations, Scales and Visibility attributes in

the channel box. We won't need to use these attributes at all.

This circle will control the IK portion of the arm once this tutorial is complete. At this

 point, you should test to see if the constraint works. Select the circle and translate it.Rotating the circle won't do anything because we didn't put an orient constrain on it nor 

do we need to. If the ArmR_IK and armR_IK skeleton move and bend properly then

you're ready to go on the the next step. If it doesn't bend right, check your Y rotations onArmR_IK2. If the circle doesn't move the skeleton, make sure you select the circle first

then the IK handle (constraining has a master-slave relationship which is the opposite of 

the child-parent relationship).

2. Create a locator, snap it to the armR_IK2 joint and pull it back behind the joint byabout 2 maya units (translate Z -2). This will determine the elbow's direction and help

keep it aligned the wrist. Rename the locator to Right_arm_vector and add it to theIK_skel layer.

Page 5: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 5/20

3. Select Right_arm_vector locator and then the armR_IK handle and use constrain >

 pole vector (Figure 6). You can parent the Right_arm_vector to the Right_arm_IK if 

you like. It's not necessary to parent it but I prefer to because that way the vector isalways following the arm.

• At this point you should test to make sure you set up the pole vector correctly.

Select the Right_arm_IK and move it in a little bit to give the arm a slight bend.

The select the Right_arm_vector and translate it up and down. If the elboworients towards the locator, then everything is working properly. Remember to

undo all you movements before you continue on.

4. Select the armR_IK handle, turn off visibility and lock all the attributes from visibility

and up. We don't need to animate these attributes because the skeleton is being driven bythe Right_arm_IK circle.

5. Translate the armR_IK skeleton away from the armR skeleton's original position.

6. Turn on the FK_skel layer and rotate it so it to is away from the armR skeleton

(Figure 7).

7. Binding will take place on the armR skeleton but you don't to bind it until later if you

like. Its better to bind later than now so you don't get visually confused with your arm

geometry in the way.

Page 6: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 6/20

Top

 

Constraints and SDKs

1. With all the layers visible, select armR_IK1 first, Shift-select armR_FK1 (second)

and finally armR1(third) then Constrain > Orient (Figure 8).

2. Select armR_IK2, shift-select armR_FK2 and finally armR2 then Constrain >Orient. Now the armR skeleton is trying to orient between the IK and FK skeletons

(Figure 9).

Page 7: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 7/20

From here, you can translate the Right_arm_IK circle or any joint in the FK skeleton to

see if the armR skeleton is orienting properly. The armR skeleton should always try to

stay directly in the middle of the two skeletons because the orient constraint weights arecurrently equal (each has the value of 1). Shift the orient constrain weight of armR1 and

armR 2 from 1, 1 to 1, 0 or 0, 1 to see how each joint shifts its weight. Before you move

on the next step, turn the weight values back to the their original settings (1, 1).

3. Next we need to create a control that influences which way the armR skeleton is going

to orient. You can use either the Right_arm_IK circle or your character's move node.

For simplicity reasons, I used the Right_arm_IK circle in this tutorial. Create anattribute using Modify > Add attribute > option box. Name the attribute R_arm_IK_FK .

The minimum value is 0, maximum is 10 and default is 0 (Figure 10). Hit ok.

4. Open up the Set Driven Key window and load the attribute we just created in step 21

as the driver.

• From here, we are going to set up the R_arm_IK_FK attribute to handle the

switch between IK and FK smoothly.

Page 8: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 8/20

5. Select the armR1 joint in the perspective window, open the hypergraph and hit the f 

key to focus on the skeleton's hierarchy. Select the armR1_orientConstraint1 and the

armR1_orientConstraint1 nodes and load as them as the driven in the Set Driven Key

window (Figure 11). Make sure that the value for R_Arm_IK_FK is 0 in the channel box.

Page 9: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 9/20

Page 10: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 10/20

6. Select the armR1_orientConstraint1 in the Set Driven Key window and highlight

armR_IK1W0 and armR_FK1W1. Change the Arm R_FK1 W1 value to zero in thechannel box. Key it. Select the armR2_orientConstraint1 in the Set Driven Key windowand highlight armR_IK2W0 and armR_FK2W1. Change the Arm R_FK2 W1 value to

zero in the channel box. Key it (Figure 12). This influences the arm to act as an IK 

skeleton.

To read what those long objects are (armR_IK1W0 and armR_FK1W1):armR_IK1W0 is the right arm IK Weight number 0. armR_FK1W1 is the right arm FK 

Weight number 1. These are part of values that handle the switching between IK and FK 

on armR1 joint.

7. Select the R_arm_IK_FK attribute and change the value to 10 in the channel box.Select the armR1_orientConstraint1 and highlight the armR_IK1W0 and

armR_FK1W1 in the Set Driven Key window. Switch the Arm R_FK1 W1 value 1 and

the Arm R_IK1 W0 value to 0 in the channel box and key it. Select thearmR2_orientConstraint1 and highlight the armR_IK2W0 and armR_FK2W1 in the

Set Driven Key window. Switch the Arm R_FK2 W1 value to 1 and the Arm R_IK W0

value to 0 in the channel box and key it.

Page 11: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 11/20

At this point, you can switch between FK and IK skeletons. Go ahead and play with

switch between the kinematic modes and move each skeleton. Note how when one

skeleton it turned off, it doesn't affect the armR skeleton at all. When animating, unlessyou character's right arm is stuck to something, you'll be using the FK skeleton to do the

majority of your keyframing.

8. If you like, you can move your display handles up so they don't sit inside the geometry.

Select the armR_FK1 joint, open the attribute editor and go to Display option > displayhandle option = checked (Figure 14).

Page 12: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 12/20

Page 13: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 13/20

Repeat for armR_FK2. Hit f8 and right mouse click on the plus mark. Select the selection

handles and offset them to sit above the geometry (Figure 15).

Happy rigging!

Top

 

Known issues

• "My hand twists when I put it down in IK mode."

o This tutorial doesn't have a joint for the palm but if it did (which you

should have one for the hand anyway) create a IK from the wrist joint(armR_IK3) to the palm joint (which would be called armR_IK4 in this

tutorial)and parent it to the arm IK. This will correct the twisting hand.

If your IK does work properly, it may be due to the orientation of the axis of theindividual joints. You need to make sure all the joints are facing the same

direction (Y points to Y of the next joint, X points X of the next joint or Z points

to Z of the next joint). See Figure 16 for what a good and bad joint orientation

should look like.

Page 14: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 14/20

• After you've orient constrained the skeletons and tried testing the constraint

motion after step 20 using the transform tool to move it, it won't work. Use therotation tool on the FK or IK joints to see the armR joints move accordingly.

• "Why do I have to do IK/FK arms this way? It seems awfully complicated"

o It has been argued that you don't need to use this whole setup to create

IK/FK arms but anybody with experience with this sort of setup knowsthat without the type of constructed skeleton system, the IK  jumps back 

and forth from the FK when you switch you kinematic modes.

• This setup has issues with using joint ArmR1 as a gimble control. Please note,gimble lock happens outside of this arm rig and is a common problem to deal with

on any type of arm/shoulder setup. Gimble lock occurs when one rotation axis is

near or is overlapping another axis. The solution can be found in the next sectionGimble Lock Fix.

Top

 

Gimble Lock Fix

1. Add another joint next to ArmR1 and name it armR_Gimble (Figure 17).

Page 15: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 15/20

2. In the hypergraph, middle mouse the armR_IK1, armR1 and armR_FK1 joints under 

the armR_Gimble (Figure 18) so that your hierarchy looks something like Figure 19.

3. Create a locator, move it above the armR_Gimble joint and call it gimbleR .

4. Move the pivot of gimbleR locator to armR_Gimble joint.

Page 16: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 16/20

5. Select the armR_Gimble joint and lock all attributes except for Rotate X and RotateY. Hide the locked attributes using the Channel Control (Windows > General Editos >

Channel Control). See Figure 20. We will use this Locator to drive selected rotations of 

the armR_Gible_group and armR_Gimble joint.

6. Group the armR_Gimble joint and name it armR_Gible_group. Center thearmR_Gible_group's pivot to the armR_Gimble joint. The reason we are grouping this

 joint is to create another rotation node. We'll use two rotation nodes to create an accurate

rotating shoulder joint.

7. Lock and hide all attributes expect for Rotate Z of the armR_Gible_group.

Page 17: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 17/20

8. On the gimbleR locator, lock and hide all attributes except for the Rotations (Figure

21).

9. Open up the Connection Editor (Window > General Editors > Connection Editor),select the gimbleR locator and hit the Load Left button (outputs) with this selection.

10. Select the armR_Gible_group and hit the Load Right button (inputs) at the top of 

the window of the Connection Editor (Figure 22).

11. Scroll down on the left side (gimbleR ) until you find the Rotate attribute and click 

on the triangle next to it. Do the same for the right side (armR_Gible_group).

Page 18: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 18/20

12. Click on the left side and right side's Rotate Z (Figure 23). Both attributes should be

italized now meaning that the value of armR_Gible_group Rotate Z is equal that of gimbleR Rotate Z. Example: if gimbleR Rotate Z equals 45, then armR_Gible_group

Rotate Z will equal 45.

13. Highlight Rotate X of gimbleR and link that output to the input of armR_Gible_group Rotate X.

14. Select the armR_Gimble joint and hit the Reload Right button at the top of theConnection Editor . Scroll down on the right side until you find the Rotate attribute and

click the triangle next to it.

Page 19: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 19/20

15. Connect the Rotate Y of left side (gimbleR ) to the Rotate Y of the right side

(armR_Gible_group). Your connections should look like Figure 24.

16. Select the armR_Gimble joint and lock the remaining attributes. Do the same for the

armR_Gible_group. We don't want to key these attributes just the gimbleR locator will be used for keying. If all has gone well, then you shouldn't have anymore issues with

gimble lock.

Page 20: Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

8/14/2019 Forward and Inverse Kinematics for Arm Skeletons With Gimble Lock Controls in Maya

http://slidepdf.com/reader/full/forward-and-inverse-kinematics-for-arm-skeletons-with-gimble-lock-controls 20/20

Top

Special thanks to Greg, Andy, Karen and Erik for their input and suggestions. Any

comments or suggestions please email them to Brian Immel.