on integrating rigidbody orientations

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
mewert
Posts: 52
Joined: Sat Oct 08, 2005 1:16 am
Location: Itinerant

on integrating rigidbody orientations

Post by mewert »

The classic approach to integrating rigidbody orientation is: R' = R + dR/dt*dt

with dR/dt = w~R
or dR/dt = .5*wq

R = rigidbodies orientation matrix
w = angular velocity
w~ = cross skew matrix from w
q = the quaternion from R

Seems to me calculus has blinded folks to the simple geometric ( physical ) relationship between R and w.

w is a vector whose direction is the axis of rotation and length is the magnitude of rotation in radians per second. So, all you need to do is premultiply R by an axis angle transform created from w*dt.

This doesn't suffer from any extrapolation artifacts like the R + dR/dt approach does. It's simply the correct rotation.

I checked the Bullet code, it resorts to exponential maps... might want to change that.

Unless I'm missing something?

- Michael Alexander Ewert
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: on integrating rigidbody orientations

Post by Dirk Gregorius »

I think this is exactly what the exponential map is doing. It also uses a small trick to make w * dt more numerically stable when w -> 0 and you cannot easily build an axis-angle rotation. In terms of performance it might maybe even the best to use q' = 0.5 * w * q and only skip to the exponential map for small rotations. On the other side I found rigid body integrations hardly ever the bottleneck.
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: on integrating rigidbody orientations

Post by bone »

Yes and no.

To do rigid body dynamics correctly, you need to preserve rotational momentum, not rotation itself which can 'wobble' for a rigid body without any external torques (as you may know). This in turn affects how the rotation affects the orientation.

You are absolutely correct about the integration, though. I think some people have the mindset that if you can't easily feed the derivatives into a generic integrator, you can't use it - I've run into this recently with a certain customer. That is what has "blinded" them - they have generated an unnecessary constraint on the types of algorithms they can use.

I always refer people to this paper: http://euclid.ucsd.edu/~sbuss/ResearchW ... /paper.pdf. It's an excellent paper which, among other things, shows that using RK4 is actually only 2nd-order accurate for rigid body rotations. And he provides several simple & cheaper methods that surpass that accuracy, which I use in my engine.

Note: I haven't investigated the exponential map method at all.
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: on integrating rigidbody orientations

Post by bone »

Dirk Gregorius wrote:It also uses a small trick to make w * dt more numerically stable when w -> 0 and you cannot easily build an axis-angle rotation.
In practice I don't think there's any concern about the stability as w -> 0 because the angle goes to zero. Even if the axis is haywire, the near-zero angle is going to result in a near-identity matrix (for the angle-axis transform). I could be wrong, but I've never seen any issues.

Does the exponential map handle high speeds (more than, say, 180 degrees per timestep)? Because that's typically no problem for the axis-angle method, at least until other factors like the rigid body wobble and/or constraint-solving issues come into play.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: on integrating rigidbody orientations

Post by Dirk Gregorius »

IIRC the exponential map basically just create a rotation from w * dt and then applies it. The only gotcha was that it used some identities to improve numerical robustness for small angular velocities.

Bone:
So you use a higher order angular velocity constraint integrator to integrate the gyroscopic forces and then relax constraints as usual? If yes, any noticeable performance hit? And did the overall quality improve (e.g. long chains or bridges) and still any issues whith thing long objects?

Cheers,
-Dirk
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: on integrating rigidbody orientations

Post by bone »

Dirk Gregorius wrote: So you use a higher order angular velocity constraint integrator to integrate the gyroscopic forces and then relax constraints as usual?
Basically. After checking the code, I actually don't quite use the Buss methods exactly. I integrate the rotational momentum first with the torque, and then use one of the Buss methods minus the torque to integrate the orientation. It's somewhat analogous to the usual linear symplectic Euler integration, and my tests showed it still remained fairly accurate.
If yes, any noticeable performance hit?
I don't think so. It's a tiny percentage of the overall dynamics, as you said above.
And did the overall quality improve (e.g. long chains or bridges) and still any issues whith thing long objects?
Excellent question, but I don't have a good comparison to know. For my application, I'm more concerned with proper gyro dynamics than really long chains. But I haven't noticed any stability problems with a somewhat complex system with loops (at least not yet ... it's a work-in-progress).
mewert
Posts: 52
Joined: Sat Oct 08, 2005 1:16 am
Location: Itinerant

Re: on integrating rigidbody orientations

Post by mewert »

Ah, I see how the exponential map collapses into the rotation formula I posted. I just don't rotate the body if the angle < epsilon.

I'm quite interested in the fact that most physics engines drop the non-linear part of Euler's equation. (w x I w). Not for gyroscopic effects so much as for torque-free precession around an intermediate inertial axis. i.e. the way a book tumbles unintuitively if you toss it in the air spinning around the left-right axis. I think this actually generates some nice motion for flying debris. It gives explosions a bit more spice, and I like it when stuff blows up real good.

Unfortunately it results in instability with a forward Euler integrator.

I'd actually like to solve the implicit euler formulation of Euler's equations.

So solve either:

w' = w - I^-1(w' x ( I w' ) ) dt

or

w1' = w1 + (I2-I3)/I1 w2'w3'
w2' = w2 + (I3-I1)/I2 w3'w1'
w3' = w3 + (I1-I2)/I3 w1'w2'

for the ' terms

which I don't have math skills for. Anyone know how to solve something like that?

- Michael Alexander Ewert
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: on integrating rigidbody orientations

Post by bone »

mewert wrote:Unfortunately it results in instability with a forward Euler integrator.
For a freely rotating rigid body, Buss's methods preserve energy much better than the rotation-preserving methods in most physics engines. The only possible instability comes in when you start applying constraints - I haven't carefully tested or worked out whether the stability is better or worse in those situations. But like I said above, I haven't noticed any major problems yet.
Post Reply