[ODE] 3 beginner questions

David McClurg dmcclurg at pandemicstudios.com.au
Thu Apr 3 16:16:02 2003


To simulate drag, are you applying a "Torque" instead of a "Force" like the Wiki says?

http://q12.org/cgi-bin/wiki.pl?RollingFrictionOrAerodynamicDrag

In my own experience, instead of damping the angular velocity (torque), I've found that for rolling friction, applying a *CONSTANT* force opposing the velocity and clamping the force so it doesn't exceed the current velocity works well.  Here's a code snippet

    // get velocity and speed of body
    float* vel = dBodyGetLinearVel(body);
    F32 speed = dSqrt(vel[0]*vel[0] + vel[1]*vel[1] + vel[2]*vel[2]);

    // apply constant friction
    const float friction = 0.1f;  // you'll need to adjust this to feel right

    float scale = -1.f;
    if (friction < speed)
      scale = -(friction / speed);

    float f[3];
    f[0] = vel[0] * scale;
    f[1] = vel[1] * scale;
    f[2] = vel[2] * scale;
    dBodyAddForce(body, f[0], f[1], f[2]);

I don't have a theoretical basis for this, but in practice it seems to feel realistic.

-----Original Message-----
From: Bob Ives [mailto:bobives@jazzfree.com]
Sent: Friday, 4 April 2003 12:06 AM
To: ode@q12.org
Subject: [ODE] 3 beginner questions

2.  Drag.  After implimenting simple drag as described in the wiki faq, I found that objects still take a considerable time to come
to rest after colliding, despite increasing the drag coefficients.  I thought to experiment with the density argument I give in
dMassSetSphere, but surprisingly found that increasing density leads to the object slipping for more time before coming to rest, and
vice-versa.  I also found that with more density there was a contant interpenetration of my objects sphere with the ground plane.  I
wonder if the slip is somehow caused by a longer time resolving contacts between the ground and the moving body.