[ODE] Applying forces outside the phys loop vs applying them
hplus-ode at mindcontrol.org
Mon Nov 22 10:34:56 MST 2004
> My question is, has anyone else found "external" force functions like
> this particularly useful? Aside from debug pushing things around, I'm
Yes. Use a control system, and express the "goals" to the
external system in terms of goals, not specific forces, like
Each frame, calculate where your body will be N frames from now,
by reading the velocity and position, and forward integrating.
Then calculate what velocity you would need to get to where you
want to go, in that same N frames.
Then calculate the force that will change your velocity from what
it is, to what you want it to be, in a single step.
Then, limit this force to your maximum allowable force.
Then, apply this force to your body.
You can do the same thing for torque to control orientation.
A good number for N is usually in the 3-10 range.
As for adding specific forces and torques, that has to be done at
the same rate as the simulation. If you're rendering slower, then
you have to gather input more seldom, and then persist the input
through each simulation loop (unless it's one-shot input); if the
input is based on location/velocity, you have to re-calculate it
each simulation loop, as it's part of the simulation, not part of
your external control/render loop. No good way around that.
More information about the ODE