26
Key Frame Animation and Key Frame Animation and Inverse Kinematics Inverse Kinematics

Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Embed Size (px)

Citation preview

Page 1: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Key Frame Animation and Inverse Key Frame Animation and Inverse

KinematicsKinematics Key Frame Animation and Inverse Key Frame Animation and Inverse

KinematicsKinematics

Page 2: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

IntroductionIntroductionIntroductionIntroduction Key frame animation requires an artist to build a Key frame animation requires an artist to build a character in various poses character in various poses Each pose is called a Each pose is called a key framekey frame Each key frame changes the local positions and local Each key frame changes the local positions and local orientations of the nodes in the hierarchyorientations of the nodes in the hierarchy To animate the character, the poses at the times To animate the character, the poses at the times between key frames are computed using interpolation.between key frames are computed using interpolation. Character Models are rich, complexCharacter Models are rich, complex

hair, clothes (particle systems),hair, clothes (particle systems), muscles, skin (FFD’s muscles, skin (FFD’s etc.etc.))

Focus is rigid-body, joint anglesFocus is rigid-body, joint angles

Page 3: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Key-frame animation Key-frame animation

Kinematics: how the positions of the parts vary as a function of the joint angles.Dynamics: how the positions of the parts vary as a function of applied forces.Each joint specified at various key frames (not necessarily the same as other joints)System does interpolation or in-betweeningDoing this well requires:

A way of smoothly interpolating key frames: splines A good interactive system A lot of skill on the part of the animator

Page 4: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Key-frame animation Key-frame animation

To specify a pose, we specify the joint-angle rotations Each joint can have up to three rotational DOFs Kinematics: how the positions of the parts vary as a function

of the joint angles. 1 DOF: knee 2 DOF: wrist 3 DOF: arm

Page 5: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Key-frame animation Key-frame animation

Links and Joints An articulated figure is a construction made of

links and joints. A link can be thought of as a solid rod. A joint can be thought of as a connection between

two neighboring links. A joint might have several degrees of freedom,

i.e., it might rotate around one, two, or three axes, or it might translate along one, two, or three axes

Links and joints can be numbered from 1, …,N

Page 6: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Key-frame animation Key-frame animation

Paired Joints Coordinates An articulated figure can be

described using the pared joint coordinates method [R. Featherstone, Robot Dynamics Algorithms,1998]

For each link three coordinate systems are associated:

- Body frame (BFi), associated with the center of mass of linki

- Inner frame (IFi), associated with jointi

- Outer frame (OFi), associated with jointi+1

Page 7: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Key-frame animation Key-frame animation

The Transformation The Transformation BFiBFiTTIFIFii

The problemThe problem is: given a point p = [x,y,z]T in inner frame coordinates, determine its coordinates in the body frame.

In homogeneous coordinates the transformation from the inner frame to the body frame is given by a matrix

BFiTIFi = TIFi (rIFi) RIFi (IFi,uIFi)

The translation and rotation matrices are as follows

TIFi (rIFi) =

RIFi (IFi,uIFi) = where the symbol 1 denotes a 3x3 identity matrix, and the vectors IIFi, jIFi,

kIFi,and 0 are 3x1 column vectors

Page 8: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Forward and Inverse Forward and Inverse KinematicsKinematics

Forward and Inverse Forward and Inverse KinematicsKinematics

Euler anglesEuler angles- - An Euler angle is a rotation about a single Cartesian

axis- Create multi-DOF rotations by concatenating Eulers Singularities in Euler Angles - Cannot be avoided (occur at 0° or 90°) - Difficult to work around What is a singularity? - continuous subspace of parameter space all of

whose elements map to same rotation Why is this bad? - induces gumball lock - two or more axes align,

results in loss of rotational DOFs (i.e. derivatives)

Page 9: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Forward and Inverse Forward and Inverse KinematicsKinematics

Forward and Inverse Forward and Inverse KinematicsKinematics

Kinematics Kinematics is the study of motion without considerations of mass or forces.

Given a planar polyline consisting of a sequence of line segments, with each segment starting at Pi, having a unit-length direction Ui, and length Li for 0 i < n, and last segment terminating at Pn

The forward kinematics problem is to compute Pn in terms of the known direction vectors and lengths

Page 10: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Forward and Inverse Forward and Inverse KinematicsKinematics

Forward and Inverse Forward and Inverse KinematicsKinematics

The final point of each segment is related to its starting point by

Pi = Pi + Li Ui for 0 i < n. Summing over all i and canceling the common

terms leads to the end effector formula

Pn = Pn + Li Ui Each direction vector can be viewed as an

incremental rotation of the previous direction

Ui = (cos( j), sin( j)).

Page 11: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Inverse KinematicsInverse Kinematics Inverse KinematicsInverse Kinematics

The angles i are called the joint angles of the manipulator. Using notation = (0, …, n-1), the end effector can be written as a function

Pn()= P0 + Li(cos( j),sin( j)). The inverse kinematics problem is to select the

position G for the end effector and determine joint angles so that Pn() = G.

The point G is called the goal and might not always be attainable.

Page 12: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Inverse KinematicsInverse Kinematics Inverse KinematicsInverse Kinematics

Numerical Solution by Jacobian Methods Numerical Solution by Jacobian Methods Closed-form solutions are usually not possible and

numerical methods are better choice for attempting to find solutions

Consider a manipulator that is a polyline with a single end effector.

Page 13: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Inverse KinematicsInverse Kinematics Inverse KinematicsInverse Kinematics

Numerical Solution by Jacobian Methods Numerical Solution by Jacobian Methods Let the end effector be written as P = F()The derivative of the end effector position with respect to

each joint parameter be used to determine an incremental step in joint space that will (hopefully) move the end effector closer to the goal.

If the position of the end effector is a function of time t, the derivatives are

dP/dt = DFd/dtDF is the Jacobian of F, the matrix of first-order

partial derivatives

Page 14: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Inverse KinematicsInverse Kinematics Inverse KinematicsInverse Kinematics

Numerical Solution by Jacobian Numerical Solution by Jacobian Methods Methods

If G is the goal and if dP/dt is replaced by G – P = G - F() as an approximation,

then the numerical method is to use G - F() = DF()d/dt

to update from its current value. The Jacobian matrix is (usually) not

square, so its inverse is not defined.

Page 15: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Inverse KinematicsInverse Kinematics Inverse KinematicsInverse Kinematics

Numerical Solution by Jacobian Methods Numerical Solution by Jacobian Methods Given a nonsquare matrix M, its pseudoinverse is defined

to be M+ =Mt (MM t) -1,

where M+M = I, the identity matrix. Applying the pseudoinverse of the Jacobian yields

d/dt = DF+()(G - F())Given a current value of , this equation allows an update

by using a forward difference operator to approximate the time derivative of the joint angles.

Page 16: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Inverse KinematicsInverse Kinematics Inverse KinematicsInverse Kinematics

Numerical Solution by Jacobian Methods Numerical Solution by Jacobian Methods The scheme is applied iteratively until some stopping criterion is

met. This approach is not always the best one since computing the

pseudoinverse is expensive, moreover, sometimes the Jacobian is singular on its domain or ill-conditioned, so numerical problems arise in the inversion.

More general approach is to use already existing algorithms for optimization. The idea is to minimize a quadratic function of the error E() = G - F()2 with respect to .

Page 17: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Motion InterpolationMotion InterpolationMotion InterpolationMotion Interpolation

Key-FramingKey-Framing In practice, it is not easy for animator In practice, it is not easy for animator

to specify all the joint parameters as to specify all the joint parameters as

functions of time, that is, functions of time, that is, 1, , 2,…, ,…, n

A helpful tool is to specify the joint A helpful tool is to specify the joint parameters by using what is known as parameters by using what is known as key-frameskey-frames..

The animator only has to specify the The animator only has to specify the most important configurations of the most important configurations of the articulated figure and also at what time articulated figure and also at what time ttii they occur, see Figure. they occur, see Figure.

Page 18: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Motion InterpolationMotion InterpolationMotion InterpolationMotion Interpolation

Key FramesKey Frames Having specified the key-Having specified the key-frames, that is, the joint frames, that is, the joint parameters at some discrete parameters at some discrete times ti, the joint parameters times ti, the joint parameters at the key-frames can be at the key-frames can be plotted on timeline, see plotted on timeline, see

Figure.Figure.

Page 19: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Motion InterpolationMotion InterpolationMotion InterpolationMotion Interpolation

Key Frames: Linear Key Frames: Linear InterpolationInterpolation If linear interpolation is If linear interpolation is used, the functions that used, the functions that represent the joint parameters represent the joint parameters are look like the ones shown are look like the ones shown in Figure.in Figure.

Page 20: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Motion InterpolationMotion InterpolationMotion InterpolationMotion Interpolation

Key Frames: Spline Key Frames: Spline InterpolationInterpolation In order to ger a In order to ger a smooth function for the smooth function for the joint parameters, we use joint parameters, we use the parametrs at the key-the parametrs at the key-frames as points that must frames as points that must be interpolated. be interpolated.

Page 21: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Motion InterpolationMotion InterpolationMotion InterpolationMotion Interpolation

Key Frames: Spline Key Frames: Spline InterpolationInterpolation How much the spline How much the spline bends and wiggles depends bends and wiggles depends on which type of spline and on which type of spline and how many control points are how many control points are use.use.

Page 22: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Interpolating the local Interpolating the local translations translations

Interpolating the local Interpolating the local translations translations

Kochanek-Bartels splines Given an ordered list of points {pi}

ni=0, the KBS provide a cubic

interpolation between each pair pi and pi+1 with varying properties specified at the end points.

These properties are tension , which controls how sharply the curve bends at a control

point; continuity , which provides a smooth visual variation in the

continuity at a control point; and a bias , which controls the direction of the path at a control

point.

Page 23: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Interpolating the local Interpolating the local translations translations

Interpolating the local Interpolating the local translations translations

Kochanek-Bartels splines use Hermite interpolation basis

H0(t) = 2t3 – 3t2 + 1, H1(t) = -2t3 – 3t2 ,

H2(t) = t3 – 2t2 + t, and H3(t) = t3 – t2 .

A parametric cubic curve passing through points pi and pi+1 with

tangent vectors Ti and Vi+1, respectively, is

xi(t) = H0(t) pi + H1(t) pi+1 + H2(t) Ti + H3(t) Ti+1,

where 0 t 1.

Page 24: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Interpolating the local Interpolating the local translations translations

Interpolating the local Interpolating the local translations translations

Kochanek-Bartels splines Parameters = 0, = 0, = 0. fish8_tr.avi

Page 25: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Key frame animation: Key frame animation: QuaternionsQuaternions

Key frame animation: Key frame animation: QuaternionsQuaternions

A quaternion invented by Sir William Rowan Hamilton in 1843 is given by q = w + xi + yj +zk,

where w, x, y, z are real numbers and i, j, k are primitive elements. Multiplication for them is defined by i2 = j2 = k2 = -1, ij = -ji = k, jk = -kj = i,

and ki = -ik = j.• A unit quaternion is a quaternion q for which the norm of the quaternion

N(q) = w2 + x2 + y2 + z2 = 1. • A unit quaternion can be represented by

q = cos + usin, where u = u0i + u1j + u2k and vector (u0,u1,u2) has length 1. • It is possible to define the logarithm of a unit quaternion,

log(q) = log(cos + usin) = log*exp(u) = u.• A unit quaternion q = cos + usin represents the rotation of 3D vector v

by an angle 2 about the 3D axis u

Page 26: Key Frame Animation and Inverse Kinematics. IntroductionIntroduction Key frame animation requires an artist to build a character in various poses Key

Key frame animationKey frame animation Key frame animationKey frame animation

Spherical Linear Interpolation Given two distinct points on a unit sphere in 3D space, it

is possible to interpolate between them by sampling along a great arc containing the two points.

To constrain the formula , let q0 and q1 be distinct unit vectors on a hypersphere. An interpolation is required of the form

q(t) = c0(t)q0 + c1(t)q1, 0 t 1,

where c0(t) and c1(t) are real-valued functions and q(t) is always a unit vector.