[ODE] Simulations running in real time?

bram at sara.nl bram at sara.nl
Tue Mar 29 20:16:59 MST 2005


Chris,

The ode timing can be simple, if you understand that:

- for stable quickstep, delta-t should be small enough,
  and QuickStepNumIters should be high enough.

- if you measure your delta-t, and this gets large, you
  risc unstable behaviour.

What I use is:

- measure dt,
- if dt > 1/60 sec, then do multiple simulation steps for each
  OpenGL draw scene.
  if it is smaller, you can do it in a single quickstep from ode.

For determining the nr of ODE steps I take in my mainloop, I use
ceilf()

In code:

  ...
  int timesteps = (int) ceilf(dt / (1.0/60.0));
  float stepsz = dt /  timesteps;

  for (int i=0; i<timesteps; i++)
  {
    dSpaceCollide (bigspace, 0, &near_callback);
    dWorldQuickStep (world, stepsz);
    dJointGroupEmpty (contactgroup);
  }
  // Draw your world.

This works just fine for me, because: If I run this on a
machine with very slow OpenGL, framerate drops, dt gets
high, so for each drawing stage, I do multiple simulation
stages.
If I run it on fast hardware: dt is small, and I always
do 1 sim step for each draw step.

At first, I tried increasing dWorldSetQuickStepNumIterations
if dt was high, but this is not enough! High dt's need
multiple intersection tests per draw-stage.

  bram

> In this example what is totalTime and deltaTime.
>
> deltaTime is this the time taken for the simLoop method to be run ?
>
> totalTime is defined as what.
>
> Sorry im a little lost on which is which.
>
> Cheers
>
> Chris
>
> ----- Original Message -----
> From: "Megan Fox" <shalinor at gmail.com>
> To: "Hampus Soderstrom" <hampus at sxp.se>
> Cc: <ode at q12.org>
> Sent: Monday, March 28, 2005 6:25 PM
> Subject: Re: [ODE] Simulations running in real time?
>
>
>> Just use code something like this:
>>
>>    // Make sure time is accrued properly for the phys step count
>>    this->totalTime += deltaTime;
>>
>>    // Then advance the world up to present time
>>    unsigned int iters = 0;
>>    while(this->totalTime > PHYS_STEPSIZE)
>>    {
>>         // ... entity processing
>>
>>        nOpende::JointGroupEmpty(this->physContactJointGroupID);
>>        nOpende::SpaceCollide(this->physColSpaceID, this,
>> this->PhysCollisionCallback);
>>
>>        nOpende::WorldQuickStep(this->physWorldID, PHYS_STEPSIZE);
>>
>>        this->totalTime -= PHYS_STEPSIZE;
>>
>>        iters++;
>>    }
>>
>>
>> Very simple.  It runs ODE in real-time with a fixed timestep, without
>> loosing those fractions of a timestep you'll drop if you're just doing
>> "if deltatime > X"
>>
>> -Megan Fox
>>
>> On Mon, 28 Mar 2005 22:45:21 +0700, Hampus Soderstrom <hampus at sxp.se>
>> wrote:
>>> You could also lock he framerate to 60 pfs or something. On a computer
>>> that is too slow and can't keep up with the framerate you selected it
>>> will run slower though.
>>>
>>> 2005-03-28 kl. 20.28 skrev George Birbilis:
>>>
>>> > use multiple threads
>>> > see a paper at the Novodex website (now called Ageia or something),
>>> > search for Novodex SDK papers and at see the PDF about
>>> multithreading.
>>> > You can apply similar technique to ODE I suppose
>>> >
>>> > -----
>>> > George Birbilis (birbilis at kagi.com)
>>> > Microsoft Most Valuable Professional
>>> > MVP J# for 2004 & 2005
>>> > http://www.kagi.com/birbilis
>>> > --------------
>>> > ----- Original Message ----- From: "Chris Royce"
>>> <croyce at ntlworld.com>
>>> > To: "ode" <ode at q12.org>
>>> > Sent: Monday, March 28, 2005 4:10 PM
>>> > Subject: [ODE] Simulations running in real time?
>>> >
>>> >
>>> > Hello there I'm trying to get my simulation to run in real time,
>>> >
>>> > Basically the problem I'm having at the moment is that the simulation
>>> > is running at different speeds on different computers. I'm working in
>>> > C++ and using the drawStuff interface.
>>> >
>>> > I'm also noticing that by changing the dWorldStep value the motion
>>> > varies quite considerably, whereas I'd expected to run simply faster
>>> > or slower ?
>>> >
>>> > Thanks for any advice
>>> >
>>> > Chris
>>> >
>>> >
>>> > -----------------------------------------------------------------------
>>> > ---------
>>> >
>>> >
>>> >> _______________________________________________
>>> >> ODE mailing list
>>> >> ODE at q12.org
>>> >> http://q12.org/mailman/listinfo/ode
>>> >
>>> > _______________________________________________
>>> > ODE mailing list
>>> > ODE at q12.org
>>> > http://q12.org/mailman/listinfo/ode
>>> >
>>>
>>> _______________________________________________
>>> ODE mailing list
>>> ODE at q12.org
>>> http://q12.org/mailman/listinfo/ode
>>>
>> _______________________________________________
>> ODE mailing list
>> ODE at q12.org
>> http://q12.org/mailman/listinfo/ode
>>
>
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>



More information about the ODE mailing list