Bullet Collision Detection & Physics Library
btMultiBody.h
Go to the documentation of this file.
1 /*
2  * PURPOSE:
3  * Class representing an articulated rigid body. Stores the body's
4  * current state, allows forces and torques to be set, handles
5  * timestepping and implements Featherstone's algorithm.
6  *
7  * COPYRIGHT:
8  * Copyright (C) Stephen Thompson, <stephen@solarflare.org.uk>, 2011-2013
9  * Portions written By Erwin Coumans: connection to LCP solver, various multibody constraints, replacing Eigen math library by Bullet LinearMath and a dedicated 6x6 matrix inverse (solveImatrix)
10  * Portions written By Jakub Stepien: support for multi-DOF constraints, introduction of spatial algebra and several other improvements
11 
12  This software is provided 'as-is', without any express or implied warranty.
13  In no event will the authors be held liable for any damages arising from the use of this software.
14  Permission is granted to anyone to use this software for any purpose,
15  including commercial applications, and to alter it and redistribute it freely,
16  subject to the following restrictions:
17 
18  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
19  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
20  3. This notice may not be removed or altered from any source distribution.
21 
22  */
23 
24 #ifndef BT_MULTIBODY_H
25 #define BT_MULTIBODY_H
26 
27 #include "LinearMath/btScalar.h"
28 #include "LinearMath/btVector3.h"
30 #include "LinearMath/btMatrix3x3.h"
32 
34 #ifdef BT_USE_DOUBLE_PRECISION
35 #define btMultiBodyData btMultiBodyDoubleData
36 #define btMultiBodyDataName "btMultiBodyDoubleData"
37 #define btMultiBodyLinkData btMultiBodyLinkDoubleData
38 #define btMultiBodyLinkDataName "btMultiBodyLinkDoubleData"
39 #else
40 #define btMultiBodyData btMultiBodyFloatData
41 #define btMultiBodyDataName "btMultiBodyFloatData"
42 #define btMultiBodyLinkData btMultiBodyLinkFloatData
43 #define btMultiBodyLinkDataName "btMultiBodyLinkFloatData"
44 #endif //BT_USE_DOUBLE_PRECISION
45 
46 #include "btMultiBodyLink.h"
48 
51 {
52 public:
54 
55  //
56  // initialization
57  //
58 
59  btMultiBody(int n_links, // NOT including the base
60  btScalar mass, // mass of base
61  const btVector3 &inertia, // inertia of base, in base frame; assumed diagonal
62  bool fixedBase, // whether the base is fixed (true) or can move (false)
63  bool canSleep, bool deprecatedMultiDof = true);
64 
65  virtual ~btMultiBody();
66 
67  //note: fixed link collision with parent is always disabled
68  void setupFixed(int linkIndex,
69  btScalar mass,
70  const btVector3 &inertia,
71  int parent,
72  const btQuaternion &rotParentToThis,
73  const btVector3 &parentComToThisPivotOffset,
74  const btVector3 &thisPivotToThisComOffset, bool deprecatedDisableParentCollision = true);
75 
76  void setupPrismatic(int i,
77  btScalar mass,
78  const btVector3 &inertia,
79  int parent,
80  const btQuaternion &rotParentToThis,
81  const btVector3 &jointAxis,
82  const btVector3 &parentComToThisPivotOffset,
83  const btVector3 &thisPivotToThisComOffset,
84  bool disableParentCollision);
85 
86  void setupRevolute(int linkIndex, // 0 to num_links-1
87  btScalar mass,
88  const btVector3 &inertia,
89  int parentIndex,
90  const btQuaternion &rotParentToThis, // rotate points in parent frame to this frame, when q = 0
91  const btVector3 &jointAxis, // in my frame
92  const btVector3 &parentComToThisPivotOffset, // vector from parent COM to joint axis, in PARENT frame
93  const btVector3 &thisPivotToThisComOffset, // vector from joint axis to my COM, in MY frame
94  bool disableParentCollision = false);
95 
96  void setupSpherical(int linkIndex, // 0 to num_links-1
97  btScalar mass,
98  const btVector3 &inertia,
99  int parent,
100  const btQuaternion &rotParentToThis, // rotate points in parent frame to this frame, when q = 0
101  const btVector3 &parentComToThisPivotOffset, // vector from parent COM to joint axis, in PARENT frame
102  const btVector3 &thisPivotToThisComOffset, // vector from joint axis to my COM, in MY frame
103  bool disableParentCollision = false);
104 
105  void setupPlanar(int i, // 0 to num_links-1
106  btScalar mass,
107  const btVector3 &inertia,
108  int parent,
109  const btQuaternion &rotParentToThis, // rotate points in parent frame to this frame, when q = 0
110  const btVector3 &rotationAxis,
111  const btVector3 &parentComToThisComOffset, // vector from parent COM to this COM, in PARENT frame
112  bool disableParentCollision = false);
113 
114  const btMultibodyLink &getLink(int index) const
115  {
116  return m_links[index];
117  }
118 
120  {
121  return m_links[index];
122  }
123 
124  void setBaseCollider(btMultiBodyLinkCollider * collider) //collider can be NULL to disable collision for the base
125  {
126  m_baseCollider = collider;
127  }
129  {
130  return m_baseCollider;
131  }
133  {
134  return m_baseCollider;
135  }
136 
137  const btMultiBodyLinkCollider *getLinkCollider(int index) const
138  {
139  if (index >= 0 && index < getNumLinks())
140  {
141  return getLink(index).m_collider;
142  }
143  return 0;
144  }
145 
147  {
148  if (index >= 0 && index < getNumLinks())
149  {
150  return getLink(index).m_collider;
151  }
152  return 0;
153  }
154 
155  //
156  // get parent
157  // input: link num from 0 to num_links-1
158  // output: link num from 0 to num_links-1, OR -1 to mean the base.
159  //
160  int getParent(int link_num) const;
161 
162  //
163  // get number of m_links, masses, moments of inertia
164  //
165 
166  int getNumLinks() const { return m_links.size(); }
167  int getNumDofs() const { return m_dofCount; }
168  int getNumPosVars() const { return m_posVarCnt; }
169  btScalar getBaseMass() const { return m_baseMass; }
170  const btVector3 &getBaseInertia() const { return m_baseInertia; }
171  btScalar getLinkMass(int i) const;
172  const btVector3 &getLinkInertia(int i) const;
173 
174  //
175  // change mass (incomplete: can only change base mass and inertia at present)
176  //
177 
178  void setBaseMass(btScalar mass) { m_baseMass = mass; }
179  void setBaseInertia(const btVector3 &inertia) { m_baseInertia = inertia; }
180 
181  //
182  // get/set pos/vel/rot/omega for the base link
183  //
184 
185  const btVector3 &getBasePos() const { return m_basePos; } // in world frame
186  const btVector3 getBaseVel() const
187  {
188  return btVector3(m_realBuf[3], m_realBuf[4], m_realBuf[5]);
189  } // in world frame
191  {
192  return m_baseQuat;
193  } // rotates world vectors into base frame
194  btVector3 getBaseOmega() const { return btVector3(m_realBuf[0], m_realBuf[1], m_realBuf[2]); } // in world frame
195 
196  void setBasePos(const btVector3 &pos)
197  {
198  m_basePos = pos;
199  }
200 
202  {
203  setBasePos(tr.getOrigin());
204  setWorldToBaseRot(tr.getRotation().inverse());
205  }
206 
208  {
209  btTransform tr;
210  tr.setOrigin(getBasePos());
211  tr.setRotation(getWorldToBaseRot().inverse());
212  return tr;
213  }
214 
215  void setBaseVel(const btVector3 &vel)
216  {
217  m_realBuf[3] = vel[0];
218  m_realBuf[4] = vel[1];
219  m_realBuf[5] = vel[2];
220  }
222  {
223  m_baseQuat = rot; //m_baseQuat asumed to ba alias!?
224  }
225  void setBaseOmega(const btVector3 &omega)
226  {
227  m_realBuf[0] = omega[0];
228  m_realBuf[1] = omega[1];
229  m_realBuf[2] = omega[2];
230  }
231 
232  //
233  // get/set pos/vel for child m_links (i = 0 to num_links-1)
234  //
235 
236  btScalar getJointPos(int i) const;
237  btScalar getJointVel(int i) const;
238 
239  btScalar *getJointVelMultiDof(int i);
240  btScalar *getJointPosMultiDof(int i);
241 
242  const btScalar *getJointVelMultiDof(int i) const;
243  const btScalar *getJointPosMultiDof(int i) const;
244 
245  void setJointPos(int i, btScalar q);
246  void setJointVel(int i, btScalar qdot);
247  void setJointPosMultiDof(int i, const double *q);
248  void setJointVelMultiDof(int i, const double *qdot);
249  void setJointPosMultiDof(int i, const float *q);
250  void setJointVelMultiDof(int i, const float *qdot);
251 
252  //
253  // direct access to velocities as a vector of 6 + num_links elements.
254  // (omega first, then v, then joint velocities.)
255  //
257  {
258  return &m_realBuf[0];
259  }
260  /* btScalar * getVelocityVector()
261  {
262  return &real_buf[0];
263  }
264  */
265 
266  //
267  // get the frames of reference (positions and orientations) of the child m_links
268  // (i = 0 to num_links-1)
269  //
270 
271  const btVector3 &getRVector(int i) const; // vector from COM(parent(i)) to COM(i), in frame i's coords
272  const btQuaternion &getParentToLocalRot(int i) const; // rotates vectors in frame parent(i) to vectors in frame i.
273 
274  //
275  // transform vectors in local frame of link i to world frame (or vice versa)
276  //
277  btVector3 localPosToWorld(int i, const btVector3 &vec) const;
278  btVector3 localDirToWorld(int i, const btVector3 &vec) const;
279  btVector3 worldPosToLocal(int i, const btVector3 &vec) const;
280  btVector3 worldDirToLocal(int i, const btVector3 &vec) const;
281 
282  //
283  // transform a frame in local coordinate to a frame in world coordinate
284  //
285  btMatrix3x3 localFrameToWorld(int i, const btMatrix3x3 &mat) const;
286 
287  //
288  // calculate kinetic energy and angular momentum
289  // useful for debugging.
290  //
291 
292  btScalar getKineticEnergy() const;
293  btVector3 getAngularMomentum() const;
294 
295  //
296  // set external forces and torques. Note all external forces/torques are given in the WORLD frame.
297  //
298 
299  void clearForcesAndTorques();
300  void clearConstraintForces();
301 
302  void clearVelocities();
303 
304  void addBaseForce(const btVector3 &f)
305  {
306  m_baseForce += f;
307  }
308  void addBaseTorque(const btVector3 &t) { m_baseTorque += t; }
309  void addLinkForce(int i, const btVector3 &f);
310  void addLinkTorque(int i, const btVector3 &t);
311 
313  {
314  m_baseConstraintForce += f;
315  }
316  void addBaseConstraintTorque(const btVector3 &t) { m_baseConstraintTorque += t; }
317  void addLinkConstraintForce(int i, const btVector3 &f);
318  void addLinkConstraintTorque(int i, const btVector3 &t);
319 
320  void addJointTorque(int i, btScalar Q);
321  void addJointTorqueMultiDof(int i, int dof, btScalar Q);
322  void addJointTorqueMultiDof(int i, const btScalar *Q);
323 
324  const btVector3 &getBaseForce() const { return m_baseForce; }
325  const btVector3 &getBaseTorque() const { return m_baseTorque; }
326  const btVector3 &getLinkForce(int i) const;
327  const btVector3 &getLinkTorque(int i) const;
328  btScalar getJointTorque(int i) const;
329  btScalar *getJointTorqueMultiDof(int i);
330 
331  //
332  // dynamics routines.
333  //
334 
335  // timestep the velocities (given the external forces/torques set using addBaseForce etc).
336  // also sets up caches for calcAccelerationDeltas.
337  //
338  // Note: the caller must provide three vectors which are used as
339  // temporary scratch space. The idea here is to reduce dynamic
340  // memory allocation: the same scratch vectors can be re-used
341  // again and again for different Multibodies, instead of each
342  // btMultiBody allocating (and then deallocating) their own
343  // individual scratch buffers. This gives a considerable speed
344  // improvement, at least on Windows (where dynamic memory
345  // allocation appears to be fairly slow).
346  //
347 
348  void computeAccelerationsArticulatedBodyAlgorithmMultiDof(btScalar dt,
349  btAlignedObjectArray<btScalar> & scratch_r,
352  bool isConstraintPass,
353  bool jointFeedbackInWorldSpace,
354  bool jointFeedbackInJointFrame
355  );
356 
358  //void stepVelocitiesMultiDof(btScalar dt,
359  // btAlignedObjectArray<btScalar> & scratch_r,
360  // btAlignedObjectArray<btVector3> & scratch_v,
361  // btAlignedObjectArray<btMatrix3x3> & scratch_m,
362  // bool isConstraintPass = false)
363  //{
364  // computeAccelerationsArticulatedBodyAlgorithmMultiDof(dt, scratch_r, scratch_v, scratch_m, isConstraintPass, false, false);
365  //}
366 
367  // calcAccelerationDeltasMultiDof
368  // input: force vector (in same format as jacobian, i.e.:
369  // 3 torque values, 3 force values, num_links joint torque values)
370  // output: 3 omegadot values, 3 vdot values, num_links q_double_dot values
371  // (existing contents of output array are replaced)
372  // calcAccelerationDeltasMultiDof must have been called first.
373  void calcAccelerationDeltasMultiDof(const btScalar *force, btScalar *output,
375  btAlignedObjectArray<btVector3> &scratch_v) const;
376 
377  void applyDeltaVeeMultiDof2(const btScalar *delta_vee, btScalar multiplier)
378  {
379  for (int dof = 0; dof < 6 + getNumDofs(); ++dof)
380  {
381  m_deltaV[dof] += delta_vee[dof] * multiplier;
382  }
383  }
385  {
386  applyDeltaVeeMultiDof(&m_deltaV[0], 1);
387 
388  for (int dof = 0; dof < 6 + getNumDofs(); ++dof)
389  {
390  m_deltaV[dof] = 0.f;
391  }
392  }
393 
394  void applyDeltaVeeMultiDof(const btScalar *delta_vee, btScalar multiplier)
395  {
396  //for (int dof = 0; dof < 6 + getNumDofs(); ++dof)
397  // printf("%.4f ", delta_vee[dof]*multiplier);
398  //printf("\n");
399 
400  //btScalar sum = 0;
401  //for (int dof = 0; dof < 6 + getNumDofs(); ++dof)
402  //{
403  // sum += delta_vee[dof]*multiplier*delta_vee[dof]*multiplier;
404  //}
405  //btScalar l = btSqrt(sum);
406 
407  //if (l>m_maxAppliedImpulse)
408  //{
409  // multiplier *= m_maxAppliedImpulse/l;
410  //}
411 
412  for (int dof = 0; dof < 6 + getNumDofs(); ++dof)
413  {
414  m_realBuf[dof] += delta_vee[dof] * multiplier;
415  btClamp(m_realBuf[dof], -m_maxCoordinateVelocity, m_maxCoordinateVelocity);
416  }
417  }
418 
419  // timestep the positions (given current velocities).
420  void stepPositionsMultiDof(btScalar dt, btScalar *pq = 0, btScalar *pqd = 0);
421 
422  //
423  // contacts
424  //
425 
426  // This routine fills out a contact constraint jacobian for this body.
427  // the 'normal' supplied must be -n for body1 or +n for body2 of the contact.
428  // 'normal' & 'contact_point' are both given in world coordinates.
429 
431  const btVector3 &contact_point,
432  const btVector3 &normal,
433  btScalar *jac,
436  btAlignedObjectArray<btMatrix3x3> &scratch_m) const { fillConstraintJacobianMultiDof(link, contact_point, btVector3(0, 0, 0), normal, jac, scratch_r, scratch_v, scratch_m); }
437 
438  //a more general version of fillContactJacobianMultiDof which does not assume..
439  //.. that the constraint in question is contact or, to be more precise, constrains linear velocity only
440  void fillConstraintJacobianMultiDof(int link,
441  const btVector3 &contact_point,
442  const btVector3 &normal_ang,
443  const btVector3 &normal_lin,
444  btScalar *jac,
447  btAlignedObjectArray<btMatrix3x3> &scratch_m) const;
448 
449  //
450  // sleeping
451  //
452  void setCanSleep(bool canSleep)
453  {
454  m_canSleep = canSleep;
455  }
456 
457  bool getCanSleep() const
458  {
459  return m_canSleep;
460  }
461 
462  bool isAwake() const { return m_awake; }
463  void wakeUp();
464  void goToSleep();
465  void checkMotionAndSleepIfRequired(btScalar timestep);
466 
467  bool hasFixedBase() const
468  {
469  return m_fixedBase;
470  }
471 
472  int getCompanionId() const
473  {
474  return m_companionId;
475  }
476  void setCompanionId(int id)
477  {
478  //printf("for %p setCompanionId(%d)\n",this, id);
479  m_companionId = id;
480  }
481 
482  void setNumLinks(int numLinks) //careful: when changing the number of m_links, make sure to re-initialize or update existing m_links
483  {
484  m_links.resize(numLinks);
485  }
486 
488  {
489  return m_linearDamping;
490  }
492  {
493  m_linearDamping = damp;
494  }
496  {
497  return m_angularDamping;
498  }
500  {
501  m_angularDamping = damp;
502  }
503 
504  bool getUseGyroTerm() const
505  {
506  return m_useGyroTerm;
507  }
508  void setUseGyroTerm(bool useGyro)
509  {
510  m_useGyroTerm = useGyro;
511  }
513  {
514  return m_maxCoordinateVelocity;
515  }
517  {
518  m_maxCoordinateVelocity = maxVel;
519  }
520 
522  {
523  return m_maxAppliedImpulse;
524  }
526  {
527  m_maxAppliedImpulse = maxImp;
528  }
529  void setHasSelfCollision(bool hasSelfCollision)
530  {
531  m_hasSelfCollision = hasSelfCollision;
532  }
533  bool hasSelfCollision() const
534  {
535  return m_hasSelfCollision;
536  }
537 
538  void finalizeMultiDof();
539 
540  void useRK4Integration(bool use) { m_useRK4 = use; }
541  bool isUsingRK4Integration() const { return m_useRK4; }
542  void useGlobalVelocities(bool use) { m_useGlobalVelocities = use; }
543  bool isUsingGlobalVelocities() const { return m_useGlobalVelocities; }
544 
545  bool isPosUpdated() const
546  {
547  return __posUpdated;
548  }
549  void setPosUpdated(bool updated)
550  {
551  __posUpdated = updated;
552  }
553 
554  //internalNeedsJointFeedback is for internal use only
556  {
557  return m_internalNeedsJointFeedback;
558  }
559  void forwardKinematics(btAlignedObjectArray<btQuaternion> & scratch_q, btAlignedObjectArray<btVector3> & scratch_m);
560 
561  void compTreeLinkVelocities(btVector3 * omega, btVector3 * vel) const;
562 
563  void updateCollisionObjectWorldTransforms(btAlignedObjectArray<btQuaternion> & scratch_q, btAlignedObjectArray<btVector3> & scratch_m);
564 
565  virtual int calculateSerializeBufferSize() const;
566 
568  virtual const char *serialize(void *dataBuffer, class btSerializer *serializer) const;
569 
570  const char *getBaseName() const
571  {
572  return m_baseName;
573  }
575  void setBaseName(const char *name)
576  {
577  m_baseName = name;
578  }
579 
581  void *getUserPointer() const
582  {
583  return m_userObjectPointer;
584  }
585 
586  int getUserIndex() const
587  {
588  return m_userIndex;
589  }
590 
591  int getUserIndex2() const
592  {
593  return m_userIndex2;
594  }
596  void setUserPointer(void *userPointer)
597  {
598  m_userObjectPointer = userPointer;
599  }
600 
602  void setUserIndex(int index)
603  {
604  m_userIndex = index;
605  }
606 
607  void setUserIndex2(int index)
608  {
609  m_userIndex2 = index;
610  }
611 
612  static void spatialTransform(const btMatrix3x3 &rotation_matrix, // rotates vectors in 'from' frame to vectors in 'to' frame
613  const btVector3 &displacement, // vector from origin of 'from' frame to origin of 'to' frame, in 'to' coordinates
614  const btVector3 &top_in, // top part of input vector
615  const btVector3 &bottom_in, // bottom part of input vector
616  btVector3 &top_out, // top part of output vector
617  btVector3 &bottom_out); // bottom part of output vector
618 
619 
620 
621 private:
622  btMultiBody(const btMultiBody &); // not implemented
623  void operator=(const btMultiBody &); // not implemented
624 
625  void solveImatrix(const btVector3 &rhs_top, const btVector3 &rhs_bot, btScalar result[6]) const;
626  void solveImatrix(const btSpatialForceVector &rhs, btSpatialMotionVector &result) const;
627 
629  {
630  int dofOffset = 0, cfgOffset = 0;
631  for (int bidx = 0; bidx < m_links.size(); ++bidx)
632  {
633  m_links[bidx].m_dofOffset = dofOffset;
634  m_links[bidx].m_cfgOffset = cfgOffset;
635  dofOffset += m_links[bidx].m_dofCount;
636  cfgOffset += m_links[bidx].m_posVarCount;
637  }
638  }
639 
640  void mulMatrix(btScalar * pA, btScalar * pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const;
641 
642 private:
644  const char *m_baseName; //memory needs to be manager by user!
645 
646  btVector3 m_basePos; // position of COM of base (world frame)
647  btQuaternion m_baseQuat; // rotates world points into base frame
648 
649  btScalar m_baseMass; // mass of the base
650  btVector3 m_baseInertia; // inertia of the base (in local frame; diagonal)
651 
652  btVector3 m_baseForce; // external force applied to base. World frame.
653  btVector3 m_baseTorque; // external torque applied to base. World frame.
654 
655  btVector3 m_baseConstraintForce; // external force applied to base. World frame.
656  btVector3 m_baseConstraintTorque; // external torque applied to base. World frame.
657 
658  btAlignedObjectArray<btMultibodyLink> m_links; // array of m_links, excluding the base. index from 0 to num_links-1.
659 
660  //
661  // realBuf:
662  // offset size array
663  // 0 6 + num_links v (base_omega; base_vel; joint_vels) MULTIDOF [sysdof x sysdof for D matrices (TOO MUCH!) + pos_delta which is sys-cfg sized]
664  // 6+num_links num_links D
665  //
666  // vectorBuf:
667  // offset size array
668  // 0 num_links h_top
669  // num_links num_links h_bottom
670  //
671  // matrixBuf:
672  // offset size array
673  // 0 num_links+1 rot_from_parent
674  //
679 
685 
687 
688  // Sleep parameters.
689  bool m_awake;
692 
696 
704 
706  int m_dofCount, m_posVarCnt;
707 
708  bool m_useRK4, m_useGlobalVelocities;
709  //for global velocities, see 8.3.2B Proposed resolution in Jakub Stepien PhD Thesis
710  //https://drive.google.com/file/d/0Bz3vEa19XOYGNWdZWGpMdUdqVmZ5ZVBOaEh4ZnpNaUxxZFNV/view?usp=sharing
711 
714 };
715 
717 {
723 
724  btVector3DoubleData m_linkInertia; // inertia of the base (in local frame; diagonal)
729 
730  double m_linkMass;
733 
736  double m_jointPos[7];
737  double m_jointVel[6];
738  double m_jointTorque[6];
739 
746 
747  char *m_linkName;
748  char *m_jointName;
751 };
752 
754 {
760  btVector3FloatData m_linkInertia; // inertia of the base (in local frame; diagonal)
765 
767  float m_linkMass;
770 
771  float m_jointPos[7];
772  float m_jointVel[6];
773  float m_jointTorque[6];
781 
782  char *m_linkName;
783  char *m_jointName;
786 };
787 
790 {
795  btVector3DoubleData m_baseInertia; // inertia of the base (in local frame; diagonal)
796  double m_baseMass;
798  char m_padding[4];
799 
800  char *m_baseName;
803 };
804 
807 {
812 
813  btVector3FloatData m_baseInertia; // inertia of the base (in local frame; diagonal)
814  float m_baseMass;
816 
817  char *m_baseName;
820 };
821 
822 #endif
void setOrigin(const btVector3 &origin)
Set the translational element.
Definition: btTransform.h:146
btMultiBodyLinkCollider * getLinkCollider(int index)
Definition: btMultiBody.h:146
void setCanSleep(bool canSleep)
Definition: btMultiBody.h:452
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
const btVector3 & getBasePos() const
Definition: btMultiBody.h:185
btAlignedObjectArray< btMatrix3x3 > m_matrixBuf
Definition: btMultiBody.h:678
btQuaternionDoubleData m_baseWorldOrientation
Definition: btMultiBody.h:792
bool m_useGyroTerm
Definition: btMultiBody.h:700
int getNumLinks() const
Definition: btMultiBody.h:166
btVector3 m_baseForce
Definition: btMultiBody.h:652
btMultiBodyLinkCollider * getBaseCollider()
Definition: btMultiBody.h:132
btVector3DoubleData m_absFrameLocVelocityTop
Definition: btMultiBody.h:727
bool internalNeedsJointFeedback() const
Definition: btMultiBody.h:555
btVector3FloatData m_baseLinearVelocity
Definition: btMultiBody.h:810
void setNumLinks(int numLinks)
Definition: btMultiBody.h:482
const btMultiBodyLinkCollider * getBaseCollider() const
Definition: btMultiBody.h:128
btMultiBodyLinkCollider * m_baseCollider
Definition: btMultiBody.h:643
btScalar m_baseMass
Definition: btMultiBody.h:649
int getUserIndex() const
Definition: btMultiBody.h:586
int getUserIndex2() const
Definition: btMultiBody.h:591
bool m_fixedBase
Definition: btMultiBody.h:686
btVector3DoubleData m_absFrameLocVelocityBottom
Definition: btMultiBody.h:728
These spatial algebra classes are used for btMultiBody, see BulletDynamics/Featherstone.
bool isUsingGlobalVelocities() const
Definition: btMultiBody.h:543
btVector3DoubleData m_jointAxisTop[6]
Definition: btMultiBody.h:721
btScalar m_maxCoordinateVelocity
Definition: btMultiBody.h:702
btVector3FloatData m_jointAxisTop[6]
Definition: btMultiBody.h:758
void addBaseTorque(const btVector3 &t)
Definition: btMultiBody.h:308
bool getCanSleep() const
Definition: btMultiBody.h:457
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btMultiBody.h:789
btScalar getAngularDamping() const
Definition: btMultiBody.h:495
void * getUserPointer() const
users can point to their objects, userPointer is not used by Bullet
Definition: btMultiBody.h:581
btQuaternionDoubleData m_zeroRotParentToThis
Definition: btMultiBody.h:718
btQuaternion getRotation() const
Return a quaternion representing the rotation.
Definition: btTransform.h:118
btVector3FloatData m_parentComToThisPivotOffset
Definition: btMultiBody.h:756
const btQuaternion & getWorldToBaseRot() const
Definition: btMultiBody.h:190
int m_userIndex2
Definition: btMultiBody.h:694
btMatrix3x3 m_cachedInertiaLowerRight
Definition: btMultiBody.h:683
btVector3DoubleData m_absFrameTotVelocityBottom
Definition: btMultiBody.h:726
btCollisionObjectFloatData * m_linkCollider
Definition: btMultiBody.h:784
bool isPosUpdated() const
Definition: btMultiBody.h:545
void setUserIndex(int index)
users can point to their objects, userPointer is not used by Bullet
Definition: btMultiBody.h:602
bool isUsingRK4Integration() const
Definition: btMultiBody.h:541
void setBaseCollider(btMultiBodyLinkCollider *collider)
Definition: btMultiBody.h:124
int getCompanionId() const
Definition: btMultiBody.h:472
btScalar getMaxAppliedImpulse() const
Definition: btMultiBody.h:521
bool getUseGyroTerm() const
Definition: btMultiBody.h:504
void btClamp(T &a, const T &lb, const T &ub)
Definition: btMinMax.h:57
btVector3 m_baseConstraintTorque
Definition: btMultiBody.h:656
void applyDeltaVeeMultiDof(const btScalar *delta_vee, btScalar multiplier)
Definition: btMultiBody.h:394
void setWorldToBaseRot(const btQuaternion &rot)
Definition: btMultiBody.h:221
btQuaternion inverse(const btQuaternion &q)
Return the inverse of a quaternion.
Definition: btQuaternion.h:909
btScalar m_maxAppliedImpulse
Definition: btMultiBody.h:701
btVector3FloatData m_absFrameTotVelocityTop
Definition: btMultiBody.h:761
btAlignedObjectArray< btScalar > m_deltaV
Definition: btMultiBody.h:675
btScalar getMaxCoordinateVelocity() const
Definition: btMultiBody.h:512
btVector3 getBaseOmega() const
Definition: btMultiBody.h:194
void setBaseVel(const btVector3 &vel)
Definition: btMultiBody.h:215
btVector3 m_baseTorque
Definition: btMultiBody.h:653
const char * getBaseName() const
Definition: btMultiBody.h:570
btVector3DoubleData m_baseLinearVelocity
Definition: btMultiBody.h:793
btQuaternion inverse() const
Return the inverse of this quaternion.
Definition: btQuaternion.h:497
btMatrix3x3 m_cachedInertiaTopLeft
Definition: btMultiBody.h:680
int m_companionId
Definition: btMultiBody.h:697
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
void setHasSelfCollision(bool hasSelfCollision)
Definition: btMultiBody.h:529
void setMaxCoordinateVelocity(btScalar maxVel)
Definition: btMultiBody.h:516
const btVector3 & getBaseInertia() const
Definition: btMultiBody.h:170
btVector3 & getOrigin()
Return the origin vector translation.
Definition: btTransform.h:113
virtual int calculateSerializeBufferSize() const
btTransform getBaseWorldTransform() const
Definition: btMultiBody.h:207
bool isAwake() const
Definition: btMultiBody.h:462
void setUseGyroTerm(bool useGyro)
Definition: btMultiBody.h:508
btQuaternion m_baseQuat
Definition: btMultiBody.h:647
btMatrix3x3 m_cachedInertiaLowerLeft
Definition: btMultiBody.h:682
btScalar getBaseMass() const
Definition: btMultiBody.h:169
void setCompanionId(int id)
Definition: btMultiBody.h:476
void setBaseOmega(const btVector3 &omega)
Definition: btMultiBody.h:225
bool m_hasSelfCollision
Definition: btMultiBody.h:703
btMultibodyLink & getLink(int index)
Definition: btMultiBody.h:119
#define output
int getNumDofs() const
Definition: btMultiBody.h:167
void setRotation(const btQuaternion &q)
Set the rotational element by btQuaternion.
Definition: btTransform.h:160
bool m_cachedInertiaValid
Definition: btMultiBody.h:684
bool hasFixedBase() const
Definition: btMultiBody.h:467
btQuaternionFloatData m_zeroRotParentToThis
Definition: btMultiBody.h:755
btVector3FloatData m_baseInertia
Definition: btMultiBody.h:813
void * m_userObjectPointer
Definition: btMultiBody.h:693
btScalar m_sleepTimer
Definition: btMultiBody.h:691
btVector3FloatData m_jointAxisBottom[6]
Definition: btMultiBody.h:759
btVector3 m_basePos
Definition: btMultiBody.h:646
void setAngularDamping(btScalar damp)
Definition: btMultiBody.h:499
btVector3FloatData m_thisPivotToThisComOffset
Definition: btMultiBody.h:757
const btMultiBodyLinkCollider * getLinkCollider(int index) const
Definition: btMultiBody.h:137
btVector3FloatData m_absFrameLocVelocityBottom
Definition: btMultiBody.h:764
btVector3DoubleData m_baseInertia
Definition: btMultiBody.h:795
btVector3 m_baseConstraintForce
Definition: btMultiBody.h:655
btVector3DoubleData m_baseWorldPosition
Definition: btMultiBody.h:791
const btMultibodyLink & getLink(int index) const
Definition: btMultiBody.h:114
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:84
bool m_internalNeedsJointFeedback
the m_needsJointFeedback gets updated/computed during the stepVelocitiesMultiDof and it for internal ...
Definition: btMultiBody.h:713
int getNumPosVars() const
Definition: btMultiBody.h:168
btVector3 m_baseInertia
Definition: btMultiBody.h:650
btVector3FloatData m_absFrameTotVelocityBottom
Definition: btMultiBody.h:762
void setLinearDamping(btScalar damp)
Definition: btMultiBody.h:491
const char * m_baseName
Definition: btMultiBody.h:644
btQuaternionFloatData m_baseWorldOrientation
Definition: btMultiBody.h:809
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:28
void addBaseForce(const btVector3 &f)
Definition: btMultiBody.h:304
btAlignedObjectArray< btScalar > m_realBuf
Definition: btMultiBody.h:676
bool hasSelfCollision() const
Definition: btMultiBody.h:533
void updateLinksDofOffsets()
Definition: btMultiBody.h:628
void setMaxAppliedImpulse(btScalar maxImp)
Definition: btMultiBody.h:525
btMultiBodyLinkFloatData * m_links
Definition: btMultiBody.h:818
void setUserPointer(void *userPointer)
users can point to their objects, userPointer is not used by Bullet
Definition: btMultiBody.h:596
void setUserIndex2(int index)
Definition: btMultiBody.h:607
btScalar m_linearDamping
Definition: btMultiBody.h:698
btVector3FloatData m_baseAngularVelocity
Definition: btMultiBody.h:811
btCollisionObjectDoubleData * m_linkCollider
Definition: btMultiBody.h:749
void setBaseInertia(const btVector3 &inertia)
Definition: btMultiBody.h:179
void applyDeltaVeeMultiDof2(const btScalar *delta_vee, btScalar multiplier)
Definition: btMultiBody.h:377
void setPosUpdated(bool updated)
Definition: btMultiBody.h:549
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:405
btVector3DoubleData m_absFrameTotVelocityTop
Definition: btMultiBody.h:725
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
void * m_userObjectPointer
users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPoin...
const btVector3 & getBaseTorque() const
Definition: btMultiBody.h:325
btAlignedObjectArray< btVector3 > m_vectorBuf
Definition: btMultiBody.h:677
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition: btMatrix3x3.h:46
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btMultiBody.h:806
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
Definition: btQuaternion.h:49
void addBaseConstraintForce(const btVector3 &f)
Definition: btMultiBody.h:312
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
Definition: btMultiBody.h:430
void setBaseMass(btScalar mass)
Definition: btMultiBody.h:178
btVector3FloatData m_linkInertia
Definition: btMultiBody.h:760
btVector3DoubleData m_baseAngularVelocity
Definition: btMultiBody.h:794
const btVector3 & getBaseForce() const
Definition: btMultiBody.h:324
bool __posUpdated
Definition: btMultiBody.h:705
btAlignedObjectArray< btMultibodyLink > m_links
Definition: btMultiBody.h:658
btVector3DoubleData m_linkInertia
Definition: btMultiBody.h:724
void setBasePos(const btVector3 &pos)
Definition: btMultiBody.h:196
btVector3DoubleData m_thisPivotToThisComOffset
Definition: btMultiBody.h:720
void addBaseConstraintTorque(const btVector3 &t)
Definition: btMultiBody.h:316
void useGlobalVelocities(bool use)
Definition: btMultiBody.h:542
const btScalar * getVelocityVector() const
Definition: btMultiBody.h:256
btMultiBodyLinkDoubleData * m_links
Definition: btMultiBody.h:801
btCollisionObjectFloatData * m_baseCollider
Definition: btMultiBody.h:819
btMatrix3x3 m_cachedInertiaTopRight
Definition: btMultiBody.h:681
btVector3DoubleData m_parentComToThisPivotOffset
Definition: btMultiBody.h:719
void useRK4Integration(bool use)
Definition: btMultiBody.h:540
btVector3FloatData m_baseWorldPosition
Definition: btMultiBody.h:808
void setBaseWorldTransform(const btTransform &tr)
Definition: btMultiBody.h:201
void processDeltaVeeMultiDof2()
Definition: btMultiBody.h:384
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:294
btScalar m_angularDamping
Definition: btMultiBody.h:699
btVector3DoubleData m_jointAxisBottom[6]
Definition: btMultiBody.h:722
btVector3FloatData m_absFrameLocVelocityTop
Definition: btMultiBody.h:763
bool m_canSleep
Definition: btMultiBody.h:690
btScalar getLinearDamping() const
Definition: btMultiBody.h:487
const btVector3 getBaseVel() const
Definition: btMultiBody.h:186
void setBaseName(const char *name)
memory of setBaseName needs to be manager by user
Definition: btMultiBody.h:575
btCollisionObjectDoubleData * m_baseCollider
Definition: btMultiBody.h:802