friction and restitution

Stefan Rilling
Posts: 4
Joined: Wed Aug 08, 2007 2:18 pm

friction and restitution

Post by Stefan Rilling »

Hello,

i am trying to set friction and restitution factors in a very basic app.
The relevant code is:

Code: Select all

btRigidBody* ground = localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
ground->setRestitution(0.0);

btRigidBody* sphere = localCreateRigidBody(btScalar(10.0),trans,sphereShape);
sphere->setRestitution(0.0);
So if the sphere falls on the (static) ground, there shouldn't be any bounce of the sphere. Unfortunately, there is... So what am i doing wrong? are there any other things to consider to get friction / restitution working?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

There is a bit of restitution due to penetration depth correction: the positional correction adds some velocity. If you make the timestep smaller, this effect should be smaller.

In the future I plan on separating the penetration correction from the velocity correction, which should completely get rid of this unwanted restitution. Note that several other system suffer from the same problem (most notably open dynamics engine/ODE). This has been discussed in other sections of the forum, in case you are interested in the technical background.

Thanks!
Erwin
Stefan Rilling
Posts: 4
Joined: Wed Aug 08, 2007 2:18 pm

Post by Stefan Rilling »

Erwin Coumans wrote:There is a bit of restitution due to penetration depth correction: the positional correction adds some velocity. If you make the timestep smaller, this effect should be smaller.

In the future I plan on separating the penetration correction from the velocity correction, which should completely get rid of this unwanted restitution. Note that several other system suffer from the same problem (most notably open dynamics engine/ODE). This has been discussed in other sections of the forum, in case you are interested in the technical background.

Thanks!
Erwin
Hi,
thanks for the fast reply. My problem is that the restitution factors i set don't seem to have any effect. If i do

Code: Select all

btRigidBody* ground = localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
ground->setRestitution(1.0);

//two spheres seperated on the x-axis, same height above ground
btRigidBody* sphere0 = localCreateRigidBody(btScalar(10.0), trans0, sphereShape);
ground->setRestitution(1.0);

btRigidBody* sphere1 = localCreateRigidBody(btScalar(10.0), trans1, sphereShape);
ground->setRestitution(0.0);
the two spheres behave exactly similar after impact. So i think i am doing something terribly wrong here...
Stefan Rilling
Posts: 4
Joined: Wed Aug 08, 2007 2:18 pm

Post by Stefan Rilling »

Recently, I discovered another strange behaviour: My test scene simply consists of a box rotated 45 degrees around local z-axis, placed 10.0 meters above the ground.

Code: Select all

//...

m_dynamicsWorld->setGravity(btVector3(0,-9.81,0)); //<-- HERE IS THE PROBLEM!

//...
btRigidBody* ground = localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
ground->setRestitution(0.5);
ground->setFriction(0.5);

//...
btRigidBody* theMagicBox = localCreateRigidBody(btScalar(10.0), trans, boxShape);
theMagicBox->setFriction(0.5);
theMagicBox->setRestitution(0.5);
If I set the gravity vector to -9.81 in y direction, I don't get any bounciness within this setting. If I set gravity to

Code: Select all

btVector3(0, -10, 0)
I do get bouncing, but I still can't adjust its amount. Strange, isn't it?
Osami
Posts: 5
Joined: Thu Jan 17, 2008 8:51 pm

Re: friction and restitution

Post by Osami »

Im having the same issue as the above using the newest (2.66) sdk anyone know why?