Instability at smaller scale

marcimatz
Posts: 34
Joined: Fri Sep 18, 2009 5:41 am

Instability at smaller scale

Post by marcimatz »

Hi,

I made a nice vehicle (tank-like, with several wheels for the caterpillars) that behaves as expected when at a scale of about 2x1.5x0.8 (cubic meters).
When I scale the vehicle down (adjusting all parameters accordingly), the vehicle starts becoming very shacky (starts jumping without any reasons, etc.). That happens from about a size of 0.5x0.375x0.2 (scaled 4 times down). I also tried to change parameters randomly (e.g. masses, inertias, restitution, friction, time step) but can't get the vehicle not to shake.

This happens also with loose bodies relatively small (e.g. a cylinder of diameter 4 cm and height of 4 cm)

What am I doing wrong, or how can I overcome my problem? This is very annoying since in future most vehicles will be of small size (under 0.5 meters) in my application.

Thanks
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Instability at smaller scale

Post by Erwin Coumans »

When using a box of .35x.35x0.05 the collision margin needs to be reduced, and a smaller timestep is required. A smaller timestep is necessary, because in one simulation frame, the object travels too far, relative to its dimension. When using 0.02 margin and an internal timestep of 1./240. things should be fairly stable:

Code: Select all

//decrease the collision margin for small objects
collisionShape->setMargin(0.02);
//use a smaller internal substep of 1./240., instead of the default of 1./60.
world->stepSimulation(deltaTimeInSeconds,5,1.f/240.f);
See this BasicDemo.zip example source code with and precompiled Win32 executable. If this doesn't help, please provide a reproduction case.
Thanks a lot,
Erwin
marcimatz
Posts: 34
Joined: Fri Sep 18, 2009 5:41 am

Re: Instability at smaller scale

Post by marcimatz »

Thanks Erwin!

It helped a little bit, but the vehicle is still shaking quite a bit. Escpecially when the vehicle's wheels collide with some obstacle, the wheels get shifted quite a lot relative to the body of the vehicle.

I tried scaling the model by a factor 5, 10 and 100, and there it works and behaves like a charm. I read a few times about scaling the whole world internally to get rid of specific problems, but never saw some concret "how to do it". But first, is this reasonable, and what other problems might I encounter?

Please correct me if I am wrong, following is how I see the thing:
1. Scale values from my application up before feeding them to Bullet
2. Scale down values from Bullet before feeding them to my application

The question is what values should by scaled and how. This is what I would do:
a) distances and dimensions: *scalingFactor
b) velocities: *scalingFactor
c) masses: *scalingFactor^3
d) mass-less inertias: *scalingFactor^2
e) forces: *scalingFactor^4
f) torques: *scalingFactor^5
g) angular velocities stay unchanged

Then I would of course apply -9.81*scalingFactor for the gravitation

Does that sound ok?
marcimatz
Posts: 34
Joined: Fri Sep 18, 2009 5:41 am

Re: Instability at smaller scale

Post by marcimatz »

I tested above world scaling and it works very nicely.
I also bumped into following document about scaling the world:

http://www.bulletphysics.com/mediawiki- ... _The_World

It seems to me that there was a X forgotten here:

"Scale all inertias by X if not computed by Bullet" --> I would say X*X

I also tried keeping the mass unscaled (keeping Y=1 instead of Y=X*X*X) while scaling the world and it also works nicely.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Instability at smaller scale

Post by sparkprime »

Yes I think you are right, this is a glaring error...