cs 775: advanced computer graphicsparagc/teaching/2012/cs775/... · 2012-01-13 · cs 775: lecture...
TRANSCRIPT
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation
● Traditional– Cell Animation, hand drawn, 2D
– Lead Animator for keyframes
http://animation.about.com/od/flashanimationtutorials/ss/flash31detanim2.htm
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation
● Traditional, hand drawn animation– Lead Animator for keyframes and many
secondary animators for the in-betweens
http://animation.about.com/od/flashanimationtutorials/ss/flash31detanim2.htm
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation
● Traditional, hand drawn animation– Keyframing @24fps – how many drawings for
a 2 hour movie?
http://animation.about.com/od/flashanimationtutorials/ss/flash31detanim2.htm
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation
● Computer assisted keyframing
– Keyframes created/posed by hand
– In-betweens interpolated by the semi-automatic techniques
Luxo Jr, PIXAR, 1986
How is this done?
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation
● Interpolating Position and Orientation parameters and animating (rigid) transformations.
● Linear interpolation, spline interpolation, quaternions.
Luxo Jr, PIXAR, 1986
How is this done?
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation
● Creating the keyframe pose for the lamp
– Modify the joint angles at each internal joint
– Modify global position and orientation
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation
● Kinematics
– Study of motion of objects by studying the change in their orientation and position. The cause of the motion, i.e., the forces are not studied.
● Dynamics
– Study of motion of objects in relation to the forces and torques that cause the motion.
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Kinematics
– Forward and Inverse Kinematics – used for posing characters and interpolation in keyframed animation.
– Faster to compute, easier to control
● Dynamics
– Physically-based animation – used for animations involving simulations of real world physics, for e.g., collisions.
– Harder to compute and control, more realistic (if modelled correctly),
– Can automatically adjust to changes in the environment.
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Terminology
Root Joint
Internal Joints
EndeffectorLinks or Bones
Kinematic Chain
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Terminology
0,0,0, t x , t y , t z
12
Joint DoF (parameters)
Root DoF
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Forward Kinematics
– Given the joint parameters, find the position of the end effector.
– Position of the root is given as a global transformation.
– Joint parameters are given as relative rotations (local transformations).
– We already know how to solve this! (from CS475/CS675)
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Inverse Kinematics
– Given the desired end effector position, compute the joint parameters.
– More interesting and easier to animate actions like – reaching, walking, grabbing.
– Much harder to solve.
– Why?
– Demo
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Inverse Kinematics
1
2
P x , y
l1
l 2
Given the link lengths and the desired position of the endeffector, find the joint parameter and that will make the endeffector reach the goal.
1 2
Pl1 l 2
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Inverse Kinematics
1
2
P x , y
l1
l 2
x=l1 cos 1l 2 cos 12
xy
y=l1 sin 1l 2 sin 12
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Inverse Kinematics
P x , y
IK a hard problem because it is an illposed problem.
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Posing the Kinematics problem
– Forward
– Inverse
is the vector of end-effector position and orientation. is the vector of joint parameters. is the mapping between the two.
X= f
= f −1X
X
f
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Assumptions
– The mapping is usually non-linear in the general case. However, we linearize the problem by localizing around the current position and use the Jacobian, i.e.,
– Note that the Jacobian is always a function of the current set of joint parameters – so it has to recalculated everytime they change!
d X=J d d=J−1d X
f
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Assumptions
– We will attempt to solve the Inverse Kinematics problems under the following assumptions:
● All joints are hinge joints.● All links are rigid and do not change in
length.
– Note that these assumptions are not there because the method we will use to solve the Jacobian require these assumptions but instead to simplify our discussion a bit.
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Steps:
– Construct the Jacobian
– Invert the Jacobian
– Iterate
– Detect singularities and avoid ill-conditioning
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Steps:
– Construct the Jacobian
– Invert the Jacobian
– Iterate
– Detect singularities and avoid ill-conditioning
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Forming a kinematic chain (Hierarchical modelling revisit)
● Given a kinematic chain with links (local coordinate frames) numbered from {1} to { j-1}.
● The position and orientation of the root is known in the global coordinate frame, {0}.
● Each has its local x-axis oriented along the length of the link and the local z-axis as the axis of rotation about the joint.
{1}
{ j−1}
{0}{2}
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Forming a kinematic chain
● Then the jth link can be added as follows:
– Translating along the local x-axis by the length of link { j-1},
{1}
{2}
l j−1
{ j−1}
{0}
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Forming a kinematic chain
● Then the jth link can be added as follows:
– Translating along the local x-axis by the length of link { j-1},
– Rotating at the new joint origin so that the local x-axis lies along the length of the new link.
{ j−1}
{1}
{2}
l j−1
{ j }
{0}
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Forming a kinematic chain
● So if this the transformation between the { j} and { j-1} frame is given by
– Any point in the frame { j} can be moved to a corresponding point in frame { j-1} as
– Therefore, the coordinates of the point in the global frame is given by
{ j−1}
{1}
{2}
{ j }
M jj−1
p j−1= M jj−1 p j
p j
p j−1
p0=M 0 . M 10 M j−1
j−2 . M jj−1 p j
{0}
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Moving to global coordinates
● The transformation from any local frame { j} to the global frame is thus, given by
{ j−1}
{1}
{2}
{ j }
T j= M 10 M j−1
j−2 . M jj−1
T j=[r 11 r 12 r13 t1
r 21 r 22 r 23 t 2
r 31 r 32 r 33 t 3
0 0 0 1]
{0}
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Constructing the Jacobian
● The Jacobian relates the end-effector velocities to velocities of the joint parameters.
[V nx
0
V ny0
V nz0
nx0
ny0
nz0
]=[∂ f 1
∂1
⋯ ⋯ ⋯ ⋯ ⋯∂ f 1
∂n−1
⋮ ⋱ ⋮
⋮∂ f i
∂ j
⋮
⋮ ⋱ ⋮∂ f 6
∂1
⋯ ⋯ ⋯ ⋯ ⋯∂ f 6
∂n−1
] [1
2
⋮⋮⋮
˙n−2
˙n−1
]d X=J d
X=J
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Constructing the Jacobian
● The Jacobian relates the end-effector velocities to velocities of the joint parameters.
d X=J d
X=J
UnknownKnown
[V nx
V ny
V nz
nx
ny
nz
]=[∂ f 1
∂1
⋯ ⋯ ⋯ ⋯ ⋯∂ f 1
∂n−1
⋮ ⋱ ⋮
⋮∂ f i
∂ j
⋮
⋮ ⋱ ⋮∂ f 6
∂1
⋯ ⋯ ⋯ ⋯ ⋯∂ f 6
∂n−1
] [1
2
⋮⋮⋮
˙n−2
˙n−1
]Simplifying Notation
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Constructing the Jacobian
– The functions relate the joint parameter angular velocities to the linear velocity of the end-effector.
– The functions relate the joint parameter angular velocities to the angular velocity of the end-effector.
– The velocities of the end-effector are known in the global coordinate system. So the Jacobian has to be formed in the global coordinate system.
f 1, f 2, f 3
f 4 f 5, f 6
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Constructing the Jacobian
– The jth column of the Jacobian relates the jth joint parameter angular velocity to the velocity of the end-effector.
J =[∂ f 1
∂1
⋯ ⋯ ⋯ ⋯ ⋯∂ f 1
∂n−1
⋮ ⋱ ⋮
⋮∂ f i
∂ j
⋮
⋮ ⋱ ⋮∂ f 6
∂1
⋯ ⋯ ⋯ ⋯ ⋯∂ f 6
∂n−1
]
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Constructing the Jacobian
● For the angular velocity,
– The contribution of this angular velocity to the angular velocity of the end-effector (in global coordinates) is given by
– So
{ j−1}
{ j }
{n−1}
j=z j j
j
j0 =T j z j j=u j j
∂ f 4
∂ j
=T j z jx=u jx
∂ f 5
∂ j
=T j z jy=u jy
∂ f 6
∂ j
=T j z j z=u jz
z j
{0}
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Constructing the Jacobian
● For the angular velocity,
– The contribution of this angular velocity to the linear velocity of the end-effector (in global coordinates) is given by
– So
{ j−1}
O j
{n−1}
j=z j j
j
V j0 =T j z j ×Pn−P j j=v j j
∂ f 1
∂ j
=v jx
∂ f 2
∂ j
=v jy
∂ f 3
∂ j
=v jz
On
z j
whereP j=T jO j
P n=T nO n
{0}
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Steps:
– Construct the Jacobian
– Invert the Jacobian
– Iterate
– Detect singularities and avoid ill-conditioning
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Inverting the Jacobian
– To solve IK, we must invert the Jacobian
– Note that the Jacobian is a fat matrix, i.e., it has more columns than rows.
– So the system is underconstrained – there is more than one possible solution.
– We choose the simplest solution, i.e., one of minimum norm:
d=J−1d X
=J−1 X
Find the unique for which we have: min∥∥2 s.t. X=J
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Linear Least Squares (Digression)
– For the system
– If A has full row rank then the unique X for which we get
is given by
– To see how this is so, solve the Lagrangian,
AX=B
min∥X∥2 s.t. AX=B
X=AT AAT −1B=A+ B
L=∥X∥2T AX−B
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Linear Least Squares (Digression)
– For the system
– If A has full row rank then the unique X for which we get
is given by
– To see how this is so, solve the Lagrangian,
AX=B
min∥X∥2 s.t. AX=B
X=AT AAT −1B=A+ B
L=∥X∥2T AX−B
MoorePenrosePseudoinverse
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Singular Value Decomposition (Digression)
– Any rectangular, real, mxn matrix A can be decomposed as:
– The pseudoinverse can be computed from the SVD as
A=U V T
A+=V +U T
where U is a m×m orthogonal matrix is a m×n diagonal matrixV is a n×n orthogonal matrix
where + is formed by transposing and taking a reciprocal of every non-zero singular value
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Inverting the Jacobian
– So we solve
– By computing the pseudoinverse of the Jacobian using the SVD
d=J−1d X
J +=V
+U T=∑
i=1
r
i-1v i ui
T
where r=m if the Jacobian has full row rank
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Steps:
– Construct the Jacobian
– Invert the Jacobian
– Iterate
– Detect singularities and avoid ill-conditioning
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Starting the IK solver and iterating
● Initialize the linear velocity components of the end-effector to , compute the Jacobian, invert, update the joints parameters and iterate.
● If dX is too large then due to local nature of the solution, tracking errors will occur, given by
● So sometimes we go from E to G in by taking smaller steps in the direction.
E
G
1
2
j
n−1
dX 1. .3=G−E
∥J d−dX∥
G−E
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Starting the IK solver and iterating
● Iterate only a fixed number of times and check whether has fallen below some tolerance.
● Also check after a few iterations whether the arm has become fully extended, is parallel to and the goal is still out of reach.
● What about the angular velocity components of the end-effector?
E
G
1
2
j
n−1
∥G−E∥
G−E
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Steps:
– Construct the Jacobian
– Invert the Jacobian
– Iterate
– Detect singularities and avoid ill-conditioning
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Detect singularities and avoid ill-conditioning
– The Jacobian becomes singular when it loses rank.
– This is detectable using the condition number, of the Jacobian matrix.
C=max
min
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Detect singularities and avoid ill-conditioning
– The solution also becomes ill-conditioned near a singulartiy, resulting in very high joint space velocities.
dX
d 1
∥d 1∥≫∥dX∥
CS 775: Lecture 3 Parag Chaudhuri, 2012
Character Animation● Detect singularities and avoid ill-conditioning
– To prevent ill-conditioning we damp the joint space velocities by searching for a solution that minimizes the sum:
– The solution to this is given by
– This is known as the damped least squares solution.
∥J d−dX∥22∥d∥2
d=J T J J T2 I −1dX
=V T T2 I −1U T dX
=∑i=1
r i
i2
2 v iu iTdX