Back to index

supertuxkart  0.5+dfsg1
Public Member Functions
btRotationalLimitMotor Class Reference

Rotation Limit structure for generic joints. More...

#include <btGeneric6DofConstraint.h>

List of all members.

Public Member Functions

 btRotationalLimitMotor ()
 btRotationalLimitMotor (const btRotationalLimitMotor &limot)
bool isLimited ()
 Is limited.
bool needApplyTorques ()
 Need apply correction.
int testLimitValue (btScalar test_value)
 calculates error
btScalar solveAngularLimits (btScalar timeStep, btVector3 &axis, btScalar jacDiagABInv, btRigidBody *body0, btRigidBody *body1)
 apply the correction impulses for two bodies

Public Attributes

btScalar m_loLimit
 limit_parameters
btScalar m_hiLimit
 joint limit
btScalar m_targetVelocity
 target motor velocity
btScalar m_maxMotorForce
 max force on motor
btScalar m_maxLimitForce
 max force on limit
btScalar m_damping
 Damping.
btScalar m_limitSoftness
btScalar m_ERP
 Relaxation factor.
btScalar m_bounce
 restitution factor
bool m_enableMotor
btScalar m_currentLimitError
 temp_variables
int m_currentLimit
 How much is violated this limit.
btScalar m_accumulatedImpulse

Detailed Description

Rotation Limit structure for generic joints.

Definition at line 34 of file btGeneric6DofConstraint.h.


Constructor & Destructor Documentation


Member Function Documentation

Is limited.

Definition at line 93 of file btGeneric6DofConstraint.h.

    {
       if(m_loLimit>=m_hiLimit) return false;
       return true;
    }

Here is the caller graph for this function:

Need apply correction.

Definition at line 100 of file btGeneric6DofConstraint.h.

    {
       if(m_currentLimit == 0 && m_enableMotor == false) return false;
       return true;
    }

Here is the caller graph for this function:

btScalar btRotationalLimitMotor::solveAngularLimits ( btScalar  timeStep,
btVector3 axis,
btScalar  jacDiagABInv,
btRigidBody body0,
btRigidBody body1 
)

apply the correction impulses for two bodies

Definition at line 114 of file btGeneric6DofConstraint.cpp.

{
    if (needApplyTorques()==false) return 0.0f;

    btScalar target_velocity = m_targetVelocity;
    btScalar maxMotorForce = m_maxMotorForce;

       //current error correction
    if (m_currentLimit!=0)
    {
        target_velocity = -m_ERP*m_currentLimitError/(timeStep);
        maxMotorForce = m_maxLimitForce;
    }

    maxMotorForce *= timeStep;

    // current velocity difference
    btVector3 vel_diff = body0->getAngularVelocity();
    if (body1)
    {
        vel_diff -= body1->getAngularVelocity();
    }



    btScalar rel_vel = axis.dot(vel_diff);

       // correction velocity
    btScalar motor_relvel = m_limitSoftness*(target_velocity  - m_damping*rel_vel);


    if ( motor_relvel < SIMD_EPSILON && motor_relvel > -SIMD_EPSILON  )
    {
        return 0.0f;//no need for applying force
    }


       // correction impulse
    btScalar unclippedMotorImpulse = (1+m_bounce)*motor_relvel*jacDiagABInv;

       // clip correction impulse
    btScalar clippedMotorImpulse;

    //todo: should clip against accumulated impulse
    if (unclippedMotorImpulse>0.0f)
    {
        clippedMotorImpulse =  unclippedMotorImpulse > maxMotorForce? maxMotorForce: unclippedMotorImpulse;
    }
    else
    {
        clippedMotorImpulse =  unclippedMotorImpulse < -maxMotorForce ? -maxMotorForce: unclippedMotorImpulse;
    }


       // sort with accumulated impulses
    btScalar  lo = btScalar(-1e30);
    btScalar  hi = btScalar(1e30);

    btScalar oldaccumImpulse = m_accumulatedImpulse;
    btScalar sum = oldaccumImpulse + clippedMotorImpulse;
    m_accumulatedImpulse = sum > hi ? btScalar(0.) : sum < lo ? btScalar(0.) : sum;

    clippedMotorImpulse = m_accumulatedImpulse - oldaccumImpulse;



    btVector3 motorImp = clippedMotorImpulse * axis;


    body0->applyTorqueImpulse(motorImp);
    if (body1) body1->applyTorqueImpulse(-motorImp);

    return clippedMotorImpulse;


}

Here is the call graph for this function:

Here is the caller graph for this function:

calculates error

calculates m_currentLimit and m_currentLimitError.

Definition at line 85 of file btGeneric6DofConstraint.cpp.

{
       if(m_loLimit>m_hiLimit)
       {
              m_currentLimit = 0;//Free from violation
              return 0;
       }

       if (test_value < m_loLimit)
       {
              m_currentLimit = 1;//low limit violation
              m_currentLimitError =  test_value - m_loLimit;
              return 1;
       }
       else if (test_value> m_hiLimit)
       {
              m_currentLimit = 2;//High limit violation
              m_currentLimitError = test_value - m_hiLimit;
              return 2;
       }
       else
       {
              m_currentLimit = 0;//Free from violation
              return 0;
       }
       return 0;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 56 of file btGeneric6DofConstraint.h.

restitution factor

Definition at line 47 of file btGeneric6DofConstraint.h.

How much is violated this limit.

0=free, 1=at lo limit, 2=at hi limit

Definition at line 55 of file btGeneric6DofConstraint.h.

temp_variables

Definition at line 54 of file btGeneric6DofConstraint.h.

Damping.

Definition at line 44 of file btGeneric6DofConstraint.h.

Definition at line 48 of file btGeneric6DofConstraint.h.

Relaxation factor.

Error tolerance factor when joint is at limit

Definition at line 46 of file btGeneric6DofConstraint.h.

joint limit

Definition at line 40 of file btGeneric6DofConstraint.h.

Definition at line 45 of file btGeneric6DofConstraint.h.

limit_parameters

joint limit

Definition at line 39 of file btGeneric6DofConstraint.h.

max force on limit

Definition at line 43 of file btGeneric6DofConstraint.h.

max force on motor

Definition at line 42 of file btGeneric6DofConstraint.h.

target motor velocity

Definition at line 41 of file btGeneric6DofConstraint.h.


The documentation for this class was generated from the following files: