my adventure with inverse kinematics chris hecker definition six, inc. [email protected]

39
My Adventure with My Adventure with Inverse Kinematics Inverse Kinematics Chris Hecker Chris Hecker definition six, inc. definition six, inc. [email protected] [email protected]

Upload: jordan-rowe

Post on 26-Mar-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

My Adventure with My Adventure with Inverse KinematicsInverse Kinematics

Chris HeckerChris Heckerdefinition six, inc.definition six, [email protected]@d6.com

Page 2: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

What is this lecture about?What is this lecture about?

• the path I took while solving a problem with inverse kinematics

• how I use math to model and [sometimes] solve problems

• decisions I made, both good and bad

• learn from my successes and failures

• work in progress!

Page 3: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

What isn’t this lecture about?What isn’t this lecture about?

• not an IK tutorial or introduction

• not going to give you the One True Way to do IK

• has nothing to do with graphics

• not about my rock climbing game• Experimental Gameplay Workshop

Friday, 4pm - 7pm

Page 4: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

TakeawayTakeaway

• You 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.

Page 5: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

PrerequisitesPrerequisites

• must be very comfortable with math– doesn’t mean you know tons of math– does mean you follow quickly and aren’t afraid

of it

• probably best if you’ve implemented a simple IK system– foot placement, arm grabbing door, etc.

Page 6: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Talk StructureTalk Structure(linear with occasional branches)(linear with occasional branches)

• ...

• attempted solution

• problem statement and discussion

• related theory

• attempted solution

• problem statement and discussion

• related theory

• ...

Page 7: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: How to move a guy Problem: How to move a guy with the mouse?with the mouse?

• move like a [rock climbing] human

• interactive

• direct body/limb control

• did not want to use physics

Page 8: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Theory: How to move a guy with Theory: How to move a guy with the mouse? the mouse?

• inverse kinematics vs. forward kinematics– FK: p=f(q)– IK: q = f-1(p)– p is Euclidean, angles– q is configuration space

p

p = (x, y)q = ()

g

Page 9: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Theory: How to move a guy with the Theory: How to move a guy with the mouse?mouse? (cont.)(cont.)

• degrees of freedom (DOF)• incredibly important concept

• “ways in which system can change”• configuration space

• find DOF of system to understand it• control & constrain DOF to control it• examples

• physical system, polynomial, etc.

• fundamental task of IK is to control degrees of freedom to attain goal

p

p = (x, y)q = ()

Page 10: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Solution: How to move a guy Solution: How to move a guy with the mouse?with the mouse?

• analytical IK

• invert p = f(q) to get q from p

• relatively easy for the 2D arm– inverse trig, some vector algebra

• gets complicated as n increases

Page 11: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: Analytical IK can’t Problem: Analytical IK can’t handle human.handle human.

• human has lots of DOF– even 2D arm with shoulder

has more DOF than neededto reach goal

• solving p = f(q) requirescertain characteristics

p

p = (x, y)q = ()

g

Page 12: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Theory: Analytical IK can’t Theory: Analytical IK can’t handle human.handle human.

• p = f(q) is a set of nonlinear equations– generally no closed forms

– must iterate numerically

• must be square, nDOF = ngoal

• over-, under-constrained system– “redundant manipulator”

– ex. human reaching for point and/or orientation

• vast literature on solving f(q) = p

p

p = (x, y)q = ()

Page 13: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Solution: Analytical IK can’t Solution: Analytical IK can’t handle human. handle human.

• use Cyclic Coordinate Descent(CCD) to solve arms– iterative, recursive position-space

algorithm

– fast, easy, robust

– start from last position• not path independent, but faster

– I draw every outside iteration• looks like animation, but it’s not

p

p = (x, y)q = ()

g

Page 14: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: CCD only handles Problem: CCD only handles serial chains.serial chains.

• multiple goals are necessaryfor human– stack up vectors in

p=f(q)– coupled at branches

p1

p = (x1, y1, x2, y2)q = ()

p2

g1

g2

Page 15: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Theory: CCD only handles serial Theory: CCD only handles serial chains.chains.

• coupling between goals

• either solvable alone,neither solvable together

• how to distribute desired-angleerror?

p1

p = (x1, y1, x2, y2)q = ()

p2

g1

g2

Page 16: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Solution: CCD only handles Solution: CCD only handles serial chains.serial chains.

• simply average desired angles atbranch parents to attainmultiple goals and distributeerror– in example, imagine p1, p2

pulled in opposite directions

p1

p = (x1, y1, x2, y2)q = ()

p2

Page 17: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: Drift on multiple goals.Problem: Drift on multiple goals.

• average can’t satisfy all goals

• or even prioritize them

• I specifically want to drag climber hand with mouse and have other end effectors stay on holds

Page 18: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Theory: Drift on multiple goals.Theory: Drift on multiple goals.

• want a rigid constraint at end effectors

• closed loops are hard, CCD doesn’t handle them, nor do common IK algorithms– must solve simultaneously– not hierarchical anymore– closed loops don’t have

local behavior

Page 19: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Solution: Drift on multiple goals.Solution: Drift on multiple goals.

• attempt to “Gram-Schmidt” off any movement that would result in error

a

b c

Page 20: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: Gram-Schmidt removes Problem: Gram-Schmidt removes the wrong direction sometimes.the wrong direction sometimes.

• could have tried real Jacobian force mapping Gram-Schmidt

Page 21: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: Human is not rooted Problem: Human is not rooted tree.tree.

• Which end effector (hand, foot) is the root?

• There is no persistent fixed rootin a rock climber – or walking person

• CCD must start at a fixed root

Page 22: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Theory: Human is not rooted Theory: Human is not rooted tree.tree.

• switching root is basically a datastructure problem

• relative angles must change– joint limits (see below)

• behavior will change slightly as well,since CCD isn’t symmetric withrespect to the root

Page 23: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Solution: Human is not rooted Solution: Human is not rooted tree.tree.

• just type it in• invert tree to new root• Caml is pretty good at this

sort of thing– see last year’s GDC talk

• dragging torso is done by inverting to a torso node, then changing the root position– the hands and feet are all end-effectors– hack!

Page 24: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: Joint limitsProblem: Joint limits

• elbow can’t bend backwards

• should lend believability and intuition

Page 25: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Theory: Joint limitsTheory: Joint limits

• inequality constraints: min

– abandon all (most) hope of analytical solution– these inequalities are axis aligned planes in

configuration space

max

min

Page 26: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Solution: Joint limitsSolution: Joint limits

• CCD makes parent-child limits easy

• do min/max clamp in CCD inner iteration

• easy, and rest of system compensates

• issue: CCD doesn’t “know” about the joint limits– often compensates, but doesn’t know to avoid

them

Page 27: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: Child-child limitsProblem: Child-child limits

• parent-child not enough with moving root

• pelvis example:– left foot root– right foot root– chest root

Page 28: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: Child-child limitsProblem: Child-child limits

• parent-child not enough with moving root

• pelvis example:– left foot root– right foot root– chest root

Page 29: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Problem: Child-child limitsProblem: Child-child limits

• parent-child not enough with moving root

• pelvis example:– left foot root– right foot root– chest root

?

Page 30: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Theory: Child-child limitsTheory: Child-child limits

• both angles are dependent on each other, coupled– parent is fixed in CCD– constraints are now non-axis

aligned planes in C-space

• simultaneous solution necessaryat branches with child-childlimits

Page 31: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Solution: Child-child limitsSolution: Child-child limits• Good solution should:

– satisfy constraints always– have zero error in goals if possible– have least squares error if not possible

• Nonlinear Least Squares with Linear Inequalities:minimize (1 - d1)2 + (2 - d2)2

w.r.t. min12 1 - 2 max12

– lots of literature on NLSLI– I convert to LCP and use Lemke’s algorithm– works great!

Page 32: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

AccomplishmentsAccomplishments

• We extended CCD to handle:– multiple end effector goals– dynamically changing root node– arbitrary joint limits

Page 33: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

ProblemsProblems

• drift on multi-goals is still a problem

• CCD doesn’t know about joint limits

• sometimes non-physical movement– CCD isn’t doing physics, not conserving

energy, or anything else for that matter

• rooted hierarchies are inconvenient

• how to control redundant DOF?

Page 34: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Body Knowledge SystemBody Knowledge System

• system to manage movement and keep it natural– “situation” & “reaction”– ex. joint limits handled in body knowledge

• huge rules system

• allocates redundant DOF– this is the key to natural movement!

Page 35: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

Body Knowledge System (cont.)Body Knowledge System (cont.)

• IK just a rough initial guess for body knowledge system; should be:– physically plausible

• no added energy, etc.

– easy to layer conflicting goals

– able to cope with over-constrained goals

• don’t know enough about this yet, but I think it will be more important than IK for good dynamic animation

Page 36: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

What I Didn’t Talk AboutWhat I Didn’t Talk About

• development process stuff– developing on lower dimensional subproblems– using visualizations to help debug math– Mathematica and Matlab for development and

debugging– running multiple techniques on top of each

other

• physics-based techniques I tried

Page 37: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

What I Didn’t TryWhat I Didn’t Try

• I should have done a weighted average based on error for multi-goals, duh.– even weighted average wouldn’t be rigid

• although could make weight very big...

• similar to a stiff system

• Wrong: “CCD must have fixed root”– now that I understand better,

this isn’t actualy true• the root’s position is just more DOF

• CCD probably wouldn’t deal with this very well?

Page 38: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

What I Didn’t Try (cont.)What I Didn’t Try (cont.)

• pseudo-inverse methods• give explicit control over redundant DOF

• data-based methods (model-based)• functions as lookup tables

• totally ad-hoc methods

Page 39: My Adventure with Inverse Kinematics Chris Hecker definition six, inc. checker@d6.com

ReferencesReferences

• two great theses:– Paolo Baerlocher– Chris Welman

• google & citeseer• GDC talks

– David Wu– Ken Perlin

• Jeff Lander’s articles & code• Experimental Gameplay Workshop