[ODE] dxTriangle

david@csworkbench.com david at csworkbench.com
Thu Mar 27 12:00:03 2003


You probably already tried this, but I thought I'd offer a suggestion just
in case you haven't: try negating the direction of the normal.  I forget
if the convention is from body 1 to body 2 or the other way around, but
just negating it should tell you if that's your problem or not.

David

> My apologies to the moderator(s) for taking 4 goes to get my sent-from
> address right . . .
> I've been lurking for a while - time I said "hi" anyway...
>
> I have decided to write my own Triangle primitive for collision
> detection in ODE, rather than using tri-collider and/or Opcode. As far
> as I can make out the triangle is generating perfectly good normals,
> collision points and penetration depths, but the behaviour of the system
> is far from stable.
>
> My test case is a large triangle on the plane y = -4.0, and a radius 1.0
> sphere which begins at y = 8.0 and travels towards it. The sphere is
> attached to the origin with a piece of weak elastic, but this is
> incidental, and causes no problems with sphere-sphere collisions (which,
> by the way, are working fine).
>
> Firstly, in my debug below, the velocity and accumulated force on the
> sphere is always reported as 0. I have no idea why, since the elastic
> undoubtably works, and the sphere definitely moves. I am obtaining it
> with
> dBodyGetLinearVel and dBodyGetForce.
>
> Secondly, if you follow the debug you will see that the sphere doesn't
> bounce off the triangle - it simply ghosts through it, steadily
> accelerating, untill the collision depth becomes close to the sphere
> radius, and then it hurtles off in the negative y direction at
> ridiculously high velocity.
>
> Collision settings are:
>             contact.surface.mode = dContactBounce;
>             contact.surface.bounce = 0.0;
>             contact.surface.bounce_vel = 0.001;
>
>             the world ERP is 0.8 and the world CFM is the default. the
> step size, out of desperation, is 0.001
>             I have tried a few settings for all of these and still get
> similar results.
>
> If I can get this working, and convert the triangle code to use ODE
> vector maths rather than my own libraries without too much hassle, I
> will be more than happy to contribute it!
>
> Oh yes - Linux, gcc, ode version 0.035
>
> Thankyou for any suggestions.
>
> This is the relevant part of the debug output from my code:
>
> ********************************
> * Just before the collision    *
> ********************************
>
> Before step:
>  position :  0.000000e+00 -2.999771e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
> After step:
>  position :  0.000000e+00 -3.000180e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
> Before step:
>  position :  0.000000e+00 -3.000180e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
> *** COLLISION ***
> Closest point in triangle to [  0.0000  -3.0002   0.0000]
>                           is [  0.0000  -4.0000   0.0000]
> distance = 0.999820
> Collision normal is [  0.0000   1.0000   0.0000]
> collision depth of 0.000180
> dCollide returned 1 contacts
> After step:
>  position :  0.000000e+00 -3.000589e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
> Before step:
>  position :  0.000000e+00 -3.000589e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
> *** COLLISION ***
> Closest point in triangle to [  0.0000  -3.0006   0.0000]
>                           is [  0.0000  -4.0000   0.0000]
> distance = 0.999411
> Collision normal is [  0.0000   1.0000   0.0000]
> collision depth of 0.000589
> dCollide returned 1 contacts
> After step:
>  position :  0.000000e+00 -3.001060e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
>
> ********************************
> * Skip a few steps to last one *
> ********************************
>
> Before step:
>  position :  0.000000e+00 -3.681070e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
> *** COLLISION ***
> Closest point in triangle to [  0.0000  -3.6811   0.0000]
>                           is [  0.0000  -4.0000   0.0000]
> distance = 0.318930
> Collision normal is [  0.0000   1.0000   0.0000]
> collision depth of 0.681070
> dCollide returned 1 contacts
> After step:
>  position :  0.000000e+00 -4.225925e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
> Before step:
>  position :  0.000000e+00 -4.225925e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
> After step:
>  position :  0.000000e+00 -4.770781e+00  0.000000e+00
>  vel      :  0.000000e+00  0.000000e+00  0.000000e+00
>  force    :  0.000000e+00  0.000000e+00  0.000000e+00
>
> ********************************
> * After the last collision     *
> ********************************
>
> --
>  - Andy
> mailto:andy@squint.clara.co.uk
> http://www.squint.clara.co.uk
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode