Hello,
The m_appliedImpulse member seems not to be updated in the case of a Generic6Dof constraint but seems to be updated correctly in the case of all other HingeConstraint/Point2PointConstraint.
I was wondering if there's a specific reason for this, or should I be using the TranslationalLimitMotor/RotationalLimitMotor's m_accumulatedImpulse instead for 6DofConstraint ? In that case there doesn't seem to be any methods to get these from the constraint class itself.
If anyone could shed some light on this, I would really appreciate it.
Purpose:
I need this to be accessed in a tickcallback to check to see how much impulse was applied to a constraint to keep it in place...and then make some choices whether to break the constraint or not.
Thanks,
Ram.
m_appliedImpulse is 0 for a Generic6DofConstraint
-
- Posts: 19
- Joined: Fri Sep 05, 2008 8:54 pm
-
- Posts: 9
- Joined: Thu Mar 26, 2009 6:09 pm
- Location: France
Re: m_appliedImpulse is 0 for a Generic6DofConstraint
Hi,
I am experiencing the same issue. I'am trying to get the applied impulse from a btTypedConstraint to decide if I need to break the constraint or not, but the value returned by getAppliedImpulse() is always zero. I had a look at the solver and I didn't saw any update of the m_appliedImpulse of the constraint. Maybe there is an issue here.
Anyway, if you have any information that could help I would appreciate this.
Cheers,
M. Colleaux
I am experiencing the same issue. I'am trying to get the applied impulse from a btTypedConstraint to decide if I need to break the constraint or not, but the value returned by getAppliedImpulse() is always zero. I had a look at the solver and I didn't saw any update of the m_appliedImpulse of the constraint. Maybe there is an issue here.
Anyway, if you have any information that could help I would appreciate this.
Cheers,
M. Colleaux
-
- Posts: 19
- Joined: Fri Sep 05, 2008 8:54 pm
Re: m_appliedImpulse is 0 for a Generic6DofConstraint
Yes, I was able to get it to work with modifications to bullet.
In bullet 2.70 source code
under the directory
/src/BulletDynamics/ConstraintSolver
and filename
btGeneric6DofConstraint.cpp
I changed the following line
to
and the following line
to
This is probably fixed in later bullet versions...
so maybe you want to do something similar in btTypedConstraint.cpp
Hope this helps you.
Ram.
In bullet 2.70 source code
under the directory
/src/BulletDynamics/ConstraintSolver
and filename
btGeneric6DofConstraint.cpp
I changed the following line
Code: Select all
m_linearLimits.solveLinearAxis(
m_timeStep,
jacDiagABInv,
m_rbA,pointInA,
m_rbB,pointInB,
i,linear_axis, m_AnchorPos);
Code: Select all
m_appliedImpulse += m_linearLimits.solveLinearAxis(
m_timeStep,
jacDiagABInv,
m_rbA,pointInA,
m_rbB,pointInB,
i,linear_axis, m_AnchorPos);
}
}
Code: Select all
m_angularLimits[i].solveAngularLimits(m_timeStep,angular_axis,angularJacDiagABInv, &m_rbA,&m_rbB);
Code: Select all
m_appliedImpulse += m_angularLimits[i].solveAngularLimits(m_timeStep,angular_axis,angularJacDiagABInv, &m_rbA,&m_rbB);
so maybe you want to do something similar in btTypedConstraint.cpp
Hope this helps you.
Ram.
-
- Posts: 41
- Joined: Thu Jan 08, 2009 11:20 am
- Location: London, UK
Re: m_appliedImpulse is 0 for a Generic6DofConstraint
Hi Mathieu,
Did you find a way to get this to work? (I'm trying to do the same thing).
Thanks,
Kate
Did you find a way to get this to work? (I'm trying to do the same thing).
Thanks,
Kate
-
- Posts: 9
- Joined: Thu Mar 26, 2009 6:09 pm
- Location: France
Re: m_appliedImpulse is 0 for a Generic6DofConstraint
Hi Kate,
I decided to add an impulse accumulator in btTypedConstraint :
It stores the impulses applied by the constraint solver and it is reseted every simulation step (at the begining of the buildJacobian method).
You will need to modify the constraint solver to store the impulses correctly.
Once the constraint is solved I compare the square length of the impulses with a threshold to determine if the constraint is broken or not.
If the constraint is broken it will be removed at the begining of the next simulation step.
I hope this helps,
Mathieu
I decided to add an impulse accumulator in btTypedConstraint :
Code: Select all
struct btImpulseAccumulator {
btVector3 m_linImpulseA;
btVector3 m_angImpulseA;
btVector3 m_linImpulseB;
btVector3 m_angImpulseB;
};
You will need to modify the constraint solver to store the impulses correctly.
Once the constraint is solved I compare the square length of the impulses with a threshold to determine if the constraint is broken or not.
Code: Select all
void updateImpulseBreakable (btScalar timestep)
{
// A broken constraint should have been already removed from the simulation
btAssert(!m_broken);
if (isBreakable())
{
float length1, length2;
// Compute impulses from velocities
m_accumulator.m_linImpulseA *= timestep;
m_accumulator.m_angImpulseA *= timestep;
m_accumulator.m_linImpulseB *= timestep;
m_accumulator.m_angImpulseB *= timestep;
length1 = m_accumulator.m_linImpulseA.length2() + m_accumulator.m_angImpulseA.length2();
m_broken |= length1 > (m_BreakThreshold*m_BreakThreshold);
length2 = m_accumulator.m_linImpulseB.length2() + m_accumulator.m_angImpulseB.length2();
m_broken |= length2 > (m_BreakThreshold*m_BreakThreshold);
if (m_broken)
{
// Fire a callback to inform the user that the constraint have been broken during the current frame
if (gConstraintBrokenCallback)
{
float maxImpulse = (length1 > length2) ? length1 : length2;
gConstraintBrokenCallback(*this, btSqrt(maxImpulse));
}
m_broken=true;
}
}
}
I hope this helps,
Mathieu
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: m_appliedImpulse is 0 for a Generic6DofConstraint
Hi Mathieu,
It would be great if you could provide a patch for this, and the breakable constraint callback, against latest trunk. Would that be possible?
UPDATE: We'll try to fix appliedImpulse for joints before final 2.75 release: http://code.google.com/p/bullet/issues/detail?id=227
Thanks,
Erwin
It would be great if you could provide a patch for this, and the breakable constraint callback, against latest trunk. Would that be possible?
UPDATE: We'll try to fix appliedImpulse for joints before final 2.75 release: http://code.google.com/p/bullet/issues/detail?id=227
Thanks,
Erwin
-
- Posts: 41
- Joined: Thu Jan 08, 2009 11:20 am
- Location: London, UK
Re: m_appliedImpulse is 0 for a Generic6DofConstraint
Cool, thanks Mathieu - I'll give that a go.
K.
K.
-
- Posts: 41
- Joined: Thu Jan 08, 2009 11:20 am
- Location: London, UK
Re: m_appliedImpulse is 0 for a Generic6DofConstraint
Hi Erwin,
Kate
That would be really cool - thanks!Erwin Coumans wrote:UPDATE: We'll try to fix appliedImpulse for joints before final 2.75 release: http://code.google.com/p/bullet/issues/detail?id=227
Kate