Presentation on theme: "My Adventure with Inverse Kinematics"— Presentation transcript:
1My Adventure with Inverse Kinematics Chris Heckerdefinition six, inc.
2What is this lecture about? the path I took while solving a problem with inverse kinematicshow I use math to model and [sometimes] solve problemsdecisions I made, both good and badlearn from my successes and failureswork in progress!
3What isn’t this lecture about? not an IK tutorial or introductionnot going to give you the One True Way to do IKhas nothing to do with graphicsnot about my rock climbing gameExperimental Gameplay Workshop Friday, 4pm - 7pm
4TakeawayYou will get insight into how IK on a whole human body is different from IK on a single arm.You will see how IK is a building block, but not a complete solution to character animation.
5Prerequisites must be very comfortable with math doesn’t mean you know tons of mathdoes mean you follow quickly and aren’t afraid of itprobably best if you’ve implemented a simple IK systemfoot placement, arm grabbing door, etc.
6Talk Structure (linear with occasional branches) ...attempted solutionproblem statement and discussionrelated theory
7Problem: How to move a guy with the mouse? move like a [rock climbing] humaninteractivedirect body/limb controldid not want to use physics
8Theory: How to move a guy with the mouse? inverse kinematics vs. forward kinematicsFK: p=f(q)IK: q = f-1(p)p is Euclidean, anglesq is configuration spacepgp = (x, y)q = (q1, q2)q2q1
9Theory: How to move a guy with the mouse? (cont.) pq2q1degrees of freedom (DOF)incredibly important concept“ways in which system can change”configuration spacefind DOF of system to understand itcontrol & constrain DOF to control itexamplesphysical system, polynomial, etc.fundamental task of IK is to control degrees of freedom to attain goalp = (x, y)q = (q1, q2)
10Solution: How to move a guy with the mouse? analytical IKinvert p = f(q) to get q from prelatively easy for the 2D arminverse trig, some vector algebragets complicated as n increases
11Problem: Analytical IK can’t handle human. human has lots of DOFeven 2D arm with shoulder has more DOF than needed to reach goalsolving p = f(q) requires certain characteristicsq3gq2q1p = (x, y)q = (q1 , q2 , q3)
12Theory: Analytical IK can’t handle human. pp = f(q) is a set of nonlinear equationsgenerally no closed formsmust iterate numericallymust be square, nDOF = ngoalover-, under-constrained system“redundant manipulator”ex. human reaching for point and/or orientationvast literature on solving f(q) = pq3q2q1p = (x, y)q = (q1 , q2 , q3)
13Solution: Analytical IK can’t handle human. puse Cyclic Coordinate Descent (CCD) to solve armsiterative, recursive position-space algorithmfast, easy, robuststart from last positionnot path independent, but fasterI draw every outside iterationlooks like animation, but it’s notq3gq2q1p = (x, y)q = (q1 , q2 , q3)
14Problem: CCD only handles serial chains. multiple goals are necessary for humanstack up vectors in p=f(q)coupled at branchesg2q3g1q5q4q2q1p = (x1, y1, x2, y2)q = (q1 , q2 , q3 , q4 , q5)
15Theory: CCD only handles serial chains. p2p1coupling between goalseither solvable alone, neither solvable togetherhow to distribute desired-angle error?g2q3g1q5q4q2q1p = (x1, y1, x2, y2)q = (q1 , q2 , q3 , q4 , q5)
16Solution: CCD only handles serial chains. p2p1simply average desired angles at branch parents to attain multiple goals and distribute errorq1 in example, imagine p1, p2 pulled in opposite directionsq3q5q4q2q1p = (x1, y1, x2, y2)q = (q1 , q2 , q3 , q4 , q5)
17Problem: Drift on multiple goals. average can’t satisfy all goalsor even prioritize themI specifically want to drag climber hand with mouse and have other end effectors stay on holdsq
18Theory: Drift on multiple goals. want a rigid constraint at end effectorsclosed loops are hard, CCD doesn’t handle them, nor do common IK algorithmsmust solve simultaneouslynot hierarchical anymoreclosed loops don’t have local behaviorq
19Solution: Drift on multiple goals. attempt to “Gram-Schmidt” off any movement that would result in errorbca
20Problem: Gram-Schmidt removes the wrong direction sometimes. could have tried real Jacobian force mapping Gram-Schmidt
21Problem: Human is not rooted tree. Which end effector (hand, foot) is the root?There is no persistent fixed root in a rock climberor walking personCCD must start at a fixed root
22Theory: Human is not rooted tree. switching root is basically a datastructure problemrelative angles must changejoint limits (see below)behavior will change slightly as well, since CCD isn’t symmetric with respect to the root
23Solution: Human is not rooted tree. just type it ininvert tree to new rootCaml is pretty good at this sort of thingsee last year’s GDC talkdragging torso is done by inverting to a torso node, then changing the root positionthe hands and feet are all end-effectorshack!
24Problem: Joint limits elbow can’t bend backwards should lend believability and intuition
25Theory: Joint limits inequality constraints: q ³ qmin abandon all (most) hope of analytical solutionthese inequalities are axis aligned planes in configuration spaceqmaxqqmin
26Solution: Joint limits CCD makes parent-child limits easydo min/max clamp in CCD inner iterationeasy, and rest of system compensatesissue: CCD doesn’t “know” about the joint limitsoften compensates, but doesn’t know to avoid them
27Problem: Child-child limits parent-child not enough with moving rootpelvis example:left foot rootright foot rootchest root
28Problem: Child-child limits parent-child not enough with moving rootpelvis example:left foot rootright foot rootchest root
29Problem: Child-child limits parent-child not enough with moving rootpelvis example:left foot rootright foot rootchest root?
30Theory: Child-child limits both angles are dependent on each other, coupledparent is fixed in CCDconstraints are now non-axis aligned planes in C-spacesimultaneous solution necessary at branches with child-child limits
31Solution: Child-child limits Good solution should:satisfy constraints alwayshave zero error in goals if possiblehave least squares error if not possibleNonlinear Least Squares with Linear Inequalities: minimize (q1 - d1)2 + (q2 - d2)2 w.r.t. qmin12 £ q1 - q2 £ qmax12lots of literature on NLSLII convert to LCP and use Lemke’s algorithmworks great!
32Accomplishments We extended CCD to handle: multiple end effector goals dynamically changing root nodearbitrary joint limits
33Problems drift on multi-goals is still a problem CCD doesn’t know about joint limitssometimes non-physical movementCCD isn’t doing physics, not conserving energy, or anything else for that matterrooted hierarchies are inconvenienthow to control redundant DOF?
34Body Knowledge System system to manage movement and keep it natural “situation” & “reaction”ex. joint limits handled in body knowledgehuge rules systemallocates redundant DOFthis is the key to natural movement!
35Body Knowledge System (cont.) IK just a rough initial guess for body knowledge system; should be:physically plausibleno added energy, etc.easy to layer conflicting goalsable to cope with over-constrained goalsdon’t know enough about this yet, but I think it will be more important than IK for good dynamic animation
36What I Didn’t Talk About development process stuffdeveloping on lower dimensional subproblemsusing visualizations to help debug mathMathematica and Matlab for development and debuggingrunning multiple techniques on top of each otherphysics-based techniques I tried
37What I Didn’t TryI should have done a weighted average based on error for multi-goals, duh.even weighted average wouldn’t be rigidalthough could make weight very big...similar to a stiff systemWrong: “CCD must have fixed root”now that I understand better, this isn’t actualy truethe root’s position is just more DOFCCD probably wouldn’t deal with this very well?
38What I Didn’t Try (cont.) pseudo-inverse methodsgive explicit control over redundant DOFdata-based methods (model-based)functions as lookup tablestotally ad-hoc methods
39References two great theses: google & citeseer GDC talks Paolo BaerlocherChris Welmangoogle & citeseerGDC talksDavid WuKen PerlinJeff Lander’s articles & codeExperimental Gameplay Workshop