Bullet Collision Detection & Physics Library: btMultiBody.h Source File

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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