All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PhysicsEngine.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 base class for all physics engines
18  * Author: Nate Koenig
19  */
20 
21 #ifndef _PHYSICSENGINE_HH_
22 #define _PHYSICSENGINE_HH_
23 
24 #include <boost/thread/recursive_mutex.hpp>
25 #include <string>
26 
28 #include "physics/PhysicsTypes.hh"
29 
30 namespace gazebo
31 {
32  namespace physics
33  {
36 
40  {
43  public: explicit PhysicsEngine(WorldPtr _world);
44 
46  public: virtual ~PhysicsEngine();
47 
50  public: virtual void Load(sdf::ElementPtr _sdf);
51 
53  public: virtual void Init() = 0;
54 
56  public: virtual void Fini();
57 
59  public: virtual void Reset() {}
60 
62  public: virtual void InitForThread() = 0;
63 
65  public: virtual void UpdateCollision() = 0;
66 
69  public: void SetUpdateRate(double _value);
70 
73  public: double GetUpdateRate();
74 
77  public: double GetUpdatePeriod();
78 
81  public: virtual void SetStepTime(double _value) = 0;
82 
85  public: virtual double GetStepTime() = 0;
86 
88  public: virtual void UpdatePhysics() {}
89 
92  public: virtual LinkPtr CreateLink(ModelPtr _parent) = 0;
93 
97  public: virtual CollisionPtr CreateCollision(
98  const std::string &_shapeType, LinkPtr _link) = 0;
99 
103  public: CollisionPtr CreateCollision(const std::string &_shapeType,
104  const std::string &_linkName);
105 
109  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
110  CollisionPtr _collision) = 0;
111 
115  public: virtual JointPtr CreateJoint(const std::string &_type,
116  ModelPtr _parent) = 0;
117 
120  public: math::Vector3 GetGravity() const;
121 
124  public: virtual void SetGravity(
125  const gazebo::math::Vector3 &_gravity) = 0;
126 
131  public: virtual void SetWorldCFM(double _cfm);
132 
137  public: virtual void SetWorldERP(double _erp);
138 
143  public: virtual void SetAutoDisableFlag(bool _autoDisable);
144 
149  public: virtual void SetSORPGSPreconIters(unsigned int _iters);
150 
155  public: virtual void SetSORPGSIters(unsigned int _iters);
156 
161  public: virtual void SetSORPGSW(double _w);
162 
167  public: virtual void SetContactMaxCorrectingVel(double _vel);
168 
173  public: virtual void SetContactSurfaceLayer(double _layerDepth);
174 
179  public: virtual void SetMaxContacts(double _maxContacts);
180 
185  public: virtual double GetWorldCFM() {return 0;}
186 
191  public: virtual double GetWorldERP() {return 0;}
192 
197  public: virtual bool GetAutoDisableFlag() {return 0;}
198 
203  public: virtual int GetSORPGSPreconIters() {return 0;}
204 
209  public: virtual int GetSORPGSIters() {return 0;}
210 
215  public: virtual double GetSORPGSW() {return 0;}
216 
221  public: virtual double GetContactMaxCorrectingVel() {return 0;}
222 
227  public: virtual double GetContactSurfaceLayer() {return 0;}
228 
233  public: virtual int GetMaxContacts() {return 0;}
234 
236  public: virtual void DebugPrint() const = 0;
237 
240  public: boost::recursive_mutex *GetPhysicsUpdateMutex() const
241  {return this->physicsUpdateMutex;}
242 
245  protected: virtual void OnRequest(ConstRequestPtr &_msg);
246 
249  protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
250 
252  protected: WorldPtr world;
253 
255  protected: sdf::ElementPtr sdf;
256 
259 
262 
265 
268 
271 
273  protected: boost::recursive_mutex *physicsUpdateMutex;
274 
277  private: double updateRateDouble;
278  };
280  }
281 }
282 #endif