[ODE] Joint tutorial for ODE?

mike cline cline at cs.ubc.ca
Wed Feb 13 19:47:02 2002


nlin@nlin.net wrote:

>I was wondering if you could update the documentation on joints anytime
>soon - for instance, a tutorial on how the ball and socket joint constraint
>is derived.

Hi.. I've been working on my own dynamics engine that is very similar in 
spirit to ODE.  This is how I derive a ball-and-socket joint.. (I imagine 
Russ's derivation would be similar).  Maybe this will tie you over until 
Russ comes out with more details.

NOTATION: (Most of my notations and formulas are similar to Baraff's 
SIGGRAPH 97 Course notes, which is a good introductory reference)
xa, xb are the positions of the centres of mass of body A and body B
Ra, Rb are the rotation matrices for A and B
va, vb are the velocities of the centres of mass
wa, wb are the angular velocity vectors
(all these vectors are in 'world coordinates')

[v] denotes the cross-product matrix for vector v, which is:

[ 0  -v.z  v.y ]
[ v.z  0  -v.x ]
[ -v.y v.x  0  ]

(Baraff calls that the "star" operator, but other authors use this bracket 
notation.)

A ball and socket joint constrains two "anchor points" (one on each body) 
to have the same position.  First, note that the coordinates of the anchor 
points are constant in their own body's coordinate frame.  Let  "ra" be the 
body-coordinates of the vector from the centre of mass of A to the anchor 
point on body A, then the world-coordinates of the anchor point is

pa = xa + Ra * ra          ("*" is matrix multiply)
   similarly for body B,
pb = xb + Rb * rb

The position constraint is :
   pa = pb
or
   pa - pb = 0

to get the velocity constraint (and the Jacobian), you take the derivative.

note that (d/dt) xa = va
and (d/dt) Ra = [wa] * Ra

so, you get:
(va + [wa] * Ra * ra) - (vb + [wb] * Rb * rb) = 0

lets say (to make notation shorter):
   za = Ra * ra
   zb = Rb * rb
then:   (va + [wa] * za) - (vb + [wb] * zb) = 0

then using the property of cross-products that  for any v1, v2
    v1 cross v2 = -v2 cross v1

(va - [za] * wa) - (vb - [zb] * wb) = 0

Now this is in a form where we can turn it into a matrix equation with the 
velocities as unknowns.  doing this, we have (hopefully you are viewing 
this with a monospaced font):

[ 1 0 0 0    za.z -za.y -1 0 0 0  -zb.z zb.y ]
[ 0 1 0 -za.z  0   za.x 0 -1 0 zb.z 0  -zb.x ] v = 0
[ 0 0 1 za.y -za.x   0  0 0 -1 -zb.y zb.x 0  ]

where v = [ va wa vb wb ]^T

The big 3x12 matrix is the jacobian of the constraint.

Hopefully this is clear enough to follow..  A hinge joint can be made by 
adding two additional rows to the Jacobian, to constrain the relative 
angular velocities more.

mike