Bug in btMultiBodyJointLimitConstraint::createConstraintRows

freezics
Posts: 5
Joined: Tue Nov 05, 2013 3:05 am

Bug in btMultiBodyJointLimitConstraint::createConstraintRows

Post by freezics »

I think there is a bug in how the penetration for multibody link limits iscalculated:


The original code in btMultiBodyJointLimitConstraint::createConstraintRows:

Code: Select all

// row 0: the lower bound
setPosition(0, m_bodyA->getJointPos(m_linkA) - m_lowerBound);
 // row 1: the upper bound
setPosition(1, m_upperBound - m_bodyA->getJointPos(m_linkA));
...
if (penetration>0)
{
...
should probably be replaced by something like:

Code: Select all

// row 0: the lower bound
btScalar pos0 = m_bodyA->getJointPos(m_linkA) - m_lowerBound;
if (pos0>0) pos0 = 0.f;
setPosition(0, pos0);
// row 1: the upper bound
btScalar pos1 = m_upperBound - m_bodyA->getJointPos(m_linkA);
if (pos1>0) pos1 = 0.f;
setPosition(1, pos1);
...
if (penetration<0)
{
...
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bug in btMultiBodyJointLimitConstraint::createConstraint

Post by Erwin Coumans »

No, it is not a bug. Have you tried running the Bullet/Demos/FeatherstoneMultiBodyDemo?

There is an example of using the joint limit, on the fixed multibody. The limits in that demo allow for some free motion.
Once you clamp the position/penetration of the limit, it breaks the demo.

The "positive" error gives the constraint freedom, until it reaches the limit.
freezics
Posts: 5
Joined: Tue Nov 05, 2013 3:05 am

Re: Bug in btMultiBodyJointLimitConstraint::createConstraint

Post by freezics »

my bad. I missed the fact that there were two types of errors, the velocity error (which is probably like a damper) and the positional error.

Then I still need to figure out why my prismatic joint snaps to its range limit at the start of simulation. I'm pretty sure the bodies' positions are correctly initialized not to cause a positional error.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bug in btMultiBodyJointLimitConstraint::createConstraint

Post by Erwin Coumans »

Did you disable collisions between links?

Can you create a reproduction case in the default FeatherstoneMultiBodyDemo?

There could be an issue, the code is new and not very well tested.
Thanks,
Erwin