BulletLink.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: Bullet Link class
18  * Author: Nate Koenig
19  * Date: 15 May 2009
20  */
21 
22 #ifndef _BULLETLINK_HH_
23 #define _BULLETLINK_HH_
24 
27 #include "gazebo/physics/Link.hh"
28 #include "gazebo/util/system.hh"
29 
30 class btRigidBody;
31 
32 namespace gazebo
33 {
34  namespace physics
35  {
36  class BulletMotionState;
37 
40 
42  class GZ_PHYSICS_VISIBLE BulletLink : public Link
43  {
45  public: BulletLink(EntityPtr _parent);
46 
48  public: virtual ~BulletLink();
49 
50  // Documentation inherited.
51  public: virtual void Load(sdf::ElementPtr _ptr);
52 
53  // Documentation inherited.
54  public: virtual void Init();
55 
56  // Documentation inherited.
57  public: virtual void Fini();
58 
59  // Documentation inherited.
60  public: virtual void OnPoseChange();
61 
62  // Documentation inherited.
63  public: virtual void SetEnabled(bool _enable) const;
64 
65  // Documentation inherited.
66  public: virtual bool GetEnabled() const;
67 
68  // Documentation inherited.
69  public: virtual void SetLinearVel(const math::Vector3 &_vel);
70 
71  // Documentation inherited.
72  public: virtual void SetAngularVel(const math::Vector3 &_vel);
73 
74  // Documentation inherited.
75  public: virtual void SetForce(const math::Vector3 &_force);
76 
77  // Documentation inherited.
78  public: virtual void SetTorque(const math::Vector3 &_torque);
79 
80  // Documentation inherited
81  public: virtual math::Vector3 GetWorldLinearVel(
82  const math::Vector3 &_offset) const;
83 
84  // Documentation inherited
85  public: virtual math::Vector3 GetWorldLinearVel(
86  const math::Vector3 &_offset,
87  const math::Quaternion &_q) const;
88 
89  // Documentation inherited
90  public: virtual math::Vector3 GetWorldCoGLinearVel() const;
91 
92  // Documentation inherited.
93  public: virtual math::Vector3 GetWorldAngularVel() const;
94 
95  // Documentation inherited.
96  public: virtual math::Vector3 GetWorldForce() const;
97 
98  // Documentation inherited.
99  public: virtual math::Vector3 GetWorldTorque() const;
100 
101  // Documentation inherited.
102  public: virtual void SetGravityMode(bool _mode);
103 
104  // Documentation inherited.
105  public: virtual bool GetGravityMode() const;
106 
107  // Documentation inherited.
108  public: virtual void SetSelfCollide(bool _collide);
109 
112  public: btRigidBody *GetBulletLink() const;
113 
116  public: void ClearCollisionCache();
117 
118  // Documentation inherited.
119  public: virtual void SetLinearDamping(double _damping);
120 
121  // Documentation inherited.
122  public: virtual void SetAngularDamping(double _damping);
123 
125  /*public: void SetCollisionRelativePose(BulletCollision *collision,
126  const math::Pose &newPose);
127  */
128 
129  // Documentation inherited.
130  public: virtual void AddForce(const math::Vector3 &_force);
131 
132  // Documentation inherited.
133  public: virtual void AddRelativeForce(const math::Vector3 &_force);
134 
135  // Documentation inherited.
136  public: virtual void AddForceAtWorldPosition(const math::Vector3 &_force,
137  const math::Vector3 &_pos);
138 
139  // Documentation inherited.
140  public: virtual void AddForceAtRelativePosition(
141  const math::Vector3 &_force,
142  const math::Vector3 &_relpos);
143 
144  // Documentation inherited
145  public: virtual void AddLinkForce(const math::Vector3 &_force,
146  const math::Vector3 &_offset = math::Vector3::Zero);
147 
148  // Documentation inherited.
149  public: virtual void AddTorque(const math::Vector3 &_torque);
150 
151  // Documentation inherited.
152  public: virtual void AddRelativeTorque(const math::Vector3 &_torque);
153 
154  // Documentation inherited.
155  public: virtual void SetAutoDisable(bool _disable);
156 
157  // Documentation inherited
158  public: virtual void SetLinkStatic(bool _static);
159 
160  // Documentation inherited.
161  public: virtual void UpdateMass();
162 
165  private: btCollisionShape *compoundShape;
166 
170 
172  private: btRigidBody *rigidLink;
173 
175  private: BulletPhysicsPtr bulletPhysics;
176  };
178  }
179 }
180 #endif
boost::shared_ptr< BulletMotionState > BulletMotionStatePtr
Definition: BulletTypes.hh:44
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
boost::shared_ptr< BulletPhysics > BulletPhysicsPtr
Definition: BulletTypes.hh:45
Bullet wrapper forward declarations and typedefs.
A quaternion class.
Definition: Quaternion.hh:42
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:85
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
static const Vector3 Zero
math::Vector3(0, 0, 0)
Definition: Vector3.hh:42