Transcript PowerPoint

Spacetime Constraints
Andrew Witkin
Michael Kass
Early Computer Animations
Pixar’s Luxo, Jr. 1986
Can we generate those motions automatically?
Some Context
• What have we learned about animation?
– Forward simulation is possible
• Assignment 1 and Timewarp paper
– Constraints can be met
• Inverse Kinematics
• Monte Carlo
– Sampling Plausible Solutions…
• Constrained optimization
– Through the Lens
Forward Simulation
• Given initial state and equations defining
changes in state…
– Integrate (simulate)
• Rigid body simulations, collisions,
kinematic chains, brittle fracture, cloth,
water, gas molecules
Meeting Constraints
• Inverse Kinematics
– The end-effector must reach a desired point
• Linearize (using the Jacobian)
• Subdivide (linear model fails quickly)
– Iterative technique with an animation that is
not guaranteed to be optimal in any sense
• Bad decisions in beginning are offset at the end
Meeting Constraints
• Monte Carlo
– A random initial value, followed by simulation,
will not likely lead to constraint-satisfying outputs
• Random exploration of initial values will take too long
• Guided exploration of initial values is feasible
– Identifying the initial values to change and how
much to change them is nontrivial
– Benefits greatly from orthogonality of inputs and
locality of good solutions
Meeting Constraints
• Through the Lens
– Like IK, but equations are a bit more general
– Iterative
– Local linearizations
– Constrained optimization
• Minimize camera movement subject to a specific
velocity of the projection of a point on world space
to screen space
• Lagrangian kicked in to balance between violating
constraints and increasing camera movement
Spacetime Constraints
• We have a physical simulation that can be
driven as an initial-value problem
– Given a sequence of torques that are applied
to a bicyclist, we can simulate its final path
• We don’t have the inverse
– Given a sequence of landmarks, compute the
torques required to make a bicyclist ride
through them… make the torques “optimal”
Spacetime Constraints
• Given a sequence of landmarks, compute
the torques required to make a bicyclist
ride through them… make the torques
“optimal”
– One could propose trajectories that go
through landmarks but require unreasonable
amounts of energy
– One could propose low-energy trajectories
that don’t go through landmarks
Spacetime Constraints
• Balancing between constraint satisfaction
(in space) and evaluation function
minimization (in time) is the key!
• Globally optimal solutions are once again
impossible to find, so a good local method
is proposed
Roadmap
•
•
•
•
•
A Particle Example
SQP Method
Extension to Complex Models
Discussion
A Tiny Movie Demo
Problem Statement
Governing Equation (Motion Equation):
mx  f  mg  0
Boundary Conditions:
x(0)  a, x(T )  b
f(t)
g
Object Function (Energy Consumption):
T
R   | f (t ) |2 dt
0
Discretize continuous function
Discretize unknown function x(t) and
f(t) as:
x1, x2, …xi, … xn-1, xn
1
i
n
f1, f2, …fi, … fn-1, fn
Our goal is to solve these discretized
2n values… x1xn satisfies goals
while optimizing f1fn
Next step is to discretize our motion
equation and object equation.
Difference Formula
h
h
xi - 0.5
xi - 1
xi + 0.5
xi
xi + 1
xi  xi 1 xi 1  xi xi 1  xi 1
xi 


h
h
2h
Backward
xi 0.5  xi 0.5
xi 
h
Forward
Middle
xi 1  xi xi  xi 1

x  2 xi  xi 1
h
h

 i 1
h
h2
Middle
Discretized Function
Motion equation:
x
x3, f3
x2, f2
x4, f4
mx  f  mg  0 
m
( xi 1  2 xi  xi 1 )  f i  mg  0, i  2, 3
h2
Boundary Conditions:
x(0)  a  x1  a
x1, f1
t
Object Function:
T
R   | f (t ) |2 dt 
0
4
R   | f i |2
i 1
x(T )  b  x4  b
When does R have minimum value?
R
0
f i
R
R
R
R
0
0
0
0
f1
f 2
f 3
f 4
Roadmap
•
•
•
•
•
A Particle Example
SQP Method
Extension to Complex Models
Discussion
A Tiny Movie Demo
Generalize Our Notation
Unknown vector:
S = (S1, S2, …Sn)
x
x2, f2
x3, f3
x4, f4
Constraint Functions:
Ci(S) = 0
x1, f1
Minimize Object Function R(S):
t
S = (x1, x2, x3, x4, f1, f2, f3, f4)
m
( xi 1  2 xi  xi 1 )  f i  mg  0, i  2, 3
2
h
x1  a x4  b
Ci
J ij 
S j
R
0
S
2R
H ij 
S i S j
R
R
R
R
0
0
0
0
x1
x2
x3
x4
R
R
R
R
0
0
0
0
f1
f 2
f 3
f 4
Sequential Quadratic Programming
(SQP) Step One
Pick a guess S0, evaluate
R
S
Most likely
R
0
S
Taylor series expansion of function f(x) at point a is:
f ( x)  f (a)  f ' (a)( x  a) 
Similarly, we have:
Set equal to 0
1 ''
f (a)( x  a) 2  O(( x  a) 2 )
2!
R R
2R

 2
S S S  S0 S

( S  S 0 )  O(( S  S 0 ) 2 )
S  S0
R
 H ij ( S0 )( S  S0 ) 
S S  S0
S  S0  S
or
S  S0  S  S1'
S is the change to S0 that makes
derivative equal to 0
Omit
SQP Step Two
Now we got S1’, evaluate our constraints Ci(S1’), if equal to 0, we are done
but most likely it will not evaluate to 0 in the first several steps.
So, let’s say Ci(S1’) ≠ 0, let’s apply Taylor series expansion on
the constraint function Ci(S) at point S1’ :
C
C (S )  C (S ) 
S
( S  S1' )  O(( S  S1' ) 2 )
'
1
Set equal to 0
S  S1'
Omit
 C ( S1' )  J ij ( S1' )( S  S1' ) 
S  S1'  S 
or
S1  S 0  S  S 
S  S1'  S   S 0  S  S 
so S 0  S1
S is the change to S0 that makes
derivative equal to 0
Then we will continue with step one and step two until we got a solution
Sn which minimizes our object function and also satisfies our constraints.
S0  S1’  S1  S2’  S2  …  Sn
Graphical Explanation of SQP
R
S
C(S)
S2’
S0
S1
’
S2
S1
S
Roadmap
•
•
•
•
•
A Particle Example
SQP Method
Extension to Complex Models
Discussion
A Tiny Movie Demo
Difficulties
•
•
•
•
Set up the motion equations
Define the objective equation
Evaluate the derivatives
Fit them into our SQP solver
Derive Motion Equation
Use Lagrangian Dynamics (another use of
Lagrangian) to derive our motion equations
dynamically:
d T T
( )
Q  0
dt q
q
T – Kinetic Energy
q – Generalized Coordinates
Q – Generalized Forces
The Authors’ Automatic System
Graphical User Interface
T, Q, q
J
Function Boxes
R
H
Dynamic
System
SQP
Solver
Roadmap
•
•
•
•
•
A Particle Example
SQP Method
Extension to Complex Models
Discussion
A Tiny Movie Demo
Define Objective Functions
Define appropriate objective functions
may be extremely difficult:
•
•
•
•
Walking on hot coals
Walking on eggs
Carrying a bowl of hot soup
Pursued by a bear
The Author’s Automatic System
Symbolic Analysis is really complex, especially
for complex system.
The state of art symbolic analysis tool is Matlab,
Maple.
The author’s automatic system may work for
some relatively simple systems.
Local Optimization vs Global
Optimization
R
S0 S*
S*
S
Roadmap
•
•
•
•
•
A Particle Example
SQP Method
Extension to Complex Models
Discussion
A Tiny Movie Demo