energy spent for joint motor, difficulty 2.73 --> 2.74

Post Reply
acx01b
Posts: 10
Joined: Thu Jan 15, 2009 12:42 pm

energy spent for joint motor, difficulty 2.73 --> 2.74

Post by acx01b »

Hi,

I would like to know how to get the total energy applied by motors to each hinge joint of my simulation,
I can get it like that in bullet 2.73 :

Code: Select all

// before the Step :
for (int = 0; i < nb_joint; i++)
{
   joint[i]->motorImpulseInThatStep = 0;
}

// modification of btHingeConstraint::solveConstraintObsolete
void	btHingeConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar	timeStep)
{
        ....
    if (m_enableAngularMotor)
    {
        clippedMotorImpulse = ... ;
        motorImpulseInThatStep += clippedMotorImpulse;
    }
}

// after the Step
for (int = 0; i < nb_joint; i++)
{
    float imp = joint[i]->motorImpulseInThatStep;
    totalEnergy += imp*imp;
}
thanks
acx01b
Posts: 10
Joined: Thu Jan 15, 2009 12:42 pm

Re: energy spent for joint motor, difficulty 2.73 --> 2.74

Post by acx01b »

I find what value I had to sum / save to get total energy applied to hinge joints :

Code: Select all

btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(...)
{
    float totalEnergy = 0;
    for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++)
    {
         ....
         ///solve all joint constraints, using SIMD, if available
         for (j=0;j<m_tmpSolverNonContactConstraintPool.size();j++)
         {
             btSolverConstraint& constraint = m_tmpSolverNonContactConstraintPool[j];
             resolveSingleConstraintRowGenericSIMD(m_tmpSolverBodyPool[constraint.m_solverBodyIdA],m_tmpSolverBodyPool[constraint.m_solverBodyIdB],constraint);
         }
         ...
    }
    
    // at the end :
    // sum (squared) the appliedimpulse field of the 6th "row" (btSolverConstraint struct for limit and motor calculation) of each hinge joint 
    for (j=0;j<m_tmpSolverNonContactConstraintPool.size();j++)
    {
        if (j is the 6th row of a hingeJoint)
        {
            float imp = m_tmpSolverNonContactConstraintPool[i].m_appliedImpulse;
            totalEnergyOfTheStep += imp*imp;
        }
    }
}
but I don't know how to code that : if (j is the 6th row of a hingeJoint)

thank you for help and confirmation
DannyChapman
Posts: 84
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: energy spent for joint motor, difficulty 2.73 --> 2.74

Post by DannyChapman »

Can't help with the Bullet-specific stuff, but

Units of impulse = mass * distance / time

Units of energy = mass * distance^2 / time^2

so your calculation (energy = impulse * impulse) must be wrong anyway...
acx01b
Posts: 10
Joined: Thu Jan 15, 2009 12:42 pm

Re: energy spent for joint motor, difficulty 2.73 --> 2.74

Post by acx01b »

yes, I agree with you but here I consider 1/ timeStep^2 as a constant
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: energy spent for joint motor, difficulty 2.73 --> 2.74

Post by Dirk Gregorius »

But you still have the (effective) mass^2 in you energy equation.

Why do you want the enery? Would't be the applied impulse sufficient?
acx01b
Posts: 10
Joined: Thu Jan 15, 2009 12:42 pm

Re: energy spent for joint motor, difficulty 2.73 --> 2.74

Post by acx01b »

I need it as quality criterion for evolutionary algorithm

yes you are right, I am going to use "the sum of impulse" instead of "the sum of impulse^2"

so my problem is still there : how to get efficiently after each step the sum of [hingeJoint 6th row].appliedImpulse ?

tks
Post Reply