150 likes | 222 Views
Assignment 6 IK + Interpolation. Objective. Get key poses by IK Implement the Catmull -Rom algorithm to interpolate poses for in-between frames Display interpolated motions. Lamp Model. A 2D lamp character. 3. Part I: Inverse Kinematics. Fixed Constraints
E N D
Objective • Get key poses by IK • Implement the Catmull-Rom algorithm to interpolate poses for in-between frames • Display interpolated motions
Lamp Model A 2D lamp character 3
Part I: Inverse Kinematics • Fixed Constraints • Choose a point F on the arm and keep it the same as the current global position (fixX,fixY) . • Where is F located? • Calculate its position in the corresponding arm local coordinate • Moving Constraints • Choose a point M on the arm and drag it to (movX,movY) • Where is M located? • Calculate M’s position in the corresponding arm local coordinate
How to Calculate the position in local coordinate • Project P into its local Axes. P
One Click • What do we get from one click • A constraint position • A point located on the local coordinate of a bone • What we are going to do • Make the point’s position is the same as the constraint.
Inverse Kinematic Cost Function Minimize the difference between the solution and a reference pose Satisfy the constraints Distance between F and (fixX,fixY) + Distance between M and (movX,movY) Smoothness term
IK Environment Setup • IK environment setup • levmar : Levenberg-Marquardt nonlinear least squares algorithms in C/C++ • http://www.ics.forth.gr/~lourakis/levmar/ • Function: dlevmar_dif to implement IK Please check the link above for function usage
How it work • 1. intial configuration p; constraints: c1, c2; two corresponding points’ local coordinate. • 2. start from p • 3. Calculate those two points’ position based on p and their local coordinate. (we call it FK) • 4. cost evaluation, get cost E; • 5. update p by p = p+ T(E). • 6. if E is small enough, stop; else go back to 2.
How it work You should implement it in costEvaluation. • 1. intial configuration p; constraints: c1, c2; two corresponding points’ local coordinate. • 2. start from p • 3. Calculate those two points’ position based on p and their local coordinate. (we call it FK) • 4. cost evaluation, get cost E; • 5. update p by p = p+ T(E). • 6. if E is small enough, stop; else go back to 2.
Usage for 1 fixed and 1 moving • dlevmar_dif(costEvaluation,p,x,6,10,1000,0,0,0,0,0); • p[6]: six degrees of freedom • X[10]: measurements • 2 for one fixed constraint • 2 for moving constraint • 6 for smoothness • costEvaluation: do forward kinematic to get F and M based on the current p first, and evaluate the cost function.
Inverse Kinematic Cost Function Minimize the difference between the solution and a reference pose Satisfy the constraints Distance between F and (fixX,fixY) + Distance between M and (movX,movY) Smoothness term
X: Measurement • From the click, we get a point T and a constraint C1 • X[0] = Tx - C1x • X[1] = Ty - C1y
Part II (125 points) • You will implement it by yourself • Save key poses obtained by IK • Do Interpolation by Catmull-Rom • Display the interpolated motion