The goal of this lab is to
This assignment has been added to your AnimationFramework repository. To get the source, run
> cd cs56/AnimationToolkit > git pull > cd build > cmake .. > make
You should now have a new directory under assignments called a9-ik.
In this question, you will work through the calculations needed to perform IK for a two-link chain on paper. Include your answers in your readme for this week. Remember that you can use python, octave, matlab, maple, our basecode or any other method to check your answers!
Suppose we have a 2-link chain as in class.
The root joint p1 is located at the origin.
The next joint p2 is offset from p1 by (2,0,0)T
The next joint p3 is offset from p2 by (5,0,0)T
Solve using the analytic two-link method (Reference: here)
Using polar coordinates to compute the orientation of joint 1:
Using angle/axis to compute the orientation of joint 1:
In this question, you will implement the analytic IK algorithm from class. Put your work in
libsrc/animation/AIKController-basecode.cpp inside the method solveIKTwoLink.
// ASkeleton will contain a two-link chain // Assume joint 0 is the root // Assume joint 1 is the middle joint // Assume joint 2 is the end effector // If your implementation is correct, the end effector should be positioned at goalPos bool AIKController::solveIKTwoLink(ASkeleton& skeleton, const AVector3& goalPos)
To run the demo from the build directory, type
build> ../bin/a9-iksimple
Implementation tips:
The basecode includes a simple interface and 3D viewer. See above for a demo.
The camera can be controled with the mouse:
The player control panel on the top left can be used to play/pause, step through keys, and see the simulation time.
The panel at the bottom left can be used to set the goal position of the end effector.
The target position can also be moved with the mouse by holding down the Ctrl key.
In this question, you will use the CCD's angle/axis computation (with nudge factor of 1) to make a character's gaze follow a target. Implement your solution in assignments/a9-ik/ALooker.cpp
Your approach should align the forward direction of the head with the
target. The forward direction of the head is the Z axis (0,0,1) in its local
coordinates.
To run the demo from the build directory, type
build> ../bin/a9-looker
In this question, you will implement the CCD algorithm for a full character. Implement you solution in IKController::solveIKCCD() located in libsrc/animation/AIKcontroller-basecode.cpp. Given the joint specified by jointid, make its position match goalPos. The chainsize indicates how many descendents to use for the CCD algorithm. When the function returns, skeleton's pose will have the end effector matching the goalPos (as close as feasible).
// solveIKCCD positions the joint given by jointid so its global position // is located at goalPos // // param skeleton: the character to modify // param jointid: the ID of the end effector // param goalPos: the target position for jointid (global pos) // param chainSize: the number of joints to "nudge" towards the goal. (e.g. the number of descendants to use) // param maxIters: the max number of iterations to try to reach the goal // // return true/false based on whether we could reach the goal // side effect: skeleton should by posed such that jointid is located at goalPos (or in this direction of // goalPos if the target is out of reach) bool AIKController::solveIKCCD(ASkeleton& skeleton, int jointid, const AVector3& goalPos, int chainSize, int maxIters) { // recompute the chain if the end effector or chain size changes if (_selectedJoint != jointid || chainSize != (int) _chain.size()) { computeJointChain(skeleton, jointid, chainSize); } // There are no joints in the IK chain for manipulation if (_chain.size() == 0) return true; // implement CCD algorithm here return false; }
To run the demo from the build directory, type
build> ../bin/a9-ik
The basecode comes with a viewer to help yo utest your algorithm.
The camera can be controled with the mouse:
The left frame lets you select joints, reset the pose, and set the goal position maunally.
The target position can also be moved with the mouse by holding down the Ctrl key.
The right panel lets you select the algorithm for IK along with IK paramaters. For CCD:
In this question, implement IKController::solveIKAnalytic() located in libsrc/animation/AIKcontroller-basecode.cpp. In this question, you will combine the techniques of the simple two-link analytic approach with CCD's angle/axis calculation. This work will allow us to animate the legs and arms of the character such that the knees and elbows bend along their natural axis.
// solveIKAnalytic: positions the joint given by jointid so its global position // is located at goalPos. This method computes rotations for the parent and grandparent // of jointid. // // param skeleton: the character to modify // param jointid: the ID of the end effector // param goalPos: the target position for jointid (global pos) // // return true/false based on whether we could reach the goal // side effect: skeleton should by posed such that jointid is located at goalPos (or in this direction of // goalPos if the target is out of reach) bool AIKController::solveIKAnalytic(ASkeleton& skeleton, int jointid, const AVector3& goalPos)
To run the demo from the build directory, type
build> ../bin/a9-ikSet the IK type to Analytic to test your work.
Implementation hints:
vec3 limbDir = parentJoint->getLocalTranslation(); limbDir.Normalize(); vec3 axis = limbDir.Cross(vec3(0,0,-1)); if (limbDir[1] < 0) axis = limbDir.Cross(vec3(0,0,1));
In this question, you will implement a procedural dancer using solveIKAnalytic (or solveIKCCD if you
did not finish the previous question). Implement your solution in assignments/a9-ik/ADancer.cpp.
Your solution will modify the motion in idle.bvh to make the hands and hips move differently.
To run the demo from the build directory, type
build> ../bin/a9-dancer
Demo requirements
Suggested approach
Option 1 Make you own unique animation based on inverse kinematics, splines, and motions. For example, make a new dance, have the character hold a cup, or wave. Try your procedural dance or look on an other motions.
Option 2 Procedural walker. Animate walking by using IK to move the feet (to move forward, you will need to move the root too). Experiment with unique characters, such as spiders and robots.
Be sure to include a video of your demo for full credit!