Page 1 of 1

Stiffness of btGeneric6DofConstraint

Posted: Wed Sep 05, 2012 11:48 am
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;
}

Re: Stiffness of btGeneric6DofConstraint

Posted: Thu Sep 06, 2012 10:14 am
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).

Re: Stiffness of btGeneric6DofConstraint

Posted: Fri Sep 14, 2012 6:37 pm
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