Nan troubles when using motorized btConeTwistConstraint

foolish_mortal
Posts: 3
Joined: Tue Aug 23, 2011 11:28 am

Nan troubles when using motorized btConeTwistConstraint

Post by foolish_mortal »

Hi

I'm using Bullet 2.78. I was happily using a btConeTwistConstraint until I decided I wanted to motorize it.

When I tried enabling the motor it worked fine, except that it was way too fast, and calling setMaxMotorImpulse passing in a small value seemed to have no effect. Looking at the code I realised that m_maxMotorImpulse is only used by the 'obsolete' branch.

So I set CONETWIST_USE_OBSOLETE_SOLVER to true and tried again, but I found I was getting NANs in my angular velocities. The source seemed to be from the following bit of code in btConeTwistConstraint.cpp:

Code: Select all

btVector3 impulseAxis =  impulse / impulseMag;

bodyA.internalApplyImpulse(btVector3(0,0,0), m_rbA.getInvInertiaTensorWorld()*impulseAxis, impulseMag);
bodyB.internalApplyImpulse(btVector3(0,0,0), m_rbB.getInvInertiaTensorWorld()*impulseAxis, -impulseMag);
impulseMag was 0. After I put a

Code: Select all

if (impulseMag > 0.f)
around the above, it seemed to work properly.

I looked in the forums and found someone saying that the cone twist constraint motor is still work in progress. So my questions I guess are:
- Will m_maxMotorImpulse make it into the non-obsolete solver?
- Is my fix correct for the obsolete solver?

Thanks.