[ODE] ODE uses forces that are twice as large as specified.

Chris Ledwith cledwith at d-a-s.com
Wed Jan 12 15:11:04 MST 2005


> It's simply a body of mass 1.0 that's initially located at the origin.
> The gravity is set to g=(0,0,-1) and one simulation step is done with a
> time step of 1/25 = 0.04. After that the position and linear velocity of
> the body are printed.
>
> The result after running the script is this:
>
> dt: 0.04
> pos = (0.000000, 0.000000, -0.001600)
> vel = (0.000000, 0.000000, -0.040000)
>
> The velocity is v=g*dt which is -0.04 for the z component, so that's
> correct. But the position should be p=0.5*g*dt^2 which should yield a z
> component of -0.0008 but the z component in the ODE simulation is twice
> as large. So it's as if the position was updated with a gravity of -2
> instead of -1 and the position is inconsistent with the velocity.
>
> So what's the mistake here? Is it me or is it really a bug in ODE?
>

I think you will find that if you provide a smaller stepsize (say 100 Hz
instead of the 25 Hz you have used here, you will get a result closer to
what you'd expect. It's better to step physics at a faster rate than
you're drawing to the screen. Say that 0.04 seconds have passed since the
last frame. Instead of passing this entire timestep to ODE, break it up
into 0.01 second slices and step ODE until the 0.04 time is all used up
(so your physics loop would run 4 times for this particular frame).

-C




More information about the ODE mailing list