[ODE] Brakes and rotational damping
Jon Watte (ODE)
hplus-ode at mindcontrol.org
Thu Feb 9 15:00:45 MST 2006
Matthew Harmon wrote:
> - Velocity-Based Damping: Grab the angular velocity, reduce it, and
> put it back. This is easy, avoids “backlash”, but probably isn’t kosher
> and I imagine may result in non-physical behavior in ODE. However, this
> is “sort of” how brakes behave – they simply reduce any existing
> rotational velocity.
No; brakes bleed off existing energy as heat. That's very different.
> - Add “counter-torque”: Apply a torque opposing the current angle of
> rotation. This works, but has the “backlash” problem where applying too
> much torque will cause the body to reverse it’s spin. We check for
> backlash and “lock” the body if it switches direction… but this feels a
> little like a hack.
You should never look at the current angle of rotation; you should look
at the angular rotation speed (which is very different). If you take the
anngular rotation speed, scale it by some factor (that depends on the
mass of the body, and is negative) and apply it to the body as a torque,
this will apply a well-defined impulse during the next time step. If you
do this, and get a reversal of rotation direction once, then you will
get a reversal at each and every step (or you have a bug in your math).
That means your scaling factor is too big; you're breaking too much.
In reality, this works swimmingly in most cases:
dReal const S = -0.02;
dReal const * L = dBodyGetAngularVelocity( b );
dReal m = get mass scalar from body
dBodyAddTorque( b, L*m*S, L*m*S, L*m*S );
dWorldStep( 0.01 )
Note that this is done in euler angle space, which is, technically
speaking, not an equal-force space -- i e, you'll get the "move strafe
faster than move alone" problem unless you compensate.
More information about the ODE