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

Matthias Baas baas at ira.uka.de
Wed Jan 12 11:55:30 MST 2005

```Hi,

it seems there's a bug in ODE that makes position updates behave as if
every force was twice as large as it actually was.

Here is a simple example that shows my problem (it's written in Python,
but it should be straightforward to translate it to C):

###############################################################
import ode

# Create a world object
world = ode.World()
world.setGravity( (0,0,-1) )

# Create a body inside the world
body = ode.Body(world)
M = ode.Mass()
M.setSphere(1000.0, 0.1)
M.mass = 1.0
body.setMass(M)
body.setPosition( (0,0,0) )

# Do one simulation step
dt = 1.0/25.0
print "dt:",dt
world.step(dt)

# Print the current position and velocity of the body
print "pos = (%f, %f, %f)"%body.getPosition()
print "vel = (%f, %f, %f)"%body.getLinearVel()
###############################################################

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?

- Matthias -
```