All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BulletLink.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Nate Koenig
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 "physics/Link.hh"
28 
29 class btRigidBody;
30 
31 namespace gazebo
32 {
33  namespace physics
34  {
35  class BulletMotionState;
36 
41 
43  class BulletLink : public Link
44  {
46  public: BulletLink(EntityPtr _parent);
47 
49  public: virtual ~BulletLink();
50 
52  public: virtual void Load(sdf::ElementPtr _ptr);
53 
55  public: virtual void Init();
56 
58  public: virtual void Fini();
59 
61  public: virtual void Update();
62 
65  public: virtual void OnPoseChange();
66 
68  public: virtual void SetEnabled(bool enable) const;
69 
71  public: virtual bool GetEnabled() const {return true;}
72 
74  public: virtual void UpdateCoM();
75 
77  public: virtual void SetLinearVel(const math::Vector3 &vel);
78 
80  public: virtual void SetAngularVel(const math::Vector3 &vel);
81 
83  public: virtual void SetForce(const math::Vector3 &force);
84 
86  public: virtual void SetTorque(const math::Vector3 &force);
87 
89  public: virtual math::Vector3 GetWorldLinearVel() const;
90 
92  public: virtual math::Vector3 GetWorldAngularVel() const;
93 
95  public: virtual math::Vector3 GetWorldForce() const;
96 
98  public: virtual math::Vector3 GetWorldTorque() const;
99 
101  public: virtual void SetGravityMode(bool mode);
102 
104  public: virtual bool GetGravityMode();
105 
107  public: void SetSelfCollide(bool collide);
108 
110  public: btRigidBody *GetBulletLink() const;
111 
113  public: virtual void SetLinearDamping(double damping);
114 
116  public: virtual void SetAngularDamping(double damping);
117 
119  /*public: void SetCollisionRelativePose(BulletCollision *collision,
120  const math::Pose &newPose);
121  */
122 
124  public: virtual void AddForce(const math::Vector3 &_force);
125 
128  public: virtual void AddRelativeForce(const math::Vector3 &_force);
129 
131  public: virtual void AddForceAtWorldPosition(const math::Vector3 &_force,
132  const math::Vector3 &_pos);
133 
136  public: virtual void AddForceAtRelativePosition(
137  const math::Vector3 &_force,
138  const math::Vector3 &_relpos);
139 
141  public: virtual void AddTorque(const math::Vector3 &_torque);
142 
145  public: virtual void AddRelativeTorque(const math::Vector3 &_torque);
146 
148  public: virtual void SetAutoDisable(bool _disable);
149 
150  private: btCompoundShape *compoundShape;
151  private: BulletMotionState *motionState;
152  private: btRigidBody *rigidLink;
153  private: BulletPhysicsPtr bulletPhysics;
154  protected: math::Pose pose;
155  };
157  }
158 }
159 #endif