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 2012 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 
30 
31 namespace gazebo
32 {
33  namespace physics
34  {
35  class ContactManager;
36 
39 
43  {
46  public: explicit PhysicsEngine(WorldPtr _world);
47 
49  public: virtual ~PhysicsEngine();
50 
53  public: virtual void Load(sdf::ElementPtr _sdf);
54 
56  public: virtual void Init() = 0;
57 
59  public: virtual void Fini();
60 
62  public: virtual void Reset() {}
63 
65  public: virtual void InitForThread() = 0;
66 
68  public: virtual void UpdateCollision() = 0;
69 
72  public: void SetUpdateRate(double _value);
73 
76  public: double GetUpdateRate();
77 
80  public: double GetUpdatePeriod();
81 
84  public: virtual void SetStepTime(double _value) = 0;
85 
88  public: virtual double GetStepTime() = 0;
89 
91  public: virtual void UpdatePhysics() {}
92 
95  public: virtual LinkPtr CreateLink(ModelPtr _parent) = 0;
96 
100  public: virtual CollisionPtr CreateCollision(
101  const std::string &_shapeType, LinkPtr _link) = 0;
102 
106  public: CollisionPtr CreateCollision(const std::string &_shapeType,
107  const std::string &_linkName);
108 
112  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
113  CollisionPtr _collision) = 0;
114 
118  public: virtual JointPtr CreateJoint(const std::string &_type,
119  ModelPtr _parent) = 0;
120 
123  public: virtual math::Vector3 GetGravity() const;
124 
127  public: virtual void SetGravity(
128  const gazebo::math::Vector3 &_gravity) = 0;
129 
134  public: virtual void SetWorldCFM(double _cfm);
135 
140  public: virtual void SetWorldERP(double _erp);
141 
146  public: virtual void SetAutoDisableFlag(bool _autoDisable);
147 
152  public: virtual void SetSORPGSPreconIters(unsigned int _iters);
153 
158  public: virtual void SetSORPGSIters(unsigned int _iters);
159 
164  public: virtual void SetSORPGSW(double _w);
165 
170  public: virtual void SetContactMaxCorrectingVel(double _vel);
171 
176  public: virtual void SetContactSurfaceLayer(double _layerDepth);
177 
182  public: virtual void SetMaxContacts(double _maxContacts);
183 
188  public: virtual double GetWorldCFM() {return 0;}
189 
194  public: virtual double GetWorldERP() {return 0;}
195 
200  public: virtual bool GetAutoDisableFlag() {return 0;}
201 
206  public: virtual int GetSORPGSPreconIters() {return 0;}
207 
212  public: virtual int GetSORPGSIters() {return 0;}
213 
218  public: virtual double GetSORPGSW() {return 0;}
219 
224  public: virtual double GetContactMaxCorrectingVel() {return 0;}
225 
230  public: virtual double GetContactSurfaceLayer() {return 0;}
231 
236  public: virtual int GetMaxContacts() {return 0;}
237 
239  public: virtual void DebugPrint() const = 0;
240 
243  public: ContactManager *GetContactManager() const;
244 
247  public: boost::recursive_mutex *GetPhysicsUpdateMutex() const
248  {return this->physicsUpdateMutex;}
249 
252  protected: virtual void OnRequest(ConstRequestPtr &_msg);
253 
256  protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
257 
259  protected: WorldPtr world;
260 
262  protected: sdf::ElementPtr sdf;
263 
266 
269 
272 
275 
277  protected: boost::recursive_mutex *physicsUpdateMutex;
278 
282 
285  private: double updateRateDouble;
286  };
288  }
289 }
290 #endif