All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BulletPhysics.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: The Bullet physics engine wrapper
18  * Author: Nate Koenig
19  * Date: 11 June 2009
20  */
21 
22 #ifndef BULLETPHYSICS_HH
23 #define BULLETPHYSICS_HH
24 #include <string>
25 
26 #include <boost/thread/thread.hpp>
27 #include <boost/thread/mutex.hpp>
28 
30 #include "physics/PhysicsEngine.hh"
31 #include "physics/Collision.hh"
32 #include "physics/Shape.hh"
33 
34 namespace gazebo
35 {
36  namespace physics
37  {
38  class Entity;
39  class XMLConfigNode;
40  class Mass;
41 
45 
48  {
50  public: BulletPhysics(WorldPtr _world);
51 
53  public: virtual ~BulletPhysics();
54 
56  public: virtual void Load(sdf::ElementPtr _sdf);
57 
59  public: virtual void Init();
60 
62  public: virtual void InitForThread();
63 
65  public: virtual void UpdateCollision();
66 
68  public: virtual void UpdatePhysics();
69 
71  public: virtual void Fini();
72 
74  public: virtual void SetStepTime(double _value);
75 
77  public: virtual double GetStepTime();
78 
80  public: virtual LinkPtr CreateLink(ModelPtr _parent);
81 
83  public: virtual CollisionPtr CreateCollision(const std::string &_type,
84  LinkPtr _body);
85 
87  public: virtual JointPtr CreateJoint(const std::string &_type,
88  ModelPtr _parent);
89 
90  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
91  CollisionPtr _collision);
92 
94  // public: virtual PhysicsRaySensor *CreateRaySensor(Link *body);
95 
97  public: virtual void ConvertMass(InertialPtr _inertial,
98  void *_engineMass);
99 
101  public: virtual void ConvertMass(void *_engineMass,
102  InertialPtr _inertial);
103 
105  public: static math::Pose ConvertPose(const btTransform &_bt);
106 
108  public: static btTransform ConvertPose(const math::Pose &_pose);
109 
111  public: btDynamicsWorld *GetDynamicsWorld() const
112  {return this->dynamicsWorld;}
113 
115  public: virtual void SetGravity(const gazebo::math::Vector3 &gravity);
116 
117  public: virtual void DebugPrint() const;
118 
119  private: btBroadphaseInterface *broadPhase;
120  private: btDefaultCollisionConfiguration *collisionConfig;
121  private: btCollisionDispatcher *dispatcher;
122  private: btSequentialImpulseConstraintSolver *solver;
123  private: btDiscreteDynamicsWorld *dynamicsWorld;
124 
125  private: common::Time lastUpdateTime;
126 
127  private: double stepTimeDouble;
128  };
129 
131  }
132 }
133 #endif