Character Animation Forward and Inverse Kinematics CSE 3541 Matt Boggus
Overview Concepts Defining forward and inverse kinematics Example calculations for forward kinematics Inverse kinematics algorithms Other topics Ragdoll physics Dynamics
Simplifies motion specification Hierarchical Modeling Parent-child relationship Simplifies motion specification Relative motion Constrains motion Reduces dimensionality
Modeling & animating hierarchies 3 aspects Linkages & Joints – the relationships Data structure – how to represent such a hierarchy Converting local coordinate frames into global space
Terms Joint – allowed relative motion & parameters Joint Limits – limit on valid joint angle values Link – object involved in relative motion Linkage – entire joint-link hierarchy End effector – most distant link in linkage Pose – configuration of linkage using given set of joint angles
Forward vs. Inverse Kinematics Forward Kinematics Input: joint angles Output: link positions and orientations end effector position Inverse Kinematics Input: end effector Output: joint angles
Joints – relative movement Every joint allowing motion in one dimension is said to have one degree of freedom (DOF) Example: flying (Six DOF) x, y, and z positions (prismatic or translation) roll, pitch, and yaw (revolute or rotation)
Hierarchical structure
Forward Kinematics: A Simple Example Forward kinematics map as a coordinate transformation The body local coordinate system of the end-effector was initially coincide with the global coordinate system Forward kinematics map transforms the position and orientation of the end-effector according to joint angles Example from Jehee Lee
A Chain of Transformations
Thinking of Transformations In a view of global coordinate system
Thinking of Transformations In a view of global coordinate system
Thinking of Transformations In a view of global coordinate system
Thinking of Transformations In a view of global coordinate system
Thinking of Transformations In a view of global coordinate system
Thinking of Transformations In a view of body-attached coordinate system
Thinking of Transformations In a view of body-attached coordinate system
Thinking of Transformations In a view of body-attached coordinate system
Thinking of Transformations In a view of body-attached coordinate system
Thinking of Transformations In a view of body-attached coordinate system
Real-time forward kinematics QWOP http://www.foddy.net/Athletics.html
Inverse kinematics Given goal position for end effector Compute internal joint angles Simple linkages analytic solution Otherwise numeric iterative solution
IK solution uniqueness Zero One Two Many Images from http://freespace.virgin.net/hugo.elias/models/m_ik.htm
Inverse kinematics – spaces Configuration space Reachable workspace
Analytic Inverse Kinematics Given target position (X,Y) Compute angle with respect to origin of linkage Solve for angle of rotation for each joint See reference text for solution and derivation
IK - numeric Solve iteratively – numerically solve for step toward goal Remember: a pose is the position and orientation of all links for given a set of joint angles - Compute the desired change from this pose Vector to the goal, or Minimal distance between end effector and goal - Compute set of changes to joint angles to make that change
Inverse Kinematics - Numeric Given Current configuration Goal position Determine Goal vector Positions & local coordinate systems of interior joints (in global coordinates) Solve for change in joint angles & take small step, optionally clamp acceleration or clamp velocity Repeat until: Within epsilon of goal Stuck in some configuration Taking too long
Given the values for each xi, we can compute each yi IK math notation Given the values for each xi, we can compute each yi
IK – chain rule The change in output variables (y) relative to the change in input variables (x)
Inverse Kinematics - Jacobian Desired motion of end effector Unknown change in articulation variables The Jacobian is the matrix relating the two: describing how each coordinate changes with respect to each joint angle in our system
Inverse Kinematics - Jacobian Change in position Change in orientation Change in articulation variables Jacobian
If J is not square, use of pseudo-inverse of Jacobian Solving If J square, compute inverse, J-1 If J is not square, use of pseudo-inverse of Jacobian
Another example linkage
IK – compute positional change vectors induced by changes in joint angles Instantaneous positional change vectors Desired change vector One approach to IK computes linear combination of change vectors that equal desired vector
Jacobian psuedocode while ( Distance(endEffector,goal) > threshold && time < timeLimit) { vel = goal – endEffector; j = ComputeJacobian(linkage); pj = ComputePseudoinverse(j); deltaTheta = pj * vel; rotateJoints(deltaTheta,linkage); } In addition to the reference text, should you want to implement this I also recommend http://web.eecs.umich.edu/~ocj/courses/autorob/autorob_11_ik_jacobian.pdf
IK - singularity Some singular configurations are not so easily recognizable
IK – cyclic coordinate descent Heuristic solution Consider one joint at a time, from outside in At each joint, choose update that best gets end effector to goal position In 2D – pretty simple Goal axisi Ji EndEffector
Cyclic-Coordinate Descent - Starting with the root of our effector, R, to our current endpoint, E. - Next, we draw a vector from R to our desired endpoint, D - The inverse cosine of the dot product gives us the angle between the vectors: cos(a) = RD ● RE
Cyclic-Coordinate Descent Rotate our link so that RE falls on RD
Cyclic-Coordinate Descent Move one link up the chain, and repeat the process
Cyclic-Coordinate Descent The process is basically repeated until the root joint is reached. Then the process begins all over again starting with the end effector, and will continue until we are close enough to D for an acceptable solution.
Cyclic-Coordinate Descent
Cyclic-Coordinate Descent We’ve reached the root. Repeat the process
Cyclic-Coordinate Descent
Cyclic-Coordinate Descent
Cyclic-Coordinate Descent
Cyclic-Coordinate Descent
Cyclic-Coordinate Descent
Cyclic-Coordinate Descent We’ve reached the root again. Repeat the process until solution reached.
IK – cyclic coordinate descent Other orderings of processing joints are possible Because of its procedural nature Lends itself to enforcing joint limits Easy to clamp angular velocity
Dynamics – Featherstone equations
Dynamics – Featherstone equations Forces + linkage constraints For the details of the equations, see http://web.cse.ohio-state.edu/~parent.1/classes/683/Lectures/chapter07featherstone.ppt
Approximating dynamics Archived reference of 2003 Gamasutra article: http://graphics.cs.cmu.edu/nsp/course/15-869/2006/papers/jakobsen.htm Archived IO interactive slides: http://www-scf.usc.edu/~gamedev/assets/AdvancedPhysics.ppt Human particle/stick model Video example Not shown (points can be matched/rigged to 3D character model)
Stick position constraint solving Figure and code from reference in previous slide
Stick angle constraint solving Figure and code from reference in previous slide (x2 – x1) ∙ (x2 – x1) > d -OR- (x2 – x0) ∙ (x1 – x0) < a Where a and d are constants, representing limits
Additional slides
Derivation for analytical IK example
Complex Joints
IK – 3D cyclic coordinate descent EndEffector Goal Ji axisi Projected goal First – goal has to be projected onto plane defined by axis (normal to plane) and EF Second– determine angle at joint