kinematics for animation - inria · direct and inverse kinematics in animation ! fast numerical...

57
KINEMATICS FOR ANIMATION Rémi Ronfard, Animation, M2R MOSIG

Upload: vocong

Post on 29-Aug-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

KINEMATICS FOR ANIMATION Rémi Ronfard, Animation, M2R MOSIG

Page 2: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Direct and inverse kinematics in animation

¨  Fast numerical methods for inverse kinematics by Bill Baxter

¨  My Adventures with Inverse Kinematics by Chris Hecker

Page 3: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 4: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 5: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 6: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 7: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 8: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 9: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 10: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 11: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 12: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 13: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 14: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 15: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 16: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 17: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Fast numerical methods for inverse kinematics by Bill Baxter

Page 18: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction
Page 19: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction
Page 20: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

My Adventure with Inverse Kinematics

Chris Hecker definition six, inc. [email protected]

Page 21: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

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 22: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

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

Page 23: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Takeaway ¨  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 24: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Prerequisites ¨  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 25: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Talk Structure (linear with occasional branches) ¨  ... ¨  attempted solution ¨  problem statement and discussion ¨  related theory ¨  attempted solution ¨  problem statement and discussion ¨  related theory ¨  ...

Page 26: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problem: How to move a guy with the mouse?

¨  move like a [rock climbing] human ¨  interactive ¨  direct body/limb control ¨  did not want to use physics

Page 27: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Theory: How to move a guy with 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

θ2

θ1

p = (x, y) q = (θ1, θ2)

g

Page 28: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Theory: How to move a guy with the mouse? (cont.) ¨  degrees of freedom (DOF)

n  incredibly important concept

¨  “ways in which system can change” n  configuration space

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

n  physical system, polynomial, etc.

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

p

θ2

θ1

p = (x, y) q = (θ1, θ2)

Page 29: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Solution: How to move a guy 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 30: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problem: Analytical IK can’t handle human.

¨  human has lots of DOF ¤ even 2D arm with shoulder

has more DOF than needed to reach goal

¨  solving p = f(q) requires certain characteristics

p

θ2

θ1

θ3

p = (x, y) q = (θ1 , θ2 , θ3)

g

Page 31: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Theory: Analytical IK can’t 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

θ2

θ1

θ3

p = (x, y) q = (θ1 , θ2 , θ3)

Page 32: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Solution: Analytical IK can’t handle human. ¨  use Cyclic Coordinate Descent

(CCD) to solve arms ¤  iterative, recursive position-space

algorithm ¤  fast, easy, robust ¤  start from last position

n  not path independent, but faster ¤  I draw every outside iteration

n  looks like animation, but it’s not

p

θ2

θ1

θ3

p = (x, y) q = (θ1 , θ2 , θ3)

g

Page 33: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problem: CCD only handles serial chains.

¨  multiple goals are necessary for human ¤  stack up vectors in

p=f(q) ¤ coupled at branches

p1

θ2

θ1

θ3

p = (x1, y1, x2, y2) q = (θ1 , θ2 , θ3 , θ4 , θ5)

θ4

θ5

p2

g1 g2

Page 34: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Theory: CCD only handles serial chains.

¨  coupling between goals ¨  either solvable alone,

neither solvable together ¨  how to distribute desired-angle

error?

p1

θ2

θ1

θ3

p = (x1, y1, x2, y2) q = (θ1 , θ2 , θ3 , θ4 , θ5)

θ4

θ5

p2

g1 g2

Page 35: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Solution: CCD only handles serial chains.

¨  simply average desired angles at branch parents to attain multiple goals and distribute error ¤  θ1 in example, imagine p1, p2

pulled in opposite directions

p1

θ2

θ1

θ3

p = (x1, y1, x2, y2) q = (θ1 , θ2 , θ3 , θ4 , θ5)

θ4

θ5

p2

Page 36: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

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 37: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

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 38: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Solution: Drift on multiple goals. ¨  attempt to “Gram-Schmidt” off any movement that

would result in error

a

b c

Page 39: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problem: Gram-Schmidt removes the wrong direction sometimes.

¨  could have tried real Jacobian force mapping Gram-Schmidt

Page 40: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problem: Human is not rooted tree. ¨  Which end effector (hand, foot) is the root? ¨  There is no persistent fixed root

in a rock climber ¤ or walking person

¨  CCD must start at a fixed root

Page 41: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Theory: Human is not rooted 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 with respect to the root

Page 42: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Solution: Human is not rooted 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 43: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problem: Joint limits ¨  elbow can’t bend backwards ¨  should lend believability and intuition

Page 44: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Theory: Joint limits ¨  inequality constraints: θ ≥ θmin

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

configuration space

θmax

θmin

θ

Page 45: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Solution: 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 46: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problem: Child-child limits ¨  parent-child not enough with moving root ¨  pelvis example:

¤  left foot root ¤  right foot root ¤ chest root

Page 47: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problem: Child-child limits ¨  parent-child not enough with moving root ¨  pelvis example:

¤  left foot root ¤  right foot root ¤ chest root

Page 48: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problem: Child-child limits ¨  parent-child not enough with moving root ¨  pelvis example:

¤  left foot root ¤  right foot root ¤ chest root

?

Page 49: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Theory: 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 necessary

at branches with child-child limits

Page 50: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Solution: 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 51: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Accomplishments ¨  We extended CCD to handle:

¤ multiple end effector goals ¤ dynamically changing root node ¤ arbitrary joint limits

Page 52: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Problems ¨  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 53: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Body 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 54: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

Body Knowledge System (cont.) ¨  IK just a rough initial guess for body knowledge system;

should be: ¤  physically plausible

n  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 55: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

What 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 56: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

What 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

n  although could make weight very big... n  similar to a stiff system

¨  Wrong: “CCD must have fixed root” ¤  now that I understand better,

this isn’t actualy true n  the root’s position is just more DOF n  CCD probably wouldn’t deal with this very well?

Page 57: KINEMATICS FOR ANIMATION - Inria · Direct and inverse kinematics in animation ! Fast numerical methods for inverse kinematics by Bill Baxter ! ... not an IK tutorial or introduction

What I Didn’t Try (cont.) ¨  pseudo-inverse methods

n give explicit control over redundant DOF

¨  data-based methods (model-based) n  functions as lookup tables

¨  totally ad-hoc methods