[ODE] Resetting a moving vehicle

Jon Watte hplus-ode at mindcontrol.org
Wed Oct 13 09:34:17 MST 2004


There are three things that can kill you:

1) stored velocities (angular or linear) can jerk you around
2) joint constraints can induce explosive forces if violated
3) penetrations at the "restoration" point can induce significant    energy

To solve 1, you simply dBodySetLinearVelocity() and dBodySetAngularVelocity() to zero.

To solve 2, you have to use a "blueprint" of what bodies goes where, in what orientations, and with what joints. To create your object, first create the bodies, attach the geoms, and then call AssembleFromBlueprint(), which will move/orient the bodies, and then re-set joint constraints (remembering the low/high ordering problem), and then attach the joints. When you want to re-set the vehicle, detach all bodies from their joints (without destroying the joints), and call AssembleFromBlueprint() again. It certainly helps if your Assemble() function takes an optional global translation/orientation to apply after all the local offsets/rotations :-)
Note that IF your joints and bodies are all still sane, and you kill the energy (as in 1), then it "ought" to work to simply offset and translate all the bodies. You have to make sure you first rotate all the bodies AROUND THE CENTER OF THE VEHICLE, and then translate to where you want to go -- if you just set the rotation of each body, when the car is upside-down, that will end up with wheels sitting on the wrong side of the body, and your joints will make you very unhappy.

To solve 3, I ray-cast down from 5 meters above the intended recovery point, and find the surface normal and distance. Then I lift the vehicle up such that it won't penetrate the assumed plane described by that normal (using bounding-box test). Then I lift it up an extra two meters, just for paranoia, which leads to a nice drop straight onto the recovery position.


I put this text on http://q12.org/cgi-bin/wiki.pl?TipsAndTricks but couldn't figure out how to do nice headings. !!, ==, and <h2> didn't work.

Cheers,

			/ h+



-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org]On Behalf Of Lukas
Henschke
Sent: Wednesday, October 13, 2004 8:34 AM
To: ode
Subject: [ODE] Resetting a moving vehicle


I have a serious problem with our racing game. When the car lies upside down or goes off the track it should be automatically reset to the race track.
First I tried to just set the new position to the single objects (the car and its wheels) which ended in desaster because some velocities or forces were still stored and caused the vehicle to "explode". I tried to set each single velocity and force to null, before and after the resetting, but nothing changed.
As I could not find the reason I ended up detaching all joints, destroying all elements and rebuilding the whole car on the new position but this worked only for certain angles.
My last try was to hide the car and move it slowly to the wanted position but even this didn´t work. At a certain angle the car flipped and started to "explode" again.

Has anyone experience with this issue ? Does anyone know a way how to realy set all velocities and forces to null ? I am missing a function like FreeObjectFromAllForces() or so to be able to set it to an arbitrary position/rotation and kind of start the simulation for this object from the beginning of the next frame.

thanks for any hints
Lukas Henschke

_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode




More information about the ODE mailing list