Stiffness of btGeneric6DofConstraint

Post Reply
Otz
Posts: 8
Joined: Wed Jun 27, 2012 9:13 am

Stiffness of btGeneric6DofConstraint

Post by Otz »

Hi there,

I am working on a humanoid robot physics simulator and I use btGeneric6DofConstraints for all the joints of the robot.
Please look at this little screen capture: http://www.youtube.com/watch?v=6ggX2nnU-CQ
Here you can see my problem with the constraints. They aren't stiff.

Can somebody help me with this problem?

The ERP/CFM - Config:

Code: Select all

angularCFM : 0.0000001 
angularERP  : 0.9
linear CFM   : 0.0000001
angularERP  : 0.3
Here some Code:

Code: Select all

btGeneric6DofConstraint * Robot::addbtGeneric6DofConstraint (RobotPart *partA, RobotPart *partB,btVector3 pointInA,btVector3 pointInB, bool useLinearReferenceFrameA){

    pointInA.setValue((btScalar)pointInA.x()*(btScalar)scale.x(),(btScalar)pointInA.y()*(btScalar)scale.y(),(btScalar)pointInA.z()*(btScalar)scale.z());
    pointInB.setValue((btScalar)pointInB.x()*(btScalar)scale.x(),(btScalar)pointInB.y()*(btScalar)scale.y(),(btScalar)pointInB.z()*(btScalar)scale.z());

    btTransform tInA;
    tInA.setIdentity();
    tInA.setOrigin( pointInA );
    btTransform tInB;
    tInB.setIdentity();
    tInB.setOrigin( pointInB );
    btGeneric6DofConstraint *cons = new btGeneric6DofConstraint(*partA->getRigidBody(),*partB->getRigidBody(),tInA,tInB,false);


    partA->getRigidBody()->setActivationState(DISABLE_DEACTIVATION);
    partB->getRigidBody()->setActivationState(DISABLE_DEACTIVATION);

    cons->enableFeedback(true);

    btRotationalLimitMotor *motorX = cons->getRotationalLimitMotor(0);
    btRotationalLimitMotor *motorY = cons->getRotationalLimitMotor(1);
    btRotationalLimitMotor *motorZ = cons->getRotationalLimitMotor(2);
    motorX->m_normalCFM = motorY->m_normalCFM = motorZ->m_normalCFM = 0.0000000;
    motorX->m_stopCFM = motorY->m_stopCFM = motorZ->m_stopCFM = 0.0000000;
    motorX->m_bounce = motorY->m_bounce = motorZ->m_bounce = 0.0000000;
    motorX->m_targetVelocity = motorY->m_targetVelocity = motorZ->m_targetVelocity =1.0;
    motorX->m_maxMotorForce = motorY->m_maxMotorForce  = motorZ->m_maxMotorForce  =100.0;
    motorX->m_maxLimitForce = motorY->m_maxLimitForce  = motorZ->m_maxLimitForce  =10000.0;
    motorX->m_enableMotor = motorY->m_enableMotor = motorZ->m_enableMotor = true;

    cons->setAngularLowerLimit(btVector3(0,0,0));
    cons->setLinearLowerLimit(btVector3(0,0,0));
    cons->setAngularUpperLimit(btVector3(0,0,0));
    cons->setLinearLowerLimit(btVector3(0,0,0));

    dynamicsWorld->addConstraint(cons,true); // true = allow collisions with linked objects

    allConstraints.push_back(cons);

    return cons;
}
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Stiffness of btGeneric6DofConstraint

Post by Flix »

Otz wrote:Here you can see my problem with the constraints. They aren't stiff.Can somebody help me with this problem?
I have found some improvements by using a much higher mass (something like: 10x->1000x factor) when calculating the local inertia of the rigid bodies (I've already described it in this post: http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=7863), but I'm not sure this method is useful in all the simulations: expecially in yours, because you probably need a bigger stiffness if you don't add some additional constraints to keep the robot from falling (like I did).
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Stiffness of btGeneric6DofConstraint

Post by Erwin Coumans »

The easiest way to improve stifness is to increase the number of constraint solver iterations (can be done per constraint):

Code: Select all

	dof6->setOverrideNumSolverIterations(100);
also you can use a small INTERNAL simulation substep. For example run at 1000 Hertz:

btScalar simulationSubStep = 1.f/1000.f;

Code: Select all

world->stepSimulation(actualDeltaTime, 100, simulationSubStep);
Hope this helps,
Erwin
Post Reply