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 #include "gazebo/msgs/msgs.hh"
29 
31 
32 namespace gazebo
33 {
34  namespace physics
35  {
36  class ContactManager;
37 
40 
44  {
47  public: explicit PhysicsEngine(WorldPtr _world);
48 
50  public: virtual ~PhysicsEngine();
51 
54  public: virtual void Load(sdf::ElementPtr _sdf);
55 
57  public: virtual void Init() = 0;
58 
60  public: virtual void Fini();
61 
63  public: virtual void Reset() {}
64 
66  public: virtual void InitForThread() = 0;
67 
69  public: virtual void UpdateCollision() = 0;
70 
73  public: virtual std::string GetType() const = 0;
74 
77  public: virtual void SetSeed(uint32_t _seed) = 0;
78 
81  public: void SetUpdateRate(double _value);
82 
85  public: double GetUpdateRate();
86 
89  public: double GetUpdatePeriod();
90 
93  public: virtual void SetStepTime(double _value) = 0;
94 
97  public: virtual double GetStepTime() = 0;
98 
100  public: virtual void UpdatePhysics() {}
101 
104  public: virtual LinkPtr CreateLink(ModelPtr _parent) = 0;
105 
109  public: virtual CollisionPtr CreateCollision(
110  const std::string &_shapeType, LinkPtr _link) = 0;
111 
115  public: CollisionPtr CreateCollision(const std::string &_shapeType,
116  const std::string &_linkName);
117 
121  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
122  CollisionPtr _collision) = 0;
123 
127  public: virtual JointPtr CreateJoint(const std::string &_type,
128  ModelPtr _parent) = 0;
129 
132  public: virtual math::Vector3 GetGravity() const;
133 
136  public: virtual void SetGravity(
137  const gazebo::math::Vector3 &_gravity) = 0;
138 
143  public: virtual void SetWorldCFM(double _cfm);
144 
149  public: virtual void SetWorldERP(double _erp);
150 
155  public: virtual void SetAutoDisableFlag(bool _autoDisable);
156 
161  public: virtual void SetSORPGSPreconIters(unsigned int _iters);
162 
167  public: virtual void SetSORPGSIters(unsigned int _iters);
168 
173  public: virtual void SetSORPGSW(double _w);
174 
179  public: virtual void SetContactMaxCorrectingVel(double _vel);
180 
185  public: virtual void SetContactSurfaceLayer(double _layerDepth);
186 
191  public: virtual void SetMaxContacts(double _maxContacts);
192 
197  public: virtual double GetWorldCFM() {return 0;}
198 
203  public: virtual double GetWorldERP() {return 0;}
204 
209  public: virtual bool GetAutoDisableFlag() {return 0;}
210 
215  public: virtual int GetSORPGSPreconIters() {return 0;}
216 
221  public: virtual int GetSORPGSIters() {return 0;}
222 
227  public: virtual double GetSORPGSW() {return 0;}
228 
233  public: virtual double GetContactMaxCorrectingVel() {return 0;}
234 
239  public: virtual double GetContactSurfaceLayer() {return 0;}
240 
245  public: virtual int GetMaxContacts() {return 0;}
246 
248  public: virtual void DebugPrint() const = 0;
249 
252  public: ContactManager *GetContactManager() const;
253 
256  public: boost::recursive_mutex *GetPhysicsUpdateMutex() const
257  {return this->physicsUpdateMutex;}
258 
261  protected: virtual void OnRequest(ConstRequestPtr &_msg);
262 
265  protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
266 
268  protected: WorldPtr world;
269 
271  protected: sdf::ElementPtr sdf;
272 
275 
278 
281 
284 
286  protected: boost::recursive_mutex *physicsUpdateMutex;
287 
291 
294  private: double updateRateDouble;
295  };
297  }
298 }
299 #endif