Bullet Collision Detection & Physics Library
btMultiBodyLink.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
16 #ifndef BT_MULTIBODY_LINK_H
17 #define BT_MULTIBODY_LINK_H
18 
20 #include "LinearMath/btVector3.h"
22 
24 {
26 };
27 //
28 // Link struct
29 //
30 
32 {
33 
35 
37 
38  btScalar mass; // mass of link
39  btVector3 inertia; // inertia of link (local frame; diagonal)
40 
41  int parent; // index of the parent link (assumed to be < index of this link), or -1 if parent is the base link.
42 
43  btQuaternion zero_rot_parent_to_this; // rotates vectors in parent-frame to vectors in local-frame (when q=0). constant.
44 
45  // "axis" = spatial joint axis (Mirtich Defn 9 p104). (expressed in local frame.) constant.
46  // for prismatic: axis_top = zero;
47  // axis_bottom = unit vector along the joint axis.
48  // for revolute: axis_top = unit vector along the rotation axis (u);
49  // axis_bottom = u cross d_vector.
52 
53  btVector3 d_vector; // vector from the inboard joint pos to this link's COM. (local frame.) constant. set for revolute joints only.
54 
55  // e_vector is constant, but depends on the joint type
56  // prismatic: vector from COM of parent to COM of this link, WHEN Q = 0. (local frame.)
57  // revolute: vector from parent's COM to the pivot point, in PARENT's frame.
59 
60  bool is_revolute; // true = revolute, false = prismatic
61 
62  btQuaternion cached_rot_parent_to_this; // rotates vectors in parent frame to vectors in local frame
63  btVector3 cached_r_vector; // vector from COM of parent to COM of this link, in local frame.
64 
65  btVector3 applied_force; // In WORLD frame
66  btVector3 applied_torque; // In WORLD frame
68 
70  int m_flags;
71 
72  // ctor: set some sensible defaults
74  : joint_pos(0),
75  mass(1),
76  parent(-1),
77  zero_rot_parent_to_this(1, 0, 0, 0),
78  is_revolute(false),
79  cached_rot_parent_to_this(1, 0, 0, 0),
80  joint_torque(0),
81  m_collider(0),
82  m_flags(0)
83  {
84  inertia.setValue(1, 1, 1);
85  axis_top.setValue(0, 0, 0);
86  axis_bottom.setValue(1, 0, 0);
87  d_vector.setValue(0, 0, 0);
88  e_vector.setValue(0, 0, 0);
89  cached_r_vector.setValue(0, 0, 0);
90  applied_force.setValue( 0, 0, 0);
91  applied_torque.setValue(0, 0, 0);
92  }
93 
94  // routine to update cached_rot_parent_to_this and cached_r_vector
95  void updateCache()
96  {
97  if (is_revolute)
98  {
101  } else
102  {
103  // cached_rot_parent_to_this never changes, so no need to update
105  }
106  }
107 };
108 
109 
110 #endif //BT_MULTIBODY_LINK_H
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
btVector3 quatRotate(const btQuaternion &rotation, const btVector3 &v)
Definition: btQuaternion.h:866
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
Definition: btQuaternion.h:48
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:266