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: double GetUpdatePeriod();
82 
85  public: double GetTargetRealTimeFactor() const;
86 
89  public: double GetRealTimeUpdateRate() const;
90 
93  public: double GetMaxStepSize() const;
94 
97  public: void SetTargetRealTimeFactor(double _factor);
98 
101  public: void SetRealTimeUpdateRate(double _rate);
102 
105  public: void SetMaxStepSize(double _stepSize);
106 
108  public: virtual void UpdatePhysics() {}
109 
112  public: virtual ModelPtr CreateModel(BasePtr _base);
113 
116  public: virtual LinkPtr CreateLink(ModelPtr _parent) = 0;
117 
121  public: virtual CollisionPtr CreateCollision(
122  const std::string &_shapeType, LinkPtr _link) = 0;
123 
127  public: CollisionPtr CreateCollision(const std::string &_shapeType,
128  const std::string &_linkName);
129 
133  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
134  CollisionPtr _collision) = 0;
135 
139  public: virtual JointPtr CreateJoint(const std::string &_type,
140  ModelPtr _parent = ModelPtr()) = 0;
141 
144  public: virtual math::Vector3 GetGravity() const;
145 
148  public: virtual void SetGravity(
149  const gazebo::math::Vector3 &_gravity) = 0;
150 
155  public: virtual void SetWorldCFM(double _cfm);
156 
161  public: virtual void SetWorldERP(double _erp);
162 
167  public: virtual void SetAutoDisableFlag(bool _autoDisable);
168 
173  public: virtual void SetSORPGSPreconIters(unsigned int _iters);
174 
179  public: virtual void SetSORPGSIters(unsigned int _iters);
180 
185  public: virtual void SetSORPGSW(double _w);
186 
191  public: virtual void SetContactMaxCorrectingVel(double _vel);
192 
197  public: virtual void SetContactSurfaceLayer(double _layerDepth);
198 
203  public: virtual void SetMaxContacts(double _maxContacts);
204 
209  public: virtual double GetWorldCFM() {return 0;}
210 
215  public: virtual double GetWorldERP() {return 0;}
216 
221  public: virtual bool GetAutoDisableFlag() {return 0;}
222 
227  public: virtual int GetSORPGSPreconIters() {return 0;}
228 
233  public: virtual int GetSORPGSIters() {return 0;}
234 
239  public: virtual double GetSORPGSW() {return 0;}
240 
245  public: virtual double GetContactMaxCorrectingVel() {return 0;}
246 
251  public: virtual double GetContactSurfaceLayer() {return 0;}
252 
257  public: virtual int GetMaxContacts() {return 0;}
258 
262  public: virtual void SetParam(std::string _key,
263  const boost::any &_value);
264 
268  public: virtual boost::any GetParam(std::string _key) const;
269 
271  public: virtual void DebugPrint() const = 0;
272 
275  public: ContactManager *GetContactManager() const;
276 
279  public: boost::recursive_mutex *GetPhysicsUpdateMutex() const
280  {return this->physicsUpdateMutex;}
281 
284  protected: virtual void OnRequest(ConstRequestPtr &_msg);
285 
288  protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
289 
291  protected: WorldPtr world;
292 
294  protected: sdf::ElementPtr sdf;
295 
298 
301 
304 
307 
309  protected: boost::recursive_mutex *physicsUpdateMutex;
310 
314 
316  protected: double realTimeUpdateRate;
317 
319  protected: double targetRealTimeFactor;
320 
322  protected: double maxStepSize;
323  };
325  }
326 }
327 #endif