Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Protected Member Functions | Protected Attributes
btGeneric6DofConstraint Class Reference

btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space More...

#include <btGeneric6DofConstraint.h>

Inheritance diagram for btGeneric6DofConstraint:
Inheritance graph
[legend]
Collaboration diagram for btGeneric6DofConstraint:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 btGeneric6DofConstraint (btRigidBody &rbA, btRigidBody &rbB, const btTransform &frameInA, const btTransform &frameInB, bool useLinearReferenceFrameA)
 btGeneric6DofConstraint ()
void calculateTransforms ()
 Calcs global transform of the offsets.
const btTransformgetCalculatedTransformA () const
 Gets the global transform of the offset for body A.
const btTransformgetCalculatedTransformB () const
 Gets the global transform of the offset for body B.
const btTransformgetFrameOffsetA () const
const btTransformgetFrameOffsetB () const
btTransformgetFrameOffsetA ()
btTransformgetFrameOffsetB ()
virtual void buildJacobian ()
 performs Jacobian calculation, and also calculates angle differences and axis
virtual void solveConstraint (btScalar timeStep)
void updateRHS (btScalar timeStep)
btVector3 getAxis (int axis_index) const
 Get the rotation axis in global coordinates.
btScalar getAngle (int axis_index) const
 Get the relative Euler angle.
bool testAngularLimitMotor (int axis_index)
 Test angular limit.
void setLinearLowerLimit (const btVector3 &linearLower)
void setLinearUpperLimit (const btVector3 &linearUpper)
void setAngularLowerLimit (const btVector3 &angularLower)
void setAngularUpperLimit (const btVector3 &angularUpper)
btRotationalLimitMotorgetRotationalLimitMotor (int index)
 Retrieves the angular limit informacion.
btTranslationalLimitMotorgetTranslationalLimitMotor ()
 Retrieves the limit informacion.
void setLimit (int axis, btScalar lo, btScalar hi)
bool isLimited (int limitIndex)
 Test limit.
const btRigidBodygetRigidBodyA () const
const btRigidBodygetRigidBodyB () const
btRigidBodygetRigidBodyA ()
btRigidBodygetRigidBodyB ()
int getUserConstraintType () const
void setUserConstraintType (int userConstraintType)
void setUserConstraintId (int uid)
int getUserConstraintId () const
int getUid () const
btScalar getAppliedImpulse () const
btTypedConstraintType getConstraintType () const

Protected Member Functions

btGeneric6DofConstraintoperator= (btGeneric6DofConstraint &other)
void buildLinearJacobian (btJacobianEntry &jacLinear, const btVector3 &normalWorld, const btVector3 &pivotAInW, const btVector3 &pivotBInW)
void buildAngularJacobian (btJacobianEntry &jacAngular, const btVector3 &jointAxisW)
void calculateAngleInfo ()
 calcs the euler angles between the two bodies.

Protected Attributes

btRigidBodym_rbA
btRigidBodym_rbB
btScalar m_appliedImpulse
btTransform m_frameInA
 relative_frames
btJacobianEntry m_jacLinear [3]
 3 orthogonal linear constraints
btTranslationalLimitMotor m_linearLimits
btRotationalLimitMotor m_angularLimits [3]
 hinge_parameters
btScalar m_timeStep
 temporal variables
btTransform m_calculatedTransformA
btTransform m_calculatedTransformB
btVector3 m_calculatedAxisAngleDiff
btVector3 m_calculatedAxis [3]
bool m_useLinearReferenceFrameA

Detailed Description

btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space

btGeneric6DofConstraint can leave any of the 6 degree of freedom 'free' or 'locked'. currently this limit supports rotational motors

Definition at line 213 of file btGeneric6DofConstraint.h.


Constructor & Destructor Documentation

btGeneric6DofConstraint::btGeneric6DofConstraint ( btRigidBody rbA,
btRigidBody rbB,
const btTransform frameInA,
const btTransform frameInB,
bool  useLinearReferenceFrameA 
)

Definition at line 277 of file btGeneric6DofConstraint.cpp.

        : btTypedConstraint(D6_CONSTRAINT_TYPE, rbA, rbB)
        , m_frameInA(frameInA)
        , m_frameInB(frameInB),
              m_useLinearReferenceFrameA(useLinearReferenceFrameA)
{

}

Member Function Documentation

void btGeneric6DofConstraint::buildAngularJacobian ( btJacobianEntry jacAngular,
const btVector3 jointAxisW 
) [protected]

Definition at line 360 of file btGeneric6DofConstraint.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

performs Jacobian calculation, and also calculates angle differences and axis

Implements btTypedConstraint.

Definition at line 380 of file btGeneric6DofConstraint.cpp.

{

       // Clear accumulated impulses for the next simulation step
    m_linearLimits.m_accumulatedImpulse.setValue(btScalar(0.), btScalar(0.), btScalar(0.));
    int i;
    for(i = 0; i < 3; i++)
    {
        m_angularLimits[i].m_accumulatedImpulse = btScalar(0.);
    }
    //calculates transform
    calculateTransforms();

    const btVector3& pivotAInW = m_calculatedTransformA.getOrigin();
    const btVector3& pivotBInW = m_calculatedTransformB.getOrigin();


    btVector3 rel_pos1 = pivotAInW - m_rbA.getCenterOfMassPosition();
    btVector3 rel_pos2 = pivotBInW - m_rbB.getCenterOfMassPosition();

    btVector3 normalWorld;
    //linear part
    for (i=0;i<3;i++)
    {
        if (m_linearLimits.isLimited(i))
        {
                     if (m_useLinearReferenceFrameA)
                   normalWorld = m_calculatedTransformA.getBasis().getColumn(i);
                     else
                   normalWorld = m_calculatedTransformB.getBasis().getColumn(i);

            buildLinearJacobian(
                m_jacLinear[i],normalWorld ,
                pivotAInW,pivotBInW);

        }
    }

    // angular part
    for (i=0;i<3;i++)
    {
        //calculates error angle
        if (testAngularLimitMotor(i))
        {
            normalWorld = this->getAxis(i);
            // Create angular atom
            buildAngularJacobian(m_jacAng[i],normalWorld);
        }
    }


}

Here is the call graph for this function:

void btGeneric6DofConstraint::buildLinearJacobian ( btJacobianEntry jacLinear,
const btVector3 normalWorld,
const btVector3 pivotAInW,
const btVector3 pivotBInW 
) [protected]

Definition at line 343 of file btGeneric6DofConstraint.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

calcs the euler angles between the two bodies.

Definition at line 290 of file btGeneric6DofConstraint.cpp.

{
       btMatrix3x3 relative_frame = m_calculatedTransformA.getBasis().inverse()*m_calculatedTransformB.getBasis();

       matrixToEulerXYZ(relative_frame,m_calculatedAxisAngleDiff);



       // in euler angle mode we do not actually constrain the angular velocity
  // along the axes axis[0] and axis[2] (although we do use axis[1]) :
  //
  //    to get                     constrain w2-w1 along              ...not
  //    ------                     ---------------------              ------
  //    d(angle[0])/dt = 0  ax[1] x ax[2]               ax[0]
  //    d(angle[1])/dt = 0  ax[1]
  //    d(angle[2])/dt = 0  ax[0] x ax[1]               ax[2]
  //
  // constraining w2-w1 along an axis 'a' means that a'*(w2-w1)=0.
  // to prove the result for angle[0], write the expression for angle[0] from
  // GetInfo1 then take the derivative. to prove this for angle[2] it is
  // easier to take the euler rate expression for d(angle[2])/dt with respect
  // to the components of w and set that to 0.

       btVector3 axis0 = m_calculatedTransformB.getBasis().getColumn(0);
       btVector3 axis2 = m_calculatedTransformA.getBasis().getColumn(2);

       m_calculatedAxis[1] = axis2.cross(axis0);
       m_calculatedAxis[0] = m_calculatedAxis[1].cross(axis2);
       m_calculatedAxis[2] = axis0.cross(m_calculatedAxis[1]);


//    if(m_debugDrawer)
//    {
//
//     char buff[300];
//            sprintf(buff,"\n X: %.2f ; Y: %.2f ; Z: %.2f ",
//            m_calculatedAxisAngleDiff[0],
//            m_calculatedAxisAngleDiff[1],
//            m_calculatedAxisAngleDiff[2]);
//     m_debugDrawer->reportErrorWarning(buff);
//    }

}

Here is the call graph for this function:

Here is the caller graph for this function:

Calcs global transform of the offsets.

Calcs the global transform for the joint offset for body A an B, and also calcs the agle differences between the bodies.

See also:
btGeneric6DofConstraint.getCalculatedTransformA , btGeneric6DofConstraint.getCalculatedTransformB, btGeneric6DofConstraint.calculateAngleInfo

Definition at line 334 of file btGeneric6DofConstraint.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

btScalar btGeneric6DofConstraint::getAngle ( int  axis_index) const

Get the relative Euler angle.

Precondition:
btGeneric6DofConstraint.buildJacobian must be called previously.

Definition at line 499 of file btGeneric6DofConstraint.cpp.

{
    return m_calculatedAxisAngleDiff[axis_index];
}
btScalar btTypedConstraint::getAppliedImpulse ( ) const [inline, inherited]

Definition at line 108 of file btTypedConstraint.h.

       {
              return m_appliedImpulse;
       }
btVector3 btGeneric6DofConstraint::getAxis ( int  axis_index) const

Get the rotation axis in global coordinates.

Precondition:
btGeneric6DofConstraint.buildJacobian must be called previously.

Definition at line 494 of file btGeneric6DofConstraint.cpp.

{
    return m_calculatedAxis[axis_index];
}

Here is the caller graph for this function:

Gets the global transform of the offset for body B.

See also:
btGeneric6DofConstraint.getFrameOffsetA, btGeneric6DofConstraint.getFrameOffsetB, btGeneric6DofConstraint.calculateAngleInfo.

Definition at line 300 of file btGeneric6DofConstraint.h.

Here is the caller graph for this function:

Definition at line 113 of file btTypedConstraint.h.

       {
              return m_constraintType;
       }

Here is the caller graph for this function:

Definition at line 305 of file btGeneric6DofConstraint.h.

    {
       return m_frameInA;
    }

Here is the caller graph for this function:

Definition at line 316 of file btGeneric6DofConstraint.h.

    {
       return m_frameInA;
    }

Definition at line 310 of file btGeneric6DofConstraint.h.

    {
       return m_frameInB;
    }

Here is the caller graph for this function:

Definition at line 321 of file btGeneric6DofConstraint.h.

    {
       return m_frameInB;
    }

Definition at line 74 of file btTypedConstraint.h.

       {
              return m_rbA;
       }

Reimplemented from btTypedConstraint.

Definition at line 421 of file btGeneric6DofConstraint.h.

    {
        return m_rbA;
    }

Definition at line 78 of file btTypedConstraint.h.

       {
              return m_rbB;
       }

Reimplemented from btTypedConstraint.

Definition at line 425 of file btGeneric6DofConstraint.h.

    {
        return m_rbB;
    }

Retrieves the angular limit informacion.

Definition at line 378 of file btGeneric6DofConstraint.h.

    {
       return &m_angularLimits[index];
    }

Here is the caller graph for this function:

Retrieves the limit informacion.

Definition at line 384 of file btGeneric6DofConstraint.h.

    {
       return &m_linearLimits;
    }
int btTypedConstraint::getUid ( ) const [inline, inherited]

Definition at line 103 of file btTypedConstraint.h.

       {
              return m_userConstraintId;   
       } 
int btTypedConstraint::getUserConstraintId ( ) const [inline, inherited]

Definition at line 98 of file btTypedConstraint.h.

       {
              return m_userConstraintId;
       }
int btTypedConstraint::getUserConstraintType ( ) const [inline, inherited]

Definition at line 83 of file btTypedConstraint.h.

       {
              return m_userConstraintType ;
       }
bool btGeneric6DofConstraint::isLimited ( int  limitIndex) [inline]

Test limit.

  • free means upper < lower,
  • locked means upper == lower
  • limited means upper > lower
  • limitIndex: first 3 are linear, next 3 are angular

Definition at line 411 of file btGeneric6DofConstraint.h.

    {
       if(limitIndex<3)
       {
                     return m_linearLimits.isLimited(limitIndex);

       }
        return m_angularLimits[limitIndex-3].isLimited();
    }

Here is the call graph for this function:

btGeneric6DofConstraint& btGeneric6DofConstraint::operator= ( btGeneric6DofConstraint other) [inline, protected]

Definition at line 254 of file btGeneric6DofConstraint.h.

    {
        btAssert(0);
        (void) other;
        return *this;
    }
void btGeneric6DofConstraint::setAngularLowerLimit ( const btVector3 angularLower) [inline]

Definition at line 363 of file btGeneric6DofConstraint.h.

    {
        m_angularLimits[0].m_loLimit = angularLower.getX();
        m_angularLimits[1].m_loLimit = angularLower.getY();
        m_angularLimits[2].m_loLimit = angularLower.getZ();
    }

Here is the call graph for this function:

void btGeneric6DofConstraint::setAngularUpperLimit ( const btVector3 angularUpper) [inline]

Definition at line 370 of file btGeneric6DofConstraint.h.

    {
        m_angularLimits[0].m_hiLimit = angularUpper.getX();
        m_angularLimits[1].m_hiLimit = angularUpper.getY();
        m_angularLimits[2].m_hiLimit = angularUpper.getZ();
    }

Here is the call graph for this function:

void btGeneric6DofConstraint::setLimit ( int  axis,
btScalar  lo,
btScalar  hi 
) [inline]

Definition at line 390 of file btGeneric6DofConstraint.h.

    {
       if(axis<3)
       {
              m_linearLimits.m_lowerLimit[axis] = lo;
              m_linearLimits.m_upperLimit[axis] = hi;
       }
       else
       {
              m_angularLimits[axis-3].m_loLimit = lo;
              m_angularLimits[axis-3].m_hiLimit = hi;
       }
    }
void btGeneric6DofConstraint::setLinearLowerLimit ( const btVector3 linearLower) [inline]

Definition at line 353 of file btGeneric6DofConstraint.h.

    {
       m_linearLimits.m_lowerLimit = linearLower;
    }
void btGeneric6DofConstraint::setLinearUpperLimit ( const btVector3 linearUpper) [inline]

Definition at line 358 of file btGeneric6DofConstraint.h.

    {
       m_linearLimits.m_upperLimit = linearUpper;
    }
void btTypedConstraint::setUserConstraintId ( int  uid) [inline, inherited]

Definition at line 93 of file btTypedConstraint.h.

       {
              m_userConstraintId = uid;
       }
void btTypedConstraint::setUserConstraintType ( int  userConstraintType) [inline, inherited]

Definition at line 88 of file btTypedConstraint.h.

       {
              m_userConstraintType = userConstraintType;
       };
void btGeneric6DofConstraint::solveConstraint ( btScalar  timeStep) [virtual]

Implements btTypedConstraint.

Definition at line 434 of file btGeneric6DofConstraint.cpp.

{
    m_timeStep = timeStep;

    //calculateTransforms();

    int i;

    // linear

    btVector3 pointInA = m_calculatedTransformA.getOrigin();
       btVector3 pointInB = m_calculatedTransformB.getOrigin();

       btScalar jacDiagABInv;
       btVector3 linear_axis;
    for (i=0;i<3;i++)
    {
        if (m_linearLimits.isLimited(i))
        {
            jacDiagABInv = btScalar(1.) / m_jacLinear[i].getDiagonal();

                     if (m_useLinearReferenceFrameA)
                   linear_axis = m_calculatedTransformA.getBasis().getColumn(i);
                     else
                   linear_axis = m_calculatedTransformB.getBasis().getColumn(i);

            m_linearLimits.solveLinearAxis(
              m_timeStep,
              jacDiagABInv,
              m_rbA,pointInA,
                m_rbB,pointInB,
                i,linear_axis);

        }
    }

    // angular
    btVector3 angular_axis;
    btScalar angularJacDiagABInv;
    for (i=0;i<3;i++)
    {
        if (m_angularLimits[i].needApplyTorques())
        {

                     // get axis
                     angular_axis = getAxis(i);

                     angularJacDiagABInv = btScalar(1.) / m_jacAng[i].getDiagonal();

                     m_angularLimits[i].solveAngularLimits(m_timeStep,angular_axis,angularJacDiagABInv, &m_rbA,&m_rbB);
        }
    }
}

Here is the call graph for this function:

Test angular limit.

Calculates angular correction and returns true if limit needs to be corrected.

Precondition:
btGeneric6DofConstraint.buildJacobian must be called previously.

Definition at line 371 of file btGeneric6DofConstraint.cpp.

{
    btScalar angle = m_calculatedAxisAngleDiff[axis_index];

    //test limits
    m_angularLimits[axis_index].testLimitValue(angle);
    return m_angularLimits[axis_index].needApplyTorques();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 488 of file btGeneric6DofConstraint.cpp.

{
    (void)timeStep;

}

Member Data Documentation

hinge_parameters

Definition at line 237 of file btGeneric6DofConstraint.h.

Definition at line 50 of file btTypedConstraint.h.

Definition at line 248 of file btGeneric6DofConstraint.h.

Definition at line 247 of file btGeneric6DofConstraint.h.

Definition at line 245 of file btGeneric6DofConstraint.h.

Definition at line 246 of file btGeneric6DofConstraint.h.

relative_frames

the constraint space w.r.t body A

Definition at line 219 of file btGeneric6DofConstraint.h.

3 orthogonal linear constraints

Jacobians

Definition at line 221 of file btGeneric6DofConstraint.h.

Linear_Limit_parameters

Definition at line 227 of file btGeneric6DofConstraint.h.

btRigidBody& btTypedConstraint::m_rbA [protected, inherited]

Definition at line 48 of file btTypedConstraint.h.

btRigidBody& btTypedConstraint::m_rbB [protected, inherited]

Definition at line 49 of file btTypedConstraint.h.

temporal variables

Definition at line 244 of file btGeneric6DofConstraint.h.

Definition at line 250 of file btGeneric6DofConstraint.h.


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