Cant make axes free in 6dof constraint

Bilal
Posts: 8
Joined: Tue Nov 13, 2007 2:30 pm

Cant make axes free in 6dof constraint

Post by Bilal »

Hi...

I was trying to make a joint using generic6dof constraint between two dynamic bodies, but cant get it done.
All axes seem to be locked. I have tried many combinations with SetLimit but none of them worked. Both bodies seem to be joined together.

Here is my code:

Code: Select all

	btTransform id; id.setIdentity();

        wheel1Constraint = new btGeneric6DofConstraint(
            *axleBody->getBulletRigidBody (),
            *defaultBody->getBulletRigidBody (), 
            frameInB,
            id);
		wheel1Constraint->setLinearLowerLimit(btVector3(0,0,0));
		wheel1Constraint->setLinearUpperLimit(btVector3(0,0,0));
		
		wheel1Constraint->setAngularLowerLimit(btVector3(0,10,0));
		wheel1Constraint->setAngularUpperLimit(btVector3(1,1,0));
		mWorld->getBulletDynamicsWorld()->addConstraint(wheel1Constraint);
getBulletRigidBody() is used because I am using OgreBullet but I dont think that the problem is there
momoreda
Posts: 25
Joined: Mon Oct 08, 2007 2:09 pm
Location: France

Re: Cant make axes free in 6dof constraint

Post by momoreda »

Hello !

Three cases possible:
- Lowerlimit == Upperlimit -> the axis is locked.
- Lowerlimit > Upperlimit -> the axis is free
- Lowerlimit < Upperlimit -> the axis it limited in that range

hope this helps
Bilal
Posts: 8
Joined: Tue Nov 13, 2007 2:30 pm

Re: Cant make axes free in 6dof constraint

Post by Bilal »

that means that in my code, all linear and one angular axes should be locked.

One angular axes should be free and one should be free with some limits..

But when I run the code, all axes seem to be locked!!!!!!!

I dont know what is it that I am doing wrong.
Bilal
Posts: 8
Joined: Tue Nov 13, 2007 2:30 pm

Re: Cant make axes free in 6dof constraint

Post by Bilal »

It should have been the simplest of tasks......and I am stuck here so bad!!

Please help me......anyone........This problem is killing me!!!!!!
momoreda
Posts: 25
Joined: Mon Oct 08, 2007 2:09 pm
Location: France

Re: Cant make axes free in 6dof constraint

Post by momoreda »

I will give you an example and I think you are going to understand. There are two objects if you want to :

Block it :
localA.setIdentity(); localB.setIdentity();
localA.setOrigin(btVector3(btScalar(0), btScalar(0.), btScalar(0)));
localB.setOrigin(btVector3(btScalar(0.), btScalar(0), btScalar(0.)));
Fix = new btGeneric6DofConstraint(*m_bodies[Body1], *m_bodies[Body2], localA, localB, true);
Fix->setLinearLowerLimit(btVector3(0,0,0));
Fix->setLinearUpperLimit(btVector3(0,0,0));
Fix->setAngularLowerLimit(btVector3(0,0,0));
Fix->setAngularUpperLimit(btVector3(0,0,0));
m_joints[JOINT] = Fix;
m_ownerWorld->addConstraint(m_joints[JOINT], true);


Translation along the axis x :
localA.setIdentity(); localB.setIdentity();
localA.setOrigin(btVector3(btScalar(0.), btScalar(0), btScalar(0.)));
localB.setOrigin(btVector3(btScalar(0.), btScalar(0.), btScalar(0.)));
slider = new btGeneric6DofConstraint(*m_bodies[Body1], *m_bodies[Body2], localA, localB, true);
//Specify the limit of translation of the two rigidbodies
btVector3 lowerSliderLimit = btVector3(0.,-0.4,0.);
btVector3 hiSliderLimit = btVector3(0.,0.3,0.);
/*
Three cases possible:
- Lowerlimit == Upperlimit -> axis is locked.
- Lowerlimit > Upperlimit -> axis is free
- Lowerlimit < Upperlimit -> axis it limited in that range
*/
slider->setLinearLowerLimit(lowerSliderLimit1);
slider->setLinearUpperLimit(hiSliderLimit1);
//Course of Slider = hiSliderLimit-lowerSliderLimit
slider->setAngularLowerLimit(btVector3(0,0,0));
slider->setAngularUpperLimit(btVector3(0,0,0));
m_joints[JOINT] = slider;
m_ownerWorld->addConstraint(m_joints[JOINT], true);


To understand better try to see the Demo Ragdoll in BULLET and try to change the settings and see what happen.

I hope that it will help you


M