[ODE] continuous forces w/ constant step size

Bob Dowland Bob.Dowland at blue52.co.uk
Fri Sep 17 10:28:43 MST 2004


F is applicable over time slice = step. This corresponds to desired change in momentum, I = F.step. Take step = k.maxStep, say (k > 1 if step > maxStep). Then,

I = F.step = k.F.maxStep

is the full (desired) impulse over timeslice = step. 

By applying F just the once, the impulse you actually get is

I* = F.maxStep = (F/k)step = F*.step, where F* = F/k and k > 1 => F* < F 

ie I* < I ie vel change is 1/k what it should be (per second).


What's wrong with just applying F before each physics substep?

:)

Bob.

> -----Original Message-----
> From: Tyler Streeter [mailto:tylerstreeter at yahoo.com]
> Sent: 16 September 2004 22:19
> To: ode at q12.org
> Subject: [ODE] continuous forces w/ constant step size
> 
> 
> So far I have been using the following type of loop in
> my simulation:
> 
> while(1)
> {
>    getUserInput();
>    addForcesToObjects();
>    dt = getElapsedTime();
>    physics.step(dt);
>    redraw();
> }
> ...
> void PhysicsEngine::step(dReal dt)
> {
>    timeAccumulation += dt;
> 
>    while (dt >= STEP_SIZE)
>    {
>       //step ODE ahead by a constant value
>       ODESystem.step(STEP_SIZE);
>    }
> }
> 
> This works well to make things move the same on
> different machines (no slow motion on slower machines)
> and to yield repeatable results (due to the constant
> step size).  Additionally, it's nice to have this
> iterative stepping loop hidden within the above "step"
> function so the application can just pass in some
> arbitrary dt.
> 
> Here's the problem with it: The continuously-applied
> forces and the input only get updated once per frame,
> not once per time step, which yields different results
> depending on the frame rate.  These things need to get
> applied per time step to get consistent results.
> 
> Assuming I want to keep the iterative stepping
> function, here's a possible solution: calculate the dt
> since the last frame, call some addForce wrapper
> function that takes a force vector and a dt value,
> update physics, redraw..  This addForce function
> creates a "force event" that gets added to a queue,
> storing the force vector and the amount of time it
> should be applied.  Whenever physics gets stepped
> ahead, each force event's time left gets decremented
> until eventually they stop getting applied.  This
> allows forces to be applied for some time into the
> future which is helpful since you don't know exactly
> how long it'll be until the next frame comes around.
> 
> Any comments?
> 
> Tyler
> 
> 
> 	
> 		
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - 100MB free storage!
> http://promotions.yahoo.com/new_mail 
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
> 



More information about the ODE mailing list