btMultiBodyJointLimitConstraint issues

Post Reply
StriderH
Posts: 4
Joined: Fri Sep 10, 2021 2:54 pm

btMultiBodyJointLimitConstraint issues

Post by StriderH »

I'm having trouble using a btMultiBodyJointLimitConstraint, as I'm seeing the revolute joint violate the upper and lower limits often. Does anybody know how to make the joint respect the constraint in these two scenarios?

Scenario A
1) I start with the InvertedPendulumPDControl example.
2) I comment out the m_multiBody->addJointTorque line, so the pendulum isn't being moved.
3) I (theoretically) constrain the pendulum to be pointed to the side with:

Code: Select all

m_dynamicsWorld->addMultiBodyConstraint(new btMultiBodyJointLimitConstraint(m_multiBody, 0, btRadians(80.f), btRadians(90.f)));
If I run the program, the pendulum happily sits outside the 80-90 limit. If I click it with the mouse and move it into the 80-90 range, then it'll respect the constraint, but before that it doesn't. Is there a way to make the limit constraint come into effect immediately?

Scenario B
I change the base to be floating, but with a btMultiBodyFixedConstraint (so I can move it around later):

Code: Select all

m_multiBody = createInvertedPendulumMultiBody(m_dynamicsWorld, m_guiHelper, baseWorldTrans, false);
m_dynamicsWorld->addMultiBodyConstraint(new btMultiBodyFixedConstraint(m_multiBody, -1, nullptr, btVector3(0, 0, 0), btVector3(1, 2, 3), btMatrix3x3::getIdentity(), btMatrix3x3::getIdentity()));
And again, I try limiting the pendulum angle:

Code: Select all

m_dynamicsWorld->addMultiBodyConstraint(new btMultiBodyJointLimitConstraint(m_multiBody, 0, btRadians(80.f), btRadians(90.f)));
In this case, the revolute limit constraint on the pendulum doesn't work at all, the joint can freely spin a full 360 degrees, as if the limit constraint wasn't even added. Is there some rule forbidding the use of btMultiBodyFixedConstraint and btMultiBodyJointLimitConstraint on the same multibody?
Post Reply