BulletLink.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 
115  public: void RemoveAndAddBody() const;
116 
119  public: void ClearCollisionCache();
120 
121  // Documentation inherited.
122  public: virtual void SetLinearDamping(double _damping);
123 
124  // Documentation inherited.
125  public: virtual void SetAngularDamping(double _damping);
126 
128  /*public: void SetCollisionRelativePose(BulletCollision *collision,
129  const math::Pose &newPose);
130  */
131 
132  // Documentation inherited.
133  public: virtual void AddForce(const math::Vector3 &_force);
134 
135  // Documentation inherited.
136  public: virtual void AddRelativeForce(const math::Vector3 &_force);
137 
138  // Documentation inherited.
139  public: virtual void AddForceAtWorldPosition(const math::Vector3 &_force,
140  const math::Vector3 &_pos);
141 
142  // Documentation inherited.
143  public: virtual void AddForceAtRelativePosition(
144  const math::Vector3 &_force,
145  const math::Vector3 &_relpos);
146 
147  // Documentation inherited
148  public: virtual void AddLinkForce(const math::Vector3 &_force,
149  const math::Vector3 &_offset = math::Vector3::Zero);
150 
151  // Documentation inherited.
152  public: virtual void AddTorque(const math::Vector3 &_torque);
153 
154  // Documentation inherited.
155  public: virtual void AddRelativeTorque(const math::Vector3 &_torque);
156 
157  // Documentation inherited.
158  public: virtual void SetAutoDisable(bool _disable);
159 
160  // Documentation inherited
161  public: virtual void SetLinkStatic(bool _static);
162 
163  // Documentation inherited.
164  public: virtual void UpdateMass();
165 
168  private: btCollisionShape *compoundShape;
169 
173 
175  private: btRigidBody *rigidLink;
176 
178  private: BulletPhysicsPtr bulletPhysics;
179  };
181  }
182 }
183 #endif
boost::shared_ptr< BulletMotionState > BulletMotionStatePtr
Definition: BulletTypes.hh:44
Forward declarations for the common classes.
Definition: Animation.hh:33
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:80
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