All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PhysicsEngine.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 #include "gazebo/util/system.hh"
32 
33 namespace gazebo
34 {
35  namespace physics
36  {
37  class ContactManager;
38 
41 
45  {
48  public: explicit PhysicsEngine(WorldPtr _world);
49 
51  public: virtual ~PhysicsEngine();
52 
55  public: virtual void Load(sdf::ElementPtr _sdf);
56 
58  public: virtual void Init() = 0;
59 
61  public: virtual void Fini();
62 
64  public: virtual void Reset() {}
65 
67  public: virtual void InitForThread() = 0;
68 
70  public: virtual void UpdateCollision() = 0;
71 
74  public: virtual std::string GetType() const = 0;
75 
78  public: virtual void SetSeed(uint32_t _seed) = 0;
79 
82  public: double GetUpdatePeriod();
83 
86  public: double GetTargetRealTimeFactor() const;
87 
90  public: double GetRealTimeUpdateRate() const;
91 
94  public: double GetMaxStepSize() const;
95 
98  public: void SetTargetRealTimeFactor(double _factor);
99 
102  public: void SetRealTimeUpdateRate(double _rate);
103 
106  public: void SetMaxStepSize(double _stepSize);
107 
109  public: virtual void UpdatePhysics() {}
110 
113  public: virtual ModelPtr CreateModel(BasePtr _base);
114 
117  public: virtual LinkPtr CreateLink(ModelPtr _parent) = 0;
118 
122  public: virtual CollisionPtr CreateCollision(
123  const std::string &_shapeType, LinkPtr _link) = 0;
124 
128  public: CollisionPtr CreateCollision(const std::string &_shapeType,
129  const std::string &_linkName);
130 
134  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
135  CollisionPtr _collision) = 0;
136 
140  public: virtual JointPtr CreateJoint(const std::string &_type,
141  ModelPtr _parent = ModelPtr()) = 0;
142 
145  public: virtual math::Vector3 GetGravity() const;
146 
149  public: virtual void SetGravity(
150  const gazebo::math::Vector3 &_gravity) = 0;
151 
156  public: virtual void SetWorldCFM(double _cfm);
157 
162  public: virtual void SetWorldERP(double _erp);
163 
168  public: virtual void SetAutoDisableFlag(bool _autoDisable);
169 
174  public: virtual void SetSORPGSPreconIters(unsigned int _iters)
175  GAZEBO_DEPRECATED(3.0);
176 
181  public: virtual void SetSORPGSIters(unsigned int _iters)
182  GAZEBO_DEPRECATED(3.0);
183 
188  public: virtual void SetSORPGSW(double _w) GAZEBO_DEPRECATED(3.0);
189 
194  public: virtual void SetContactMaxCorrectingVel(double _vel);
195 
200  public: virtual void SetContactSurfaceLayer(double _layerDepth);
201 
206  public: virtual void SetMaxContacts(unsigned int _maxContacts);
207 
212  public: virtual double GetWorldCFM() {return 0;}
213 
218  public: virtual double GetWorldERP() {return 0;}
219 
224  public: virtual bool GetAutoDisableFlag() {return 0;}
225 
230  public: virtual int GetSORPGSPreconIters() GAZEBO_DEPRECATED(3.0)
231  {return 0;}
232 
237  public: virtual int GetSORPGSIters() GAZEBO_DEPRECATED(3.0)
238  {return 0;}
239 
244  public: virtual double GetSORPGSW() GAZEBO_DEPRECATED(3.0)
245  {return 0;}
246 
251  public: virtual double GetContactMaxCorrectingVel() {return 0;}
252 
257  public: virtual double GetContactSurfaceLayer() {return 0;}
258 
263  public: virtual unsigned int GetMaxContacts() {return 0;}
264 
297  public: virtual bool SetParam(const std::string &_key,
298  const boost::any &_value);
299 
304  public: virtual boost::any GetParam(const std::string &_key) const;
305 
307  public: virtual void DebugPrint() const = 0;
308 
311  public: ContactManager *GetContactManager() const;
312 
315  public: boost::recursive_mutex *GetPhysicsUpdateMutex() const
316  {return this->physicsUpdateMutex;}
317 
320  protected: virtual void OnRequest(ConstRequestPtr &_msg);
321 
324  protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
325 
327  protected: WorldPtr world;
328 
330  protected: sdf::ElementPtr sdf;
331 
334 
337 
340 
343 
345  protected: boost::recursive_mutex *physicsUpdateMutex;
346 
350 
352  protected: double realTimeUpdateRate;
353 
355  protected: double targetRealTimeFactor;
356 
358  protected: double maxStepSize;
359  };
361  }
362 }
363 #endif
virtual double GetWorldERP()
: Remove this function, and replace it with a more generic property map
Definition: PhysicsEngine.hh:218
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:65
double realTimeUpdateRate
Real time update rate.
Definition: PhysicsEngine.hh:352
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:81
virtual double GetWorldCFM()
: Remove this function, and replace it with a more generic property map
Definition: PhysicsEngine.hh:212
Forward declarations for the common classes.
Definition: Animation.hh:24
virtual double GetSORPGSW() GAZEBO_DEPRECATED(3.0)
: Remove this function, and replace it with a more generic property map.
Definition: PhysicsEngine.hh:244
double targetRealTimeFactor
Target real time factor.
Definition: PhysicsEngine.hh:355
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
virtual void UpdatePhysics()
Update the physics engine.
Definition: PhysicsEngine.hh:109
boost::shared_ptr< Shape > ShapePtr
Definition: PhysicsTypes.hh:109
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:48
Base class for a physics engine.
Definition: PhysicsEngine.hh:44
virtual bool GetAutoDisableFlag()
: Remove this function, and replace it with a more generic property map
Definition: PhysicsEngine.hh:224
Forward declarations for transport.
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:44
WorldPtr world
Pointer to the world.
Definition: PhysicsEngine.hh:327
sdf::ElementPtr sdf
Our SDF values.
Definition: PhysicsEngine.hh:330
boost::recursive_mutex * physicsUpdateMutex
Mutex to protect the update cycle.
Definition: PhysicsEngine.hh:345
default namespace for gazebo
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:93
transport::SubscriberPtr physicsSub
Subscribe to the physics topic.
Definition: PhysicsEngine.hh:339
virtual int GetSORPGSPreconIters() GAZEBO_DEPRECATED(3.0)
: Remove this function, and replace it with a more generic property map
Definition: PhysicsEngine.hh:230
virtual void Reset()
Rest the physics engine.
Definition: PhysicsEngine.hh:64
transport::SubscriberPtr requestSub
Subscribe to the request topic.
Definition: PhysicsEngine.hh:342
virtual double GetContactMaxCorrectingVel()
: Remove this function, and replace it with a more generic property map.
Definition: PhysicsEngine.hh:251
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:77
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:97
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:52
boost::recursive_mutex * GetPhysicsUpdateMutex() const
returns a pointer to the PhysicsEngine::physicsUpdateMutex.
Definition: PhysicsEngine.hh:315
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
virtual unsigned int GetMaxContacts()
: Remove this function, and replace it with a more generic property map.
Definition: PhysicsEngine.hh:263
virtual int GetSORPGSIters() GAZEBO_DEPRECATED(3.0)
: Remove this function, and replace it with a more generic property map
Definition: PhysicsEngine.hh:237
virtual double GetContactSurfaceLayer()
: Remove this function, and replace it with a more generic property map.
Definition: PhysicsEngine.hh:257
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:44
transport::PublisherPtr responsePub
Response publisher.
Definition: PhysicsEngine.hh:336
Aggregates all the contact information generated by the collision detection engine.
Definition: ContactManager.hh:65
double maxStepSize
Real time update rate.
Definition: PhysicsEngine.hh:358
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
transport::NodePtr node
Node for communication.
Definition: PhysicsEngine.hh:333
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:89
ContactManager * contactManager
Class that handles all contacts generated by the physics engine.
Definition: PhysicsEngine.hh:349