Sunday, 21 August 2011

Animating Robot Arm


Animating Robot Arm
This exercise was my first ever animation I’ve done in Maya, previously we used the pencil software to learn about key framing and timing of animation, hence this time in Maya I’ve learn to handle an IK system as well as understand the basis of how animation was to be done in Maya. In this post I would not state so much about my process as I find that redundant given how I followed the Maya online tutorial to do my robot arm, I would rather discuss my reflections and thoughts about any point that I had problem understanding or found immensely useful or important.
 Kinematics Systems


I’ve learn via this exercise that there are two kind of system one can use in Maya to animate our models, these are known as Inverse Kinematics and Forward Kinematics.
Inverse Kinematics (IK) handlers are points where animators control to handle the model they are animating, movement of joints are calculated by something known as the IK solver.
Due to this fact, IK handlers are normally used to pose characters that have skeletons, that is to say models that have joints such as a arm or a leg. To do this, we place the IK handlers at position of the joints, that is to say the places where the model’s skeleton will rotate when we animate them. (Example: Placing an IK handler at the shoulder of an arm)
Compared to Forward Kinematics (FK) which requires you to manually manipulate each joint of the model’s skeleton as well as manually control its movement until you have reached the desired pose for a key frame. This can be a tedious process especially when working with a complex skeleton.

IK Handler in Robot Arm

Picture showing only the IK handler
Orange color represents the robot arm skeleton

Skeletons & Hierarchy

Hierarchy also plays an important role in animation, based on how the joints are connected in the hierarchy table, hierarchy not only helps to make a more realistic animation but it also saves a lot of work for animators when working with a skeleton-like structure.
Hence skeletons are basically a system that connects the various joints of a model and arranges them into based on hierarchy.

Example:
When working with an arm, the hierarchy for its joints are arranged in the below order.
This means that when we animate the shoulder, the elbow and the wrist moves along, and if we animate the elbow only the wrist follows, and lastly the wrist movement doesn’t affect the elbow and the shoulder.
Since I’m a coder, I understand hierarchy aspect much better than most of the other aspects of animation, and thus I am able link the hierarchy to a programming stand point of view. In game programming, it is essential that we have code in a fashion known as object-oriented programming (OOP). This is to say that behaviours often exhibited by one of the game objects in our game are linked to a class where specific codes tells it how to behave, however to ensure that we do not repeat any codes (Imagine a shooter game where player is firing of a machine gun, it would make a lot more sense to write a class or function where all bullets has rather than creating a new function or class for each bullet fired).
With that said objects in programming can inherit one another as well so as to save even more time and processing power. Example of inheritance in OOP, an animal has a name and an attribute that states what type of animal it is (reptile/mammal/bird/etc). Hence I could make a lion class, now lion class inherits animal class, hence it has to have a name as well as the type. So when we want to check if the lion is a mammal, we have to manipulate the code such that it links back to the animal class to get the information that the lion is a mammal type class. Similar to Maya animation ideology of inheritance, if the parent which in the code case is the animal class and the Maya case which is the shoulder joint, manipulating the parent means that the any of its child classes/joints would be affected.

Hypergraph
I love this tool if only we could incorporate something like this into my programming software! Basically I understand that the hypergraph is meant to be used as a tool that shows the overview of every object in the scene and their relationship to one another. This way not only can we understand what to manipulate should we want a certain result but we can also easily select them from the hypergraph, example of a case where using the hypergraph would be useful is say when we are animating a tail of a dragon where there are many scales and bone involved, hence instead of doing trial and error to see which bone segment controls which segment of scales we could simply go straight to the hypergraph and see for ourselves, not only that we can select the segments we want to manipulate directly without having to pan and try to select it from perspective view or other views.


Hypergraph showing objects
Selected Swivelbase (yellow) indicates more object parented under it

List of objects parented under swivelbase / base of robot arm

 Create Skeleton Tool
The create skeleton tool is the basic tool for creating a skeleton to rig in Maya. The first click would be the parent joint which is to say that joint would control the subsequent joint clicked. Hence due to the functionality of this skeletons it is important that we as animators think about the structure of the model we are going to animate and how it would move and behave, and then plan out a skeleton system that would suffice the work we would do before rigging the model.

Parenting the skeleton hierarchy
This basically means we parent the model to its skeleton, since it makes sense that we do it this way instead of the other way round as even in real life the skeleton is being wrapped by the muscles and body structure and movement limits are determined by the skeletal structure. To parent the model to the skeleton it is important that the order of the selection is correct, we first select the model node and then shift select the joint / skeleton node we wish to parent it to.

Applying an IK System to the Skeleton Hierachy
We apply an IK system to our skeleton by using a tool known as the IK handle tool, this serves as a mean of letting us control the movement of our model based on it skeletal structure. To do so we click on the parent of the skeleton system (first skeleton node / the first click when we created the skeleton system), and the second click is on the last joint of the skeletal system (last skeleton node / the last click when we created the skeleton system). To test if the IK has been applied correctly we can click on it and test the movement to check if it is in accordance of what we were expecting when we planned the skeletal system and movement that it must perform.

Creating a control object
Basically we utilize a tool known as create locator to create a control object that will be used as a point to control the entire IK handler system as this is much easier than manipulating each joint individually. This is extremely important especially so when working with complex joint and skeletal systems.
Also it is important that we freeze transform for the control object, that way we can ensure that we can reset its position to where we initially place the control object by zeroing all its translation.

Constraining Object in an IK System
From what I understand, it is the modeller/rigging guy job to constrain the axis and position that the object can move before passing it to the animator, this is similar to what we do in game programming where the base code designer designs the function and base code before passing it to the scripter to finish, example base code designer comes up with a function called shoot, scripter then assign the script that has the function shoot to certain guards in the game that has the gun.
To constrain an object movement in Maya, there  are several ways to go about it, there are tools to constraint movement of an object to a certain point or constrain it to have the same movement as another object, for in which in our case, the robot arm is constraint to the control object. Also we can constraint the movement of certain objects in Maya via the attribute editor where we set the min & max value of how much an object can either translate, rotate and scale.

Parent Constrain
From what I understand in the tutorial, a parent constrain applied to an object can have multiple objects influencing it, in this tutorial there are two influence of other object on the cargo box which are firstly the robot arm and secondly the platform.
Parent constraints are used to ensure that one object follow the movement of another object so that when we animate, we need not animate both objects but rather just animate one object and adjust the constraint of the other object that we put the parent constraint on.
Also for parent constraint to work we must set a rest position for the object that we constraint, the rest position indicates where the object lies when it is not influenced by any of the other objects.

Utilizing parent constraints in an animation
Basically the object who has the utilize objects has it constraint value set to 1, so for example the robot arm is now moving the box at frame 10, so at frame 10 when the robot arm just touched the box, we set the arm control value on the box to 1, when it move to the platform at frame 20, we set the arm control value to 0 and the platform value to 1 on the box. When the box is not being moved or repositioned by the arm or platform we set the value both to 0 which is also the box rest position that we set when applying the parent constraint onto it.

No comments:

Post a Comment