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 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 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: virtual void SetSeed(uint32_t _seed);
73 
76  public: void SetUpdateRate(double _value);
77 
80  public: double GetUpdateRate();
81 
84  public: double GetUpdatePeriod();
85 
88  public: virtual void SetStepTime(double _value) = 0;
89 
92  public: virtual double GetStepTime() = 0;
93 
95  public: virtual void UpdatePhysics() {}
96 
99  public: virtual LinkPtr CreateLink(ModelPtr _parent) = 0;
100 
104  public: virtual CollisionPtr CreateCollision(
105  const std::string &_shapeType, LinkPtr _link) = 0;
106 
110  public: CollisionPtr CreateCollision(const std::string &_shapeType,
111  const std::string &_linkName);
112 
116  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
117  CollisionPtr _collision) = 0;
118 
122  public: virtual JointPtr CreateJoint(const std::string &_type,
123  ModelPtr _parent) = 0;
124 
127  public: virtual math::Vector3 GetGravity() const;
128 
131  public: virtual void SetGravity(
132  const gazebo::math::Vector3 &_gravity) = 0;
133 
138  public: virtual void SetWorldCFM(double _cfm);
139 
144  public: virtual void SetWorldERP(double _erp);
145 
150  public: virtual void SetAutoDisableFlag(bool _autoDisable);
151 
156  public: virtual void SetSORPGSPreconIters(unsigned int _iters);
157 
162  public: virtual void SetSORPGSIters(unsigned int _iters);
163 
168  public: virtual void SetSORPGSW(double _w);
169 
174  public: virtual void SetContactMaxCorrectingVel(double _vel);
175 
180  public: virtual void SetContactSurfaceLayer(double _layerDepth);
181 
186  public: virtual void SetMaxContacts(double _maxContacts);
187 
192  public: virtual double GetWorldCFM() {return 0;}
193 
198  public: virtual double GetWorldERP() {return 0;}
199 
204  public: virtual bool GetAutoDisableFlag() {return 0;}
205 
210  public: virtual int GetSORPGSPreconIters() {return 0;}
211 
216  public: virtual int GetSORPGSIters() {return 0;}
217 
222  public: virtual double GetSORPGSW() {return 0;}
223 
228  public: virtual double GetContactMaxCorrectingVel() {return 0;}
229 
234  public: virtual double GetContactSurfaceLayer() {return 0;}
235 
240  public: virtual int GetMaxContacts() {return 0;}
241 
243  public: virtual void DebugPrint() const = 0;
244 
247  public: ContactManager *GetContactManager() const;
248 
251  public: boost::recursive_mutex *GetPhysicsUpdateMutex() const
252  {return this->physicsUpdateMutex;}
253 
256  protected: virtual void OnRequest(ConstRequestPtr &_msg);
257 
260  protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
261 
263  protected: WorldPtr world;
264 
266  protected: sdf::ElementPtr sdf;
267 
270 
273 
276 
279 
281  protected: boost::recursive_mutex *physicsUpdateMutex;
282 
286 
289  private: double updateRateDouble;
290  };
292  }
293 }
294 #endif