All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BulletPhysics.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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: 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 
32 #include "gazebo/physics/Shape.hh"
33 #include "gazebo/util/system.hh"
34 
35 namespace gazebo
36 {
37  namespace physics
38  {
39  class Entity;
40  class XMLConfigNode;
41  class Mass;
42 
46 
49  {
52  public: enum BulletParam
53  {
56 
59 
62 
65 
67  SOR,
68 
71 
74 
76  MIN_STEP_SIZE
77  };
78 
80  public: BulletPhysics(WorldPtr _world);
81 
83  public: virtual ~BulletPhysics();
84 
85  // Documentation inherited
86  public: virtual void Load(sdf::ElementPtr _sdf);
87 
88  // Documentation inherited
89  public: virtual void Init();
90 
91  // Documentation inherited
92  public: virtual void Reset();
93 
94  // Documentation inherited
95  public: virtual void InitForThread();
96 
97  // Documentation inherited
98  public: virtual void UpdateCollision();
99 
100  // Documentation inherited
101  public: virtual void UpdatePhysics();
102 
103  // Documentation inherited
104  public: virtual void Fini();
105 
106  // Documentation inherited
107  public: virtual std::string GetType() const
108  { return "bullet"; }
109 
110  // Documentation inherited
111  public: virtual LinkPtr CreateLink(ModelPtr _parent);
112 
113  // Documentation inherited
114  public: virtual CollisionPtr CreateCollision(const std::string &_type,
115  LinkPtr _body);
116 
117  // Documentation inherited
118  public: virtual JointPtr CreateJoint(const std::string &_type,
119  ModelPtr _parent);
120 
121  // Documentation inherited
122  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
123  CollisionPtr _collision);
124 
126  // public: virtual PhysicsRaySensor *CreateRaySensor(Link *body);
127 
128  // Documentation inherited
129  protected: virtual void OnRequest(ConstRequestPtr &_msg);
130 
131  // Documentation inherited
132  protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
133 
135  public: virtual void ConvertMass(InertialPtr _inertial,
136  void *_engineMass);
137 
139  public: virtual void ConvertMass(void *_engineMass,
140  InertialPtr _inertial);
141 
142  // Documentation inherited
143  public: virtual void SetGravity(const gazebo::math::Vector3 &_gravity);
144 
145  // Documentation inherited
146  public: virtual void SetWorldCFM(double _cfm);
147 
148  // Documentation inherited
149  public: virtual double GetWorldCFM();
150 
151  // Documentation inherited
152  public: virtual void SetSeed(uint32_t _seed);
153 
155  public: btDynamicsWorld *GetDynamicsWorld() const
156  {return this->dynamicsWorld;}
157 
158  public: virtual void DebugPrint() const;
159 
161  public: virtual bool SetParam(const std::string &_key,
162  const boost::any &_value);
163 
165  public: virtual boost::any GetParam(const std::string &_key) const;
166 
167  // Documentation inherited
168  public: virtual void SetSORPGSIters(unsigned int iters);
169 
170  private: btBroadphaseInterface *broadPhase;
171  private: btDefaultCollisionConfiguration *collisionConfig;
172  private: btCollisionDispatcher *dispatcher;
173  private: btSequentialImpulseConstraintSolver *solver;
174  private: btDiscreteDynamicsWorld *dynamicsWorld;
175 
176  private: common::Time lastUpdateTime;
177 
179  private: std::string solverType;
180  };
181 
183  }
184 }
185 #endif
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:82
Surface layer depth.
Definition: BulletPhysics.hh:70
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
boost::shared_ptr< Shape > ShapePtr
Definition: PhysicsTypes.hh:110
boost::shared_ptr< Inertial > InertialPtr
Definition: PhysicsTypes.hh:126
Base class for a physics engine.
Definition: PhysicsEngine.hh:40
virtual std::string GetType() const
Return the physics engine type (ode|bullet|dart|simbody).
Definition: BulletPhysics.hh:107
Bullet physics engine.
Definition: BulletPhysics.hh:48
Solve type.
Definition: BulletPhysics.hh:55
Maximum number of contacts.
Definition: BulletPhysics.hh:73
btDynamicsWorld * GetDynamicsWorld() const
Register a joint with the dynamics world.
Definition: BulletPhysics.hh:155
BulletParam
Bullet physics parameter types.
Definition: BulletPhysics.hh:52
Error reduction parameter.
Definition: BulletPhysics.hh:61
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:94
Number of iterations.
Definition: BulletPhysics.hh:64
Constraint force mixing.
Definition: BulletPhysics.hh:58
SOR over-relaxation parameter.
Definition: BulletPhysics.hh:67
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:78
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:98
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:90
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:43