Joints rigidity

bonjovi
Posts: 35
Joined: Mon Jul 20, 2009 12:58 pm

Joints rigidity

Post by bonjovi »

Hi,

I'm testing joints accuracy from bullet vs ODE. I did a slider between 1 body (mass=1.1 Kg) and 1 static body.
I'm using fixed timestep: m_dynamicsWorld->stepSimulation( 0.01, 2, 0.01/2);

Using ODE, the body slides along axis and the joint does not produce any error.
With bullet, when body position grows (along slider axis) , it seems that the joint produces a big error according to the (anchor-bodypos) distance.

See attached file (ODE equilibrium, Bullet equilibrium).
rigidity.JPG
By replacing Slider joint by Generic6DOF does not change anything.

QUESTION 1: Is it possible to 'rigidify' the joint ?

QUESTION 2: I've implemented a regulated spring (not using the build-in Bullet springs).
The mathematical model shows that the equilibrium position is at position 2.0 along the slider axis.
With ODE, the equilibrium is exactly this position (+- 10e-3). With bullet, the body equilibrium position is 2.73 !!
I'm using _btrigidBody::applyForce at each timestep where force= -position*KP - Velocity*KD

Hoping someone can help me :)

Thank you
You do not have the required permissions to view the files attached to this post.
bonjovi
Posts: 35
Joined: Mon Jul 20, 2009 12:58 pm

Re: Joints rigidity

Post by bonjovi »

Re !

Just for saying that in my previously message i'm talking about 'static' body 2, in fact i wanted to say 'kinematic' body.

There is not rigidity problem using static body or dynamic body (but the spring equilibrium position that is not good on all case)

Thanks if you can help me !
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Joints rigidity

Post by Erwin Coumans »

Can you share the testbed for Bullet and ODE?

What constraint solver are you using for ODE: dWorldStep or dWorldQuickStep?

Thanks,
Erwin
bonjovi
Posts: 35
Joined: Mon Jul 20, 2009 12:58 pm

Re: Joints rigidity

Post by bonjovi »

Hi Erwin,

I'm using ODE solver method.

In fact, for Bullet, the problem aprear when i was using a kinematic body:

Code: Select all

_internalbody->setCollisionFlags( _internalbody->getCollisionFlags() |btCollisionObject::CF_KINEMATIC_OBJECT);
_internalbody->setActivationState(DISABLE_DEACTIVATION);
By changing the kinematic body by something like _internalbody->setMassProp(0); where setMassProp is a copy copy of
void btRigidBody::setMassProps(btScalar mass, const btVector3& inertia)

Code: Select all

//added function = setMassProps whithout re-calculating inertia
void btRigidBody::setMassProp(btScalar mass)
{
if (mass == btScalar(0.))
	{
	m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
	m_inverseMass = btScalar(0.);
	} 
else
	{
	m_collisionFlags &= (~btCollisionObject::CF_STATIC_OBJECT);
	m_inverseMass = btScalar(1.0) / mass;
	}
}
solves the problem : the joint have a good rigidity !!

Because i need to toggle the static state (every 20 or 30 seconds) , i ve created a btRigidBody::setMassProp that i can call every time i have to change the body state (dynamic->static->dynamic).

But (of course there is a 'but'), changing the body state just by using setMassProp seems to introduce an error : a dynamic body that is over the toggleled body never stabilises and accumulates energy that makes the object to move over (box on box). If the body, the one to become static, is created directly at simulation startup in the static state (mass=0), there is not problem of stabilisation.

Then, now, my new question is : what is the best method for toggle dynamic/static/dynamic body state ?

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

Re: Joints rigidity

Post by Erwin Coumans »

bonjovi wrote: Then, now, my new question is : what is the best method for toggle dynamic/static/dynamic body state ?
Thank you.
Don't modify the Bullet btRigidBody source code for this, but instead:
  • remove the rigid body from the world
  • change the mass and inertia using 'setMassProps' properly
    (use mass=0 and inertia = btVector3(0,0,0) for static/kinematic and positive mass and calculateLocalInertia for dynamic rigid bodies)
  • add the rigid body to the world
Hope this helps,
Erwin