|
Bullet Collision Detection & Physics Library
|
Go to the documentation of this file.
24 #ifndef BT_MULTIBODY_H
25 #define BT_MULTIBODY_H
34 #ifdef BT_USE_DOUBLE_PRECISION
35 #define btMultiBodyData btMultiBodyDoubleData
36 #define btMultiBodyDataName "btMultiBodyDoubleData"
37 #define btMultiBodyLinkData btMultiBodyLinkDoubleData
38 #define btMultiBodyLinkDataName "btMultiBodyLinkDoubleData"
40 #define btMultiBodyData btMultiBodyFloatData
41 #define btMultiBodyDataName "btMultiBodyFloatData"
42 #define btMultiBodyLinkData btMultiBodyLinkFloatData
43 #define btMultiBodyLinkDataName "btMultiBodyLinkFloatData"
44 #endif //BT_USE_DOUBLE_PRECISION
63 bool canSleep,
bool deprecatedMultiDof =
true);
68 void setupFixed(
int i,
73 const btVector3 &parentComToThisPivotOffset,
74 const btVector3 &thisPivotToThisComOffset,
bool deprecatedDisableParentCollision =
true);
76 void setupPrismatic(
int i,
82 const btVector3 &parentComToThisPivotOffset,
83 const btVector3 &thisPivotToThisComOffset,
84 bool disableParentCollision);
86 void setupRevolute(
int i,
92 const btVector3 &parentComToThisPivotOffset,
93 const btVector3 &thisPivotToThisComOffset,
94 bool disableParentCollision =
false);
96 void setupSpherical(
int i,
101 const btVector3 &parentComToThisPivotOffset,
102 const btVector3 &thisPivotToThisComOffset,
103 bool disableParentCollision =
false);
105 void setupPlanar(
int i,
111 const btVector3 &parentComToThisComOffset,
112 bool disableParentCollision =
false);
116 return m_links[index];
121 return m_links[index];
126 m_baseCollider = collider;
130 return m_baseCollider;
134 return m_baseCollider;
139 if (index >= 0 && index < getNumLinks())
141 return getLink(index).m_collider;
148 if (index >= 0 && index < getNumLinks())
150 return getLink(index).m_collider;
160 int getParent(
int link_num)
const;
172 const btVector3 &getLinkInertia(
int i)
const;
191 return btVector3(m_realBuf[3], m_realBuf[4], m_realBuf[5]);
200 return m_basePos_interpolate;
204 return m_baseQuat_interpolate;
213 if(!isBaseKinematic())
214 m_basePos_interpolate = pos;
219 m_basePos_interpolate = pos;
252 m_realBuf[3] = vel[0];
253 m_realBuf[4] = vel[1];
254 m_realBuf[5] = vel[2];
260 if(!isBaseKinematic())
261 m_baseQuat_interpolate = rot;
266 m_baseQuat_interpolate = rot;
271 m_realBuf[0] = omega[0];
272 m_realBuf[1] = omega[1];
273 m_realBuf[2] = omega[2];
276 void saveKinematicState(
btScalar timeStep);
285 btScalar *getJointVelMultiDof(
int i);
286 btScalar *getJointPosMultiDof(
int i);
288 const btScalar *getJointVelMultiDof(
int i)
const;
289 const btScalar *getJointPosMultiDof(
int i)
const;
291 void setJointPos(
int i,
btScalar q);
292 void setJointVel(
int i,
btScalar qdot);
293 void setJointPosMultiDof(
int i,
const double *q);
294 void setJointVelMultiDof(
int i,
const double *qdot);
295 void setJointPosMultiDof(
int i,
const float *q);
296 void setJointVelMultiDof(
int i,
const float *qdot);
304 return &m_realBuf[0];
327 const btVector3 &getRVector(
int i)
const;
329 const btVector3 &getInterpolateRVector(
int i)
const;
330 const btQuaternion &getInterpolateParentToLocalRot(
int i)
const;
350 void clearForcesAndTorques();
351 void clearConstraintForces();
353 void clearVelocities();
360 void addLinkForce(
int i,
const btVector3 &f);
361 void addLinkTorque(
int i,
const btVector3 &t);
365 m_baseConstraintForce += f;
368 void addLinkConstraintForce(
int i,
const btVector3 &f);
369 void addLinkConstraintTorque(
int i,
const btVector3 &t);
371 void addJointTorque(
int i,
btScalar Q);
372 void addJointTorqueMultiDof(
int i,
int dof,
btScalar Q);
373 void addJointTorqueMultiDof(
int i,
const btScalar *Q);
377 const btVector3 &getLinkForce(
int i)
const;
378 const btVector3 &getLinkTorque(
int i)
const;
379 btScalar getJointTorque(
int i)
const;
380 btScalar *getJointTorqueMultiDof(
int i);
399 void computeAccelerationsArticulatedBodyAlgorithmMultiDof(
btScalar dt,
403 bool isConstraintPass,
404 bool jointFeedbackInWorldSpace,
405 bool jointFeedbackInJointFrame
430 for (
int dof = 0; dof < 6 + getNumDofs(); ++dof)
432 m_deltaV[dof] += delta_vee[dof] * multiplier;
437 for (
int dof = 0; dof < 6 + getNumDofs(); ++dof)
439 m_splitV[dof] += delta_vee[dof] * multiplier;
444 applyDeltaVeeMultiDof(&m_splitV[0], 1);
448 applyDeltaVeeMultiDof(&m_splitV[0], -1);
450 for (
int dof = 0; dof < 6 + getNumDofs(); ++dof)
457 applyDeltaVeeMultiDof(&m_deltaV[0], 1);
459 for (
int dof = 0; dof < 6 + getNumDofs(); ++dof)
483 for (
int dof = 0; dof < 6 + getNumDofs(); ++dof)
485 m_realBuf[dof] += delta_vee[dof] * multiplier;
486 btClamp(m_realBuf[dof], -m_maxCoordinateVelocity, m_maxCoordinateVelocity);
494 void predictPositionsMultiDof(
btScalar dt);
514 void fillConstraintJacobianMultiDof(
int link,
530 m_canSleep = canSleep;
546 m_canWakeup = canWakeup;
551 void checkMotionAndSleepIfRequired(
btScalar timestep);
553 bool hasFixedBase()
const;
555 bool isBaseKinematic()
const;
557 bool isBaseStaticOrKinematic()
const;
560 void setBaseDynamicType(
int dynamicType);
564 m_fixedBase = fixedBase;
583 m_links.resize(numLinks);
588 return m_linearDamping;
592 m_linearDamping = damp;
596 return m_angularDamping;
600 m_angularDamping = damp;
605 return m_useGyroTerm;
609 m_useGyroTerm = useGyro;
613 return m_maxCoordinateVelocity;
617 m_maxCoordinateVelocity = maxVel;
622 return m_maxAppliedImpulse;
626 m_maxAppliedImpulse = maxImp;
630 m_hasSelfCollision = hasSelfCollision;
634 return m_hasSelfCollision;
637 void finalizeMultiDof();
650 __posUpdated = updated;
656 return m_internalNeedsJointFeedback;
712 static void spatialTransform(
const btMatrix3x3 &rotation_matrix,
719 void setLinkDynamicType(
const int i,
int type);
721 bool isLinkStaticOrKinematic(
const int i)
const;
723 bool isLinkKinematic(
const int i)
const;
725 bool isLinkAndAllAncestorsStaticOrKinematic(
const int i)
const;
727 bool isLinkAndAllAncestorsKinematic(
const int i)
const;
738 int dofOffset = 0, cfgOffset = 0;
739 for (
int bidx = 0; bidx < m_links.size(); ++bidx)
741 m_links[bidx].m_dofOffset = dofOffset;
742 m_links[bidx].m_cfgOffset = cfgOffset;
743 dofOffset += m_links[bidx].m_dofCount;
744 cfgOffset += m_links[bidx].m_posVarCount;
void setBaseMass(btScalar mass)
const btVector3 getBaseVel() const
void setBaseName(const char *name)
memory of setBaseName needs to be manager by user
btScalar getLinearDamping() const
btMultiBody(const btMultiBody &)
void addBaseConstraintTorque(const btVector3 &t)
void * getUserPointer() const
users can point to their objects, userPointer is not used by Bullet
btMultiBodyLinkFloatData * m_links
bool isUsingGlobalVelocities() const
These spatial algebra classes are used for btMultiBody, see BulletDynamics/Featherstone.
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
int getCompanionId() const
void processDeltaVeeMultiDof2()
BT_DECLARE_ALIGNED_ALLOCATOR()
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
bool internalNeedsJointFeedback() const
btVector3DoubleData m_parentComToThisPivotOffset
btVector3 m_baseConstraintTorque
void setWorldToBaseRot(const btQuaternion &rot)
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btVector3FloatData m_absFrameTotVelocityBottom
const btQuaternion & getWorldToBaseRot() const
btQuaternion inverse() const
Return the inverse of this quaternion.
btVector3DoubleData m_linkInertia
btVector3FloatData m_absFrameLocVelocityTop
bool isPosUpdated() const
btVector3DoubleData m_absFrameTotVelocityTop
btAlignedObjectArray< btMatrix3x3 > m_matrixBuf
const char * getBaseName() const
btQuaternionDoubleData m_baseWorldOrientation
btMultiBodyLinkCollider * getBaseCollider()
void setNumLinks(int numLinks)
btMultiBodyLinkCollider * m_baseCollider
btScalar getAngularDamping() const
btAlignedObjectArray< btScalar > m_deltaV
bool getCanWakeup() const
btScalar getMaxCoordinateVelocity() const
btQuaternion inverse(const btQuaternion &q)
Return the inverse of a quaternion.
btMatrix3x3 m_cachedInertiaLowerRight
btTransform getBaseWorldTransform() const
const btScalar * getDeltaVelocityVector() const
btVector3FloatData m_jointAxisBottom[6]
bool isUsingRK4Integration() const
void setBaseVel(const btVector3 &vel)
btVector3FloatData m_baseAngularVelocity
btScalar m_maxCoordinateVelocity
void addBaseTorque(const btVector3 &t)
btVector3FloatData m_jointAxisTop[6]
void applyDeltaVeeMultiDof(const btScalar *delta_vee, btScalar multiplier)
bool m_cachedInertiaValid
void setInterpolateBasePos(const btVector3 &pos)
void setUserIndex(int index)
users can point to their objects, userPointer is not used by Bullet
void setBaseCollider(btMultiBodyLinkCollider *collider)
btScalar getMaxAppliedImpulse() const
bool getUseGyroTerm() const
void btClamp(T &a, const T &lb, const T &ub)
btVector3DoubleData m_absFrameLocVelocityBottom
btCollisionObjectFloatData * m_linkCollider
btVector3DoubleData m_absFrameLocVelocityTop
btQuaternionFloatData m_baseWorldOrientation
const btMultiBodyLinkCollider * getLinkCollider(int index) const
void setFixedBase(bool fixedBase)
btMultibodyLink & getLink(int index)
btVector3 m_baseConstraintForce
btVector3FloatData m_absFrameTotVelocityTop
bool m_internalNeedsJointFeedback
the m_needsJointFeedback gets updated/computed during the stepVelocitiesMultiDof and it for internal ...
btScalar m_maxAppliedImpulse
const btVector3 & getBaseInertia() const
void setLinearDamping(btScalar damp)
btVector3 getBaseOmega() const
void setCanWakeup(bool canWakeup)
virtual int calculateSerializeBufferSize() const
void addBaseForce(const btVector3 &f)
bool hasSelfCollision() const
void applyDeltaSplitVeeMultiDof(const btScalar *delta_vee, btScalar multiplier)
btMatrix3x3 m_cachedInertiaLowerLeft
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btScalar getBaseMass() const
void setBaseOmega(const btVector3 &omega)
btVector3DoubleData m_jointAxisBottom[6]
btVector3DoubleData m_baseLinearVelocity
btQuaternionDoubleData m_zeroRotParentToThis
btVector3FloatData m_absFrameLocVelocityBottom
btTransform getInterpolateBaseWorldTransform() const
btMatrix3x3 m_cachedInertiaTopLeft
btQuaternionFloatData m_zeroRotParentToThis
btVector3 m_basePos_interpolate
const btMultibodyLink & getLink(int index) const
btQuaternion m_baseQuat_interpolate
btVector3 can be used to represent 3D points and vectors.
btAlignedObjectArray< btScalar > m_splitV
btVector3DoubleData m_absFrameTotVelocityBottom
void setHasSelfCollision(bool hasSelfCollision)
int getNumPosVars() const
const btQuaternion & getInterpolateWorldToBaseRot() const
void setMaxCoordinateVelocity(btScalar maxVel)
btVector3DoubleData m_baseInertia
double m_jointMaxVelocity
btVector3FloatData m_parentComToThisPivotOffset
void setUseGyroTerm(bool useGyro)
void updateLinksDofOffsets()
void setCompanionId(int id)
#define ATTRIBUTE_ALIGNED16(a)
btVector3DoubleData m_baseWorldPosition
void setInterpolateBaseWorldTransform(const btTransform &tr)
void setPosUpdated(bool updated)
void operator=(const btMultiBody &)
void * m_userObjectPointer
void fillContactJacobianMultiDof(int link, const btVector3 &contact_point, const btVector3 &normal, btScalar *jac, btAlignedObjectArray< btScalar > &scratch_r, btAlignedObjectArray< btVector3 > &scratch_v, btAlignedObjectArray< btMatrix3x3 > &scratch_m) const
const btVector3 & getInterpolateBasePos() const
void setMaxAppliedImpulse(btScalar maxImp)
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
void setAngularDamping(btScalar damp)
btVector3DoubleData m_thisPivotToThisComOffset
void setUserPointer(void *userPointer)
users can point to their objects, userPointer is not used by Bullet
btAlignedObjectArray< btVector3 > m_vectorBuf
btVector3FloatData m_baseInertia
const btScalar * getVelocityVector() const
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btMatrix3x3 m_cachedInertiaTopRight
btVector3FloatData m_thisPivotToThisComOffset
btVector3FloatData m_linkInertia
void setBaseInertia(const btVector3 &inertia)
void setInterpolateWorldToBaseRot(const btQuaternion &rot)
void applyDeltaVeeMultiDof2(const btScalar *delta_vee, btScalar multiplier)
btAlignedObjectArray< btScalar > m_realBuf
void addBaseConstraintForce(const btVector3 &f)
btScalar m_angularDamping
const btVector3 & getBaseForce() const
btVector3FloatData m_baseWorldPosition
bool m_kinematic_calculate_velocity
const btScalar * getSplitVelocityVector() const
void setUserIndex2(int index)
void useGlobalVelocities(bool use)
void * m_userObjectPointer
users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPoin...
btVector3FloatData m_baseLinearVelocity
void setCanSleep(bool canSleep)
void useRK4Integration(bool use)
const btVector3 & getBasePos() const
btCollisionObjectDoubleData * m_baseCollider
btCollisionObjectDoubleData * m_linkCollider
btVector3DoubleData m_baseAngularVelocity
const btMultiBodyLinkCollider * getBaseCollider() const
const btVector3 & getBaseTorque() const
btAlignedObjectArray< btMultibodyLink > m_links
void setBasePos(const btVector3 &pos)
btMultiBodyLinkCollider * getLinkCollider(int index)
btMultiBodyLinkDoubleData * m_links
int getUserIndex2() const
btVector3DoubleData m_jointAxisTop[6]
btCollisionObjectFloatData * m_baseCollider
void setBaseWorldTransform(const btTransform &tr)