i use a series of hingeConstraints to represent a robot. My problem is that the base hinge, that is the hinge that fastens to a static body, tends to drift quite far...(see illustration). Do i have to do something specific when attaching to a static body?
This is how i create the constraints.
Code: Select all
Transform3D<> wTchild = Kinematics::WorldTframe(joint,state);
Transform3D<> wTparent = Kinematics::WorldTframe(parentFrame,state);
btTransform frameInA, frameInB;
frameInA.setIdentity(); // the joint allready use z-axis for rotation
frameInB = makeBtTransform( inverse(wTparent) * wTchild ); // calculate transform from parent to joint
btChild->setActivationState(DISABLE_DEACTIVATION);
btParent->setActivationState(DISABLE_DEACTIVATION);
btHingeConstraint *hinge = new btHingeConstraint(*btChild, *btParent, frameInA, frameInB);
hinge->setLimit( joint->getBounds().first, joint->getBounds().second );
hinge->enableAngularMotor(true, 0.0, 10);
m_dynamicsWorld->addConstraint(hinge, true);
_jointToConstraintMap[joint] = hinge;
constraints.push_back(hinge);