constraints and collisions
TRANSCRIPT
Rotational Inertia
β’ The rotational inertia tensor π is a 3x3 symmetric matrix that is essentially the rotational equivalent of mass
β’ It relates the angular momentum π of a rigid body to its angular velocity π by the equation
π = π β π
β’ This is similar to how mass relates linear momentum to
linear velocity with π© = ππ―, but adds additional complexity because π is not only a matrix instead of a scalar, but it also changes over time as the object rotates
Principal Axes & Inertias
β’ If we diagonalize the π matrix, we get an orientation matrix π and a constant diagonal matrix π0
π = π β π0 β ππ
β’ The matrix π rotates the object from an orientation where the principal axes line up with the x, y, and z axes
β’ The three diagonal values in π0, (namely πΌπ₯, πΌπ¦, and πΌπ§) are the principal inertias. They represent the resistance to torque around the corresponding principal axis (in a similar way that mass represents the resistance to force)
Rigid Body Dynamics
β’ The center of mass of a rigid body behaves like a particle: β Position: π±
β Velocity: π― =ππ±
ππ‘
β Acceleration: π =ππ―
ππ‘=
π2π±
ππ‘2
β Mass: π
β Momentum: π© = ππ―
β Force: π =ππ©
ππ‘= ππ
Rigid Body Dynamics
β’ Rigid bodies have additional properties for rotation: β Orientation: π
β Angular velocity: π
β Angular acceleration: π =ππ
ππ‘
β Rotational inertia: π = π β π0 β ππ
β Angular momentum: π = π β π
β Torque: π =ππ
ππ‘= πΓ π β π + π β π
Applied Forces
β’ When we apply a force to a rigid body at some position π±π, this is equivalent to applying the same force on the center of mass as well as a torque equal to π« Γ π, where π« = π±π β π± and π± is the position of the center of mass of the rigid body
β’ Various forces can apply to a rigid body and they are just summed up as a single total force and torque:
ππ‘ππ‘ππ = ππ
ππ‘ππ‘ππ = π«π Γ ππ
Newton-Euler Equations
β’ The Newton-Euler equations describe the motion of a rigid body under applied force and torque:
π = ππ π = π Γ π β π + π β π β’ Solved for acceleration: π = π π π = πβ1 π β π Γ π β π
Kinematics of an Offset Point
β’ Kinematic equations for an offset point on a rigid body:
π±π = π± + π«
π―π = π― +π Γ π«
ππ = π +π Γ π« +π Γ πΓ π«
π± π«
π±π = π± + π«
Offset Forces
β’ If we apply a force π to a rigid body at offset π«1, what is the resulting acceleration π at offset π«2?
π
π =?
π«π
π«π
Inverse Mass Matrix
π =1
ππ β π«2 β πβ1 β π«1 β π
π =1 π 0 00 1 π 00 0 1 π
β π«2 β πβ1 β π«1 β π
π = πβ1 β π
πβ1 =1 π 0 00 1 π 00 0 1 π
β π«2 β πβ1 β π«1
Rigid Pendulum
β’ Consider a rigid body pendulum constrained at point π±π with a ball-and-socket joint (3-DOF rotation)
β’ We assume that various known forces πππππ€π are acting on the rigid body, such as gravity
β’ The joint is able to apply whatever force ππππππ‘ that is necessary to keep the offset point of the rigid body stationary
β’ We need to solve for the unknown constraint force ππππππ‘
π±π
π«
π±
πππππ€π
ππππππ‘
Rigid Pendulum
β’ To evaluate all forces at a particular instant:
β We first evaluate all known forces on the rigid body (gravity, air friction, joint friction, etc.)
β Next, we can determine what the acceleration ππ of the offset point π±π would be with no constraint
β Then, we can use the inverse mass matrix to solve for the joint force needed to counteract the acceleration and hold the joint together
Offset Acceleration
β’ Assuming a known total force πππππ€π and torque πππππ€π are acting on the rigid body, we can calculate the acceleration ππ at relative offset π« as:
π = πππππ€π π
π = πβ1 πππππ€π βπΓ π β π
ππ = π +π Γ π« +π Γ πΓ π«
Joint Force
β’ We need a joint force that will be applied at relative offset π« and must cancel out the acceleration ππ (at the same place)
β’ We can construct an inverse mass matrix πβ1 using π« for both offsets
πβ1 =1 π 0 00 1 π 00 0 1 π
β π« β πβ1 β π«
β’ We then invert it to get the mass matrix π β’ We can then solve for the joint force needed to cancel out the
acceleration ππ
ππππππ‘ = βπ β ππ
Joint Force
β’ Once we have the joint force, we apply it to the rigid body just as any other force, thus finishing the summation of the total force and torque
β’ We can then use the total force and torque to integrate the motion forward
Rigid Pendulum Force Computation 1. Apply known forces
πππππ€π = ππ
πππππ€π = π«π Γ ππ
2. Compute separation acceleration at joint
π = πππππ€π π
π = πβ1 πππππ€π βπΓ π β π
ππ = π +π Γ π« + πΓ πΓ π«
3. Build inverse mass matrix
πβ1 =1 π 0 00 1 π 00 0 1 π
β π« β πβ1 β π«
4. Solve joint constraint force
π = πβ1 β1
ππππππ‘ = βπ β ππ
5. Compute total force & torque
ππ‘ππ‘ππ = πππππ€π + ππππππ‘
ππ‘ππ‘ππ = πππππ€π + π« Γ ππππππ‘
π«
πππππ€π
ππππππ‘
ππ‘ππ‘ππ
Joint Error
β’ Unfortunately, thereβs a catchβ¦
β’ The problem is that the joint forces are changing continuously, and so the finite time integration will accumulate a small error on every step
β’ An error in the integration of the second derivative means that the first derivative (velocity) and the zeroth derivative (position) will accumulate error
β’ This error shows up as a non-zero velocity at the joint and as a gap in position as well
Joint Error
β’ There are several options for correcting the error:
β Penalty forces
β Impulse to correct velocity
β βPushβ to correct position
β Construct as kinematic hierarchy
Double Pendulum
β’ Consider the double pendulum
β’ Known force ππ1 acts on body 1 and known force ππ2 acts on body 2
β’ We need to simultaneously solve for joint forces ππ1 and ππ2
that hold both joints together ππ1
ππ1
ππ2
ππ2
βππ2
ππππ¦ 1
ππππ¦ 2
πππππ‘ 2
πππππ‘ 1
Notation
β’ We define π«ππ as the offset from the center of mass of body π to joint π
β’ We will define ππππβ1 to be
the inverse mass matrix computed for body π, that relates the force applied at joint π to the acceleration at joint π
ππππ¦ 1
ππππ¦ 2
πππππ‘ 2
πππππ‘ 1
π«11
π«12
π«22
Known Accelerations
β’ The accelerations of the first body due to known force and torque are:
π1 = ππ1 π1
π 1 = π1β1 ππ1 βπ1 Γ π1 β π1
ππ11 = π1 +π 1 Γ π«11 +π1 Γ π1 Γ π«11 ππ12 = π1 +π 1 Γ π«12 +π1 Γ π1 Γ π«12
β’ And for the second body: π2 = ππ2 π2
π 2 = π2β1 ππ2 βπ2 Γ π2 β π2
ππ22 = π2 +π 2 Γ π«22 +π2 Γ π2 Γ π«22
Separation Acceleration
β’ For a particular joint, weβre actually interested in the acceleration that the two bodies are potentially separating
β’ In other words, we want the difference between the offset accelerations of the two connected bodies at the joint
β’ By definition, we will choose the sign such that we subtract the lower numbered bodyβs offset acceleration from the higher numbered bodyβs
β’ Also, for weβll assign body 0 as the fixed coordinate system β’ Therefore, we get the two joint separation accelerations:
ππ1 = ππ11 ππ2 = ππ22 β ππ12
Joint Forces
β’ The separation acceleration at joint 1 resulting from joint forces will be the sum of accelerations due to ππ1 and βππ2
β’ The acceleration at joint 1 due to joint forces will be:
ππ1β² = π111
β1 β ππ1 +π121β1 β βππ2
ππ1β² = π111
β1 β ππ1 βπ121β1 β ππ2
β’ The separation acceleration at joint 2 will be the difference of the accelerations of the offset point on body 2 and the offset point on body 1
ππ2β² = π222
β1 β ππ2 β π112β1 β ππ1 +π122
β1 β βππ2
ππ2β² = βπ112
β1 β ππ1 + π122β1 +π222
β1 β ππ2 ππ1
ππ1
ππ2
ππ2
βππ2
ππππ¦ 1
ππππ¦ 2
πππππ‘ 2
πππππ‘ 1
Joint Forces
ππ1β² = π111
β1 β ππ1 βπ121β1 β ππ2
ππ2β² = βπ112
β1 β ππ1 + π122β1 +π222
β1 β ππ2
ππ1β²
ππ2β² =
π111β1 βπ121
β1
βπ112β1 π122
β1 +π222β1 β
ππ1ππ2
ππβ² = πβ1 β ππ
Double Pendulum
πβ1 =π111
β1 βπ121β1
βπ112β1 π122
β1 +π222β1
ππ = βπ β ππ β’ To compute the joint forces for the double pendulum:
β Apply known forces β Compute separation acceleration for each joint β Build 6x6 system inverse mass matrix
β Invert mass matrix to solve joint forces with ππ = βπ β ππ β Add joint forces to compute total forces and torques
Articulated Bodies
β’ We can extend this method to large systems of constrained rigid bodies
β’ We end up producing a large system mass matrix that relates the vector of all joint forces to the vector of all joint accelerations
β’ If we assume π 3-DOF ball joints, we would end up with a 3π Γ 3π mass matrix describing the relationship between joint forces and joint separation accelerations
Constraint Types
β’ Weβve looked at 3-DOF ball-and-socket joints β’ These are nice because they require solving a
straightforward 3D force β’ However, other joint types are also possible such
as 1-DOF hinges, 2-DOF universal joints, 1-DOF translational βprismaticβ joints, and more
β’ These other joint types can apply a constraint force as well as torques
β’ A 1-DOF hinge joint, for example, applied 5 constraints: 3 forces, and 2 torques, leaving 1 DOF free to rotate
Constraint Types
β’ To handle different constraint types, we need to compute the individual mass matrices differently
β’ We can generalize the force-acceleration relationship to include torques and angular accelerations
β’ A 1-DOF rotational joint would require a 5x5 inverse mass matrix that relates 3 forces and 2 torques to 3 accelerations and 2 angular accelerations
β’ The overall process is similar to how we derived the inverse mass matrix in the last lecture
System Mass Matrix
β’ For a system of articulated rigid bodies, we end up with an π Γπ mass matrix that relates constraint forces to accelerations, where π is the total number of constrained degrees of freedom
β’ We see that a large system of constraints results in a large matrix that must be inverted
β’ The matrix will be more sparse for loosely coupled systems and less sparse for tightly coupled systems
β’ The matrix will also be positive definite β’ There are several approaches to solving this system:
β Direct matrix solution β Pairwise solution β Recursive solution (Featherstoneβs algorithm) β Lagrangian formulation
Direct Solution
β’ If we have a dense mass matrix, we can directly invert with standard matrix inversion or solvers
β’ Larger matrices tend to be more sparse, and so can benefit from special purpose sparse solvers
β’ There are a variety of special purpose solvers that can take advantage of properties of the system (sparseness, positive-definitenessβ¦)
Pairwise Algorithms
β’ One can also use pairwise algorithms to solve large systems of constraints
β’ With this method, we group all constraints into a queue, ordered by the magnitude of the separation accelerations
β’ We then iteratively solve for the constraint at the top of the queue, and then add it to the known forces, recomputing separation accelerations of connected joints and re-ordering the queue as needed
β’ Basically, this method continues to fix the constraint with the largest separation and repeats until it converges and all separations approach zero
Featherstoneβs Algorithm
β’ Featherstoneβs algorithm is a recursive method for solving the dynamics of tree structures without kinematic loops
β’ It can evaluate systems in linear O(n) time β’ It traverses from the fixed base (or an unfixed root) to the
leaf nodes computing joint separation accelerations and accumulating a mass matrix connecting from the base to each leaf
β’ Then, it solves the joint forces from the leaves progressing back to the root
β’ There are some adaptations to handle kinematic loops, but they compromise the linear time behavior
β’ βRobot Dynamics Algorithmsβ, Featherstone, 1987
Lagrangian Dynamics
β’ We can also reformulate the equations into the Lagrangian form β’ This is fairly different from how weβve done things so far β’ Lagrangian methods define the state of the system using
generalized coordinates, only using coordinates for actual DOFs in the system
β’ In this approach, the constraints never actually need to be solved, but we do have to solve for the motion of the degrees of freedom
β’ If the number of unconstrained DOFs is less than the number of constrained DOFs, then these methods can be faster than the Newtonian methods described so far
β’ However, the method can be tricky to work with and doesnβt handle collisions or energy damping easily
Kinematic Loops
β’ We often distinguish between articulated bodies with open tree-like structures from bodies with closed kinematic loops
β’ Closed loops can add challenges to some of the solution methods, as they may result in over-constrained systems and non-invertible mass matrices
β’ Some methods require special handling for these, while other methods (like pairwise solvers) donβt require anything special
Detection and Response
β’ Collision handling requires two different technologies: β Collision detection (geometry) β Collision response (physics)
β’ The collision detection problem is a complex application of 3D geometry and spatial data structures, and will be discussed in more detail in the next lecture
β’ Collision response is the physics problem of determining the forces (or impulses) resulting from the collisions
Impact vs. Contact
β’ It is useful to distinguish between momentary (instantaneous) impacts and finite time contacts
β’ With impacts, the closing velocity is positive before the collision, and with contacts, the closing velocity is zero (or very close)
β’ Some rigid body methods handle impacts differently from contacts, while other methods donβt distinguish between the two
Impulse
β’ Force is the derivative of momentum, and changes in momentum require forces acting over time
β’ An impulse π£ is a large force applied over a short time, such that it can be treated as an instantaneous change in momentum, rather than a rate of change over time
π£ = πππ‘
β’ Impulses operate in a very similar fashion as forces, except they affect the velocity
instead of the acceleration β’ As with forces, impulses obey Newtonβs Third Law (action/reaction) β’ An impulse can be applied to a rigid body at relative offset π« resulting in an
instantaneous change in momentum π© and angular momentum π of the body
βπ© = π£ βπ = π« Γ π£
Collision Impulses
β’ Most rigid body methods resolve instantaneous impacts with impulses
β’ Persistent contacts can be simulated with forces or impulses, but many modern methods use impulses
β’ In fact, constraints can be handled through forces or impulses as well, and by using impulses, one can handle impacts, contacts, and constraints through a single process
Single Body Impact
β’ We define π±π as the impact point, π§ as the normal of the impact surface, π―π as the offset velocity before the collision, π―πβ² as the offset velocity after, and π£ is the impulse
π―π
π―πβ² π§
π±π
π£
Collision Restitution
β’ In terms of collisions, restitution refers to the amount of kinetic energy that is conserved, and thus the amount of bounce
β’ We can measure it with a coefficient of restitution π that will range from 0 (perfectly inelastic) to 1 (perfectly elastic)
β’ For simplicity, we can assume that we have a constant restitution for a rigid body. If two rigid bodies of different restitution collide, it is a reasonable heuristic to use the lower of the two for the impulse computation
β’ Note: there are different ways to define the exact meaning of this constant, and it is ultimately just an approximation to a far more complex process that is dependent on the material properties and shape of the object
β’ Note: sometimes called coefficient of elasticity
Collision Impulse
β’ We need a collision impulse that will be applied at relative offset π« and must cancel out the velocity π―π (at the same place)
β’ We can construct an inverse mass matrix πβ1 using π« for both offsets
πβ1 =1 π 0 00 1 π 00 0 1 π
β π« β πβ1 β π«
β’ We then invert it to get the mass matrix π β’ We can then solve for the impulse needed to cancel out the velocity
π―π
π£ππππππ‘ = β 1 + π π β π―π
Coulomb Friction
β’ The simple but effective Coulomb friction model says:
ππ π‘ππ‘ β€ ππ πππππ πππ¦π = πππππππ
β’ Where ππ π‘ππ‘ is the force due to static friction, πππ¦π is the force due to dynamic friction, πππππ is the normal force, and ππ and ππ are the coefficients of static and dynamic friction
β’ The direction of the force will be opposite of the tangential velocity at the contact point
β’ The coefficients range from 0 (perfectly frictionless) to around 1.5 or so, but there really isnβt a strict maximum, as materials could conceivably have adhesive (sticky) properties
β’ ππ is typically a bit larger than ππ
Friction Cone
β’ Consider a block sliding on a flat surface
β’ The ground applies a normal force and a friction force
β’ According to the Coulomb friction model, the two forces must add up to a vector that lies within the friction cone
β’ The same can be said about impulses resulting from impacts
π£
π
1
Tangential Velocity
β’ We need to find the tangential velocity of the impact in order to determine the direction the friction will act
β’ We start by taking the difference of the two object velocities offset at the collision point
π― = π―1 β π―2 β’ If π§ is the surface normal if the contact point, we can decompose
the velocity into normal and tangential components:
π―ππππ = π― β π§ π§ π―π‘ππ = π― β π―ππππ
Rolling & Spinning Friction
β’ One can also add rolling and spinning friction effects to collisions and contacts
β’ We must first find the angular velocity difference at the collision point β’ From there, we can decompose it into rolling and spinning components
based on the contact normal π§
ππ πππ = π β π§ π§
πππππ = πβππ πππ β’ We can then apply friction torques proportional to each of those based on
separate constants
πππππ = β πππππ ππ πππππ πππ + ππππππππππ
Joint Friction
β’ We can also add friction on articulated joints β’ Usually, these would be based on the angular velocity of the joint, which is
the difference of the angular velocities of the two connected bodies β’ For rotational joints, the joint friction will be in the form of a torque
applied equal and opposite to the two connected bodies
πππππ = βππππππ‘ππππππ‘
β’ Where πππππ is the friction torque, ππππππ‘ is the joint friction, and ππππππ‘ is the joint angular velocity
β’ Static friction can also be modeled for joints. To do this, one must first assume a 6-DOF constraint and solve for the required constraint force. If this is within the static friction limit, it is used, otherwise, it is solved as a regular joint and dynamic friction is added
Collision Impulse with Friction
β’ We wish to find a collision impulse π£ that accounts for the elasticity and friction β’ We can compute the velocity of the colliding point at offset π« as:
π―π = π― + π Γ π«
π―ππππ = π―π β π§ π§ π―π‘ππ = π―π β π―ππππ
β’ We also build the inverse mass matrix πβ1 for the body using π« for both offsets β’ We start by assuming perfect static friction and solving for the impulse that would result in an
elastic bounce and the tangential velocity going to zero after the collision:
π―ππππβ² = βππ―ππππ
π£0 = π β π―ππππβ² β π―ππππ
β’ This allows us to solve the impulse that produces this result β’ If this lies within the friction cone, then weβre done β’ Otherwise, we assume sliding (dynamic) friction β’ For more details, see section 7 of βNonconvex Rigid Bodies with Stackingβ, Guendelman, Bridson,
Fedkiw, 2003
Multiple Body Collisions
β’ We can solve for multiple collisions in the same basic way that we solved for multiple constraint forces
β’ We set up a large linear system that includes all of the collision constraints
β’ There are two main differences from the articulated body solution: β For collisions, we work with impulses rather than
forces β For collisions, we are solving an inequality problem
rather than an equality problem
Linear Complementarity
β’ Collisions result in inequality constraints because they will only act to prevent objects from moving towards each other and have no effect on objects moving apart
β’ A large system of inequalities can be formed into a linear complementarity problem (LCP) which is a well studied class of problems
β’ Various solution methods have been proposed to address these, and some are discussed in the overview paper on the web page
Pairwise Solvers
β’ Pairwise solvers iteratively solve one collision at a time until the entire system is satisfied
β’ These have proven to be pretty effective in handling of multiple collisions and constraints, as each one can be treated with its own rules and special cases
β’ Some other methods may be faster, but pairwise solvers tend to be very general purpose and easy to implement