I have a situation where I need to suspend a rigid body in the air. This rigid body is attached to another (larger) rigid body that is at rest by means of a horizontal btHingeConstraint. (e.g. The boom of an Excavator). The body is successfully lifted off the ground using the angular motor and a target velocity.
Once I have lifted the body I set the target velocity to zero, still using the same Impulse (very large).
However, the motor seems unable to keep the body in the air and it slowly drifts down.
Do you have any idea what is the problem and what I can do to prevent this?
The construction code is shown below:
Note: the limits are not the problem, I have double checked them.
Code: Select all
btCollisionShape* pShapeBody = new btBoxShape(btVector3(1,1,1));
m_collisionShapes.push_back(pShapeBody);
btTransform mBodyTrans;
mBodyTrans.setIdentity();
mBodyTrans.setOrigin(btVector3(0,0,0));
btRigidBody* pBody = localCreateRigidBody(1000,mBodyTrans, pShapeBody);
pBody->setActivationState(DISABLE_DEACTIVATION);
btCollisionShape* pShapeBoom = new btBoxShape(btVector3(0.7, 0.7, 0.7));
m_collisionShapes.push_back(pShapeBoom);
btTransform mBoomTrans;
mBoomTrans.setIdentity();
mBoomTrans.setOrigin(btVector3(3,0,0));
btRigidBody* pBoom = localCreateRigidBody(200,mBoomTrans, pShapeBoom);
pBoom->setActivationState(DISABLE_DEACTIVATION);
pBoomHinge = new btHingeConstraint(*pBody, *pBoom, btVector3(1,0,0), btVector3(-2,0,0), btVector3(0,0,1), btVector3(0,0,1));
pBoomHinge->setLimit(-1.5, 0);
m_dynamicsWorld->addConstraint(pBoomHinge);
Code: Select all
if (up)
{
pBoomHinge->enableAngularMotor(true, -0.1, 1000);
} else if (down)
{
pBoomHinge->enableAngularMotor(true, 0.1, 1000);
} else {
pBoomHinge->enableAngularMotor(true, 0.0, 100000);
}