Simple newtonian simulations giving wrong results

Post Reply
TomLandry
Posts: 3
Joined: Mon Mar 15, 2010 1:52 pm

Simple newtonian simulations giving wrong results

Post by TomLandry » Mon Mar 15, 2010 3:34 pm

Hi !

I'm experimenting with Bullet to determine if it is the tool I need for a physics simulation project. I plan to move around a rigid body on a plane, with a few constraints, mainly the friction and hinge joints, and log its instant speeds.

Before considering a "complex" scenario, I went to validate some basic newtonian equations. First, I want to apply a constant force to the body and mesure its speed after 5 seconds. Second, I want to measure the effect of friction on the final speed of the body, again after 5 seconds. I actually piggyback on the clientMoveAndDisplay callback to apply forces, display the linear speeds and verify my end condition.

1) The body's mass is 100kg. The friction for both the plane and the body (a simple box, roughly the size of an human) is set to 0. Its initial speed is set to (10, 0 0). A central force of (100, 0, 0) is applied (at each step), so the expected acceleration is 1.0 (F=ma). After 5 seconds, I expect the speed to be 15 unit per second on the X axis (V=V0+at). The simulation indicates 10.7, which is far from the count.

2) Same mass, same initial speed. Friction set at 1 for the plane and 0.01 for the body, resulting in a coefficient U of 0.01. The resulting force is therefore 9.8 (F=mgU). Let's round it a 10. No other forces are applied. I would expect the body to cruise at about 9.5 after 5 seconds (F=ma, a = 0.1, V=V0-at). Simulation gives me 9.93.

Are my physics rusty ? Or have I overlooked something in my experimental setup ?

Thanks

Tom

DannyChapman
Posts: 85
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: Simple newtonian simulations giving wrong results

Post by DannyChapman » Tue Mar 16, 2010 10:14 am

Most physics engines optionally add some simple damping to aid stability. I've not checked, but it may be that Bullet has this non-zero by default.

TomLandry
Posts: 3
Joined: Mon Mar 15, 2010 1:52 pm

Re: Simple newtonian simulations giving wrong results

Post by TomLandry » Tue Mar 16, 2010 2:22 pm

Hi Danny,
Thanks for your response. I've just checked, and with restitution and damping set to 0, for both the plane and the body, I obtain the same result.
Tom

TomLandry
Posts: 3
Joined: Mon Mar 15, 2010 1:52 pm

Re: Simple newtonian simulations giving wrong results

Post by TomLandry » Mon Apr 12, 2010 2:36 pm

So any update on this ? Can I rely on Bullet for accurate simulations, according to Newtonian physics ?

Tom

ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway
Contact:

Re: Simple newtonian simulations giving wrong results

Post by ola » Mon Apr 12, 2010 5:57 pm

Since your problem sounds to be 2-dimensional, I think you should simplify things a bit to have more control over the results. You can constrain linear movement to two linear axes and one rotational axis, disable the gravity, and then calculate your own friction forces. See the Box2d demo for some examples.

Bullet uses numerical integration, and the method is called "symplectic euler" (http://en.wikipedia.org/wiki/Semi-implicit_Euler_method). This is a trade-off between stability, simplicity and accuracy that works well for most cases. So take a look at it and consider if it's good enough for your needs. You can try to make the step size smaller and see if it gives you better results too.

I recommend you to read the source code of at least btDiscreteDynamicsWorld.cpp to get an idea of what is going on in there.

Cheers,
Ola

Post Reply