230 likes | 392 Views
Skeletal Motion, Inverse Kinematics. Ladislav Kavan kavanl@cs.tcd.ie http://isg.cs.tcd.ie/kavanl/IET. Animating Skeleton. Character animation decomposed to skinning (skin deformation) previous lesson animation of the skeleton this lesson We consider only rotational joints
E N D
Skeletal Motion, Inverse Kinematics Ladislav Kavan kavanl@cs.tcd.ie http://isg.cs.tcd.ie/kavanl/IET
Animating Skeleton Character animation decomposed to • skinning (skin deformation) • previous lesson • animation of the skeleton • this lesson We consider only rotational joints • n ... the number of joints • joint rotations described by matrices T(0), ..., T(n) The task: Acquire T(0), ..., T(n) for each frame of the animation
Summary of Animation Methods • direct control of rotations (forward kinematics) • tedious work - only key postures designed • others computed automatically • indirect control: inverse kinematics • specify a goal, rotations computed automatically • more intuitive to use • motion capture • records a real motion • difficult to control (but possible!) • forward dynamics • physics engines
Keyframe Animation very old concept (Disney's studios) Idea: specify only important (key) frames • others given by interpolation of key frames Anything can be controlled via keyframes (not only rotation of joints) • variety of interpolation curves • piecewise constant, linear, polynomial (spline) For rotation: good interpolation of rotations essential! • SLERP (recall quaternions) • SQUAD (Spherical QUADratic interpolation)
Forward Kinematics (FK) • used for keyframe design • originated in robotics kinematic chain: a chain (path) of joints • base: the fixed part of a kinematic chain • end-effector: the moving part of a kinematic chain Assume (wlog): each joint rotates only about one fixed axis (... only 1-DOF) • Replace the 3-DOF joints by three 1-DOF joints (with the same origin)
Forward Kinematics (FK) Input: state vector = (1, ..., k)T - joint rotations • k is the number of DOFs of the kinematic chain Task: compute position (and orientation) of the end-effector: x = f() • only position: 3-DOF end-effector, xR3 • position and orientation: 6-DOF, xR6 • first three coordinates: translation • second three coordinates: rotation in scaled axis representation (unit axis multiplied by angle of rotation) Solution: f is concatenation of transformations • computed in the part about skinning: matrix F
Inverse Kinematics (IK) Input: the end-effector (goal) x is given • typically 3 to 6-DOFs Task: compute state vector = (1, ..., k)T such that f() = x, i.e. = f-1(x) Problems: • sometimes no solution (example?) • solution may not be defined uniquely (example?) • infinite number of solutions (example?) • f is non-linear • because of the sin and cos in rotations
IK: Analytical Solution Idea: solve the system of equations f() = x for • very difficult for longer kinematic chains • used only for 6/7-DOF manipulators • usually the fastest method (if possible) Example: Human Arm Like (HAL) chain • 7 DOFs: 3 shoulder, 1 elbow, 3 wrist • fast analytic solution for given position and orientation - IKAN library • 1 DOF remains: parametric solution • the parameter is a "swivel angle"
IK: Non-linear Optimization Idea: minimize function E() = f() - x • solved by non-linear optimization (programming) Advantages • easy to incorporate joint limits • add conditions li i hi, where li and hi are the limits • allows more general goals (planar, half-space, ...) Disadvantages • non-linear optimization can give a local minimum (instead of the global one) • slow for real-time applications
IK: Numerical Solutions Solve the problem for velocities (small displacements) • local approximation of f by linear function - called Jacobian k ... number of joints (DOFs) d ... dimension of goal (end-effector, usually 3-6)
IK: Jacobian Methods Typically: d=6 and f = (Px, Py, Pz, Ox, Oy, Oz) • (Px, Py, Pz) ... position • (Ox, Oy, Oz) ... scaled rotation axis Then Ji, the i-th column of Jacobian is computed as where • i is the axis or rotation of the i-th joint • ri is the end-effector vector w.r.t. the i-th joint
IK: Jacobian Inversion Original equation: x = f() Using Jacobian: x = J() • Jacobian maps small changes to small x changes Assume the Jacobian can be inverted: =J()-1x IK algorithm • Input: current posture , goal xg, current end-effector position xc Repeat until xc close to xg: • x = k(xg - xc) // k ... small constant • compute J()-1 • = + J()-1 x • xc= f()
IK: Jacobian Inversion Problems with inversion of J(): • J() rectangular (square only if k=d) • J() singular (rank-defficient) Ad 1) (Moore-Penrose) pseudo-inversion • compute from Singular Value Decomposition (SVD) Ad 2) serious problem: configuration singular • Example: fully outstretched kinematic chain • near singularity: large velocities & oscilation • SVD detects singularity
Singular Value Decomposition (SVD) Theorem: Any real mn matrix M can be written out as M = UDVT, where • U ... mn with orthonormal columns • D ... nn diagonal (singular values) • V ... mm orthonormal Properties: • M regular iff D contains no zeroes • if Di is D with non-zero elements inverted, then UDiVT is the pseudo-inverse matrix • efficient and robust algorithms for SVD exist • implemented for example in LAPACK
IK: Jacobian Transpose Idea: force acts on the end-effector and pushes it to the goal configuration Principle of virtual work: work = force distance, work = torque angle FTx =T (work = work) x =J() (Jacobian approximation) FT J() =T (putting together) FT J()=T =J()TF (transposing)
IK: Jacobian Transpose Instead of =J()-1x use simply =J()Tx • interpret as , and F as x The algorithm: the same as Jacobian Inverse, just use transpose instead of inversion Comparison with the Jacobian Inverse: • (pseudo-)inversion more accurate - less iterations • transposition faster to compute • transposition: physically based • intuitive control (rubber band)
IK: Cyclic Coordinate Descent (CCD) Idea: change only one joint angle iper step • others constant: analytical solution possible Input: Pc - current end-effector position Pg- goal end-effector position (u1c, u2c, u3c) - orthonormal matrix: curr. orientation (u1g, u2g, u3g) - orthonormal matrix: goal orientation Objective: minimize
IK: Cy IK: Cyclic Coordinate Descent (CCD) In the i-th step: 1, ..., i-1, i+1..., k constant Minimize E() = E(1, ..., k) only w.r.t. i Pic - current end-effector position w.r.t. joint i Pig- goal end-effector position w.r.t. joint i Pic'(i) - Pic rotated about joint i's axis with angle i Minimization of w.r.t. i equivalent to Maximization of g1(i) =
IK: Cyclic Coordinate Descent (CCD) (u1c'(i), u2c'(i), u3c'(i)) orthonormal matrix of the current orientation rotated by angle i about the i-th joint's axis Minimization of w.r.t. i equiv. to Maximization of Position and rotation together: g(i) = wpg1(i) + wog2(i) wp resp. wo is weight of position resp. orientation goal
IK: Cyclic Coordinate Descent (CCD) The function g(i) can be maximized analytically (complicated formulas, but fast to evaluate) CCD Algorithm: i = 1; Repeat until E() close to zero: • compute i giving maximal g(i) • i = (i % k) + 1 • CCD has no problems with singularities • converges well in practice
IK: Modern Trends Character animation: joint limits important First idea: impose limits on individual DOFs (angles) • too simple to express real joint range Advanced joint limits • quaternion field boundaries: • human motion recorded using motion-capture • rotations of joint (shoulder) converted to quaternions • boundaries expressed on unit quaternion sphere