Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert in multiply2_p8r #333

Closed
erwincoumans opened this issue Feb 27, 2015 · 3 comments
Closed

Assert in multiply2_p8r #333

erwincoumans opened this issue Feb 27, 2015 · 3 comments

Comments

@erwincoumans
Copy link
Member

See description here:
http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=10413

I managed to avoid the assert by enabling the motors before the first step is made.

Apparently a btGeneric6DofConstraint has its m_numConstraintRows by default set to 0 but m_numConstraintRows is increased by 1 for every linear limit that needs to apply a force or angular limit that needs to apply a torque. For the last check to be positive, the motor needs to be enabled.
For me the assert was called when adding a second hinge constraint in the scene. So even though in other cases m_numConstraintRows of the btGeneric6DofConstraint was zero, it did not call the assert in those cases. So I'm not truly understanding what went wrong and why, but at least things are working :-)

@ibrwr
Copy link

ibrwr commented Mar 2, 2015

In case this is helpful, this is the code where I setup the joints. When I have 2 hinge joints enabled as in the code below, the code crashes as mentioned above

if( true )
{
btGeneric6DofConstraint * hinge = new btGeneric6DofConstraint(*m_bodies[PIVOT_PART], localA, false );
// NOTE: 6DofConstraint only supports (currently) rotational motors!
hinge->getRotationalLimitMotor(0)->m_loLimit = 1;
hinge->getRotationalLimitMotor(0)->m_hiLimit = 0;
hinge->getRotationalLimitMotor(0)->m_enableMotor = true;

hinge->getRotationalLimitMotor(1)->m_loLimit = 1;
hinge->getRotationalLimitMotor(1)->m_hiLimit = 0;
hinge->getRotationalLimitMotor(1)->m_enableMotor = true;

hinge->getRotationalLimitMotor(2)->m_loLimit = 1;
hinge->getRotationalLimitMotor(2)->m_hiLimit = 0;
hinge->getRotationalLimitMotor(2)->m_enableMotor = true;

m_joints[PIVOT] = hinge;
m_bulletWorld->addConstraint(hinge, true );

}

{
btSliderConstraint * slider = new btSliderConstraint(*m_bodies[PIVOT_PART], *m_bodies[SHAFT], localA, shaftTipCenter, true);
slider->setLowerLinLimit(1);
slider->setUpperLinLimit(0);
slider->setPoweredLinMotor( true );
m_joints[SLIDER] = slider;
m_bulletWorld->addConstraint(slider, true);
}

btVector3 zAxis(0,0,1);
if( true )
{
btHingeConstraint * hinge = new btHingeConstraint(*m_bodies[SHAFT], *m_bodies[UPPER_JAW], shaftUpperJawHingePos, upperJawHingePos, zAxis, zAxis );
hinge->enableAngularMotor( true, 0, 0 );
m_joints[UPPER_JAW_ROT] = hinge;
m_bulletWorld->addConstraint(m_joints[UPPER_JAW_ROT], true );
}

if( true )
{
btHingeConstraint * hinge = new btHingeConstraint(*m_bodies[SHAFT], *m_bodies[LOWER_JAW], shaftLowerJawHingePos, lowerJawHingePos, zAxis, zAxis );
hinge->enableAngularMotor( true, 0, 0 );
m_joints[LOWER_JAW_ROT] = hinge;
m_bulletWorld->addConstraint(m_joints[LOWER_JAW_ROT], true );
}

@erwincoumans
Copy link
Member Author

The btGeneric6DofSpringConstraint will be deprecated and replaced by btGeneric6DofSpring2Constraint. Not sure if it will suffer the same issue. Thanks for the report!

@simo-11
Copy link

simo-11 commented Oct 25, 2015

I have similar issues with modified btGeneric6DofSpring2Constraint. In my case assert hits after I disable constraints due to breaking.
I did do some studying how this issue should be solved.

Basic issue is that infom may get set to zero which causes assert failure later in multiply2_p8r
There should probably be additional logic for such cases.
I tried few variations and visual/pyhsical response was best for case where most of block was just skipped if infom is zero. Only incrementation of jj is done.
simo-11@e35bad0

            const unsigned int infom =  row__ < m_tmpSolverNonContactConstraintPool.size() ? m_tmpConstraintSizesPool[jj].m_numConstraintRows : numContactRows;
  if(infom>0){      
            const btScalar *JinvMrow = JinvM + 2*8*(size_t)row__;
            const btScalar *Jrow = Jptr + 2*8*(size_t)row__;
            m_A.multiply2_p8r (JinvMrow, Jrow, infom, infom, row__,row__);
            if (orgBodyB) 
            {
                m_A.multiplyAdd2_p8r (JinvMrow + 8*(size_t)infom, Jrow + 8*(size_t)infom, infom, infom,  row__,row__);
            }
            row__ += infom;
          }
            jj++;

simo-11 added a commit to simo-11/bullet3 that referenced this issue Oct 25, 2015
@bulletphysics bulletphysics locked and limited conversation to collaborators Apr 26, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants