DARTPhysics.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 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
18#ifndef _GAZEBO_DARTPHYSICS_HH_
19#define _GAZEBO_DARTPHYSICS_HH_
20
21#include <string>
22
23#include <boost/thread/thread.hpp>
24#include <boost/thread/mutex.hpp>
25
29
32#include "gazebo/util/system.hh"
33
34namespace gazebo
35{
36 namespace physics
37 {
39 class DARTPhysicsPrivate;
40
45
47 class GZ_PHYSICS_VISIBLE DARTPhysics : public PhysicsEngine
48 {
51 public: enum DARTParam
52 {
53 // /// \brief Solve type
54 // SOLVER_TYPE,
55
56 // /// \brief Constraint force mixing
57 // GLOBAL_CFM,
58
59 // /// \brief Error reduction parameter
60 // GLOBAL_ERP,
61
62 // /// \brief Number of iterations
63 // PGS_ITERS,
64
65 // /// \brief SOR over-relaxation parameter
66 // SOR,
67
68 // /// \brief Surface layer depth
69 // CONTACT_SURFACE_LAYER,
70
73
75 MIN_STEP_SIZE
76 };
77
79 public: explicit DARTPhysics(WorldPtr _world);
80
82 public: virtual ~DARTPhysics();
83
84 // Documentation inherited
85 public: virtual void Load(sdf::ElementPtr _sdf);
86
87 // Documentation inherited
88 public: virtual void Init();
89
90 // Documentation inherited
91 public: virtual void Fini();
92
93 // Documentation inherited
94 public: virtual void Reset();
95
96 // Documentation inherited
97 public: virtual void InitForThread();
98
99 // Documentation inherited
100 public: virtual void UpdateCollision();
101
102 // Documentation inherited
103 public: virtual void UpdatePhysics();
104
105 // Documentation inherited
106 public: virtual std::string GetType() const;
107
108 // Documentation inherited
109 public: virtual void SetSeed(uint32_t _seed);
110
111 // Documentation inherited
112 public: virtual ModelPtr CreateModel(BasePtr _parent);
113
114 // Documentation inherited
115 public: virtual LinkPtr CreateLink(ModelPtr _parent);
116
117 // Documentation inherited
118 public: virtual CollisionPtr CreateCollision(const std::string &_type,
119 LinkPtr _body);
120
121 // Documentation inherited
122 public: virtual JointPtr CreateJoint(const std::string &_type,
123 ModelPtr _parent);
124
125 // Documentation inherited
126 public: virtual ShapePtr CreateShape(const std::string &_shapeType,
127 CollisionPtr _collision);
130 public: std::string GetSolverType() const;
131
134 public: void SetSolverType(const std::string &_type);
135
136 // Documentation inherited
137 public: virtual void SetGravity(const ignition::math::Vector3d &_gravity);
138
139 // Documentation inherited
140 public: virtual void DebugPrint() const;
141
142 // Documentation inherited
143 public: virtual boost::any GetParam(const std::string &_key) const;
144
145 // Documentation inherited
146 public: virtual bool GetParam(const std::string &_key,
147 boost::any &_value) const;
148
149 // Documentation inherited
150 public: virtual bool SetParam(const std::string &_key,
151 const boost::any &_value);
152
155 public: dart::simulation::WorldPtr DARTWorld() const;
156
160 public: std::string CollisionDetectorInUse() const;
161
162 // Documentation inherited
163 protected: virtual void OnRequest(ConstRequestPtr &_msg);
164
165 // Documentation inherited
166 protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
167
171 private: DARTLinkPtr FindDARTLink(
172 const dart::dynamics::BodyNode *_dtBodyNode);
173
176 private: DARTPhysicsPrivate *dataPtr = nullptr;
177 };
178
180 }
181}
182#endif
DART wrapper forward declarations and typedefs.
DART physics engine.
Definition DARTPhysics.hh:48
virtual bool GetParam(const std::string &_key, boost::any &_value) const
Get a parameter from the physics engine with a boolean to indicate success or failure.
virtual LinkPtr CreateLink(ModelPtr _parent)
Create a new body.
std::string GetSolverType() const
Get the constraint LCP solver type.
std::string CollisionDetectorInUse() const
Returns a string with the name of the used collision detector.
virtual void Fini()
Finilize the physics engine.
virtual ~DARTPhysics()
Destructor.
virtual void Init()
Initialize the physics engine.
DARTParam
DART physics parameter types.
Definition DARTPhysics.hh:52
@ MIN_STEP_SIZE
Minimum step size.
Definition DARTPhysics.hh:75
@ MAX_CONTACTS
Maximum number of contacts.
Definition DARTPhysics.hh:72
virtual void Reset()
Rest the physics engine.
virtual void UpdateCollision()
Update the physics engine collision.
virtual void UpdatePhysics()
Update the physics engine.
virtual void OnRequest(ConstRequestPtr &_msg)
virtual callback for gztopic "~/request".
virtual ShapePtr CreateShape(const std::string &_shapeType, CollisionPtr _collision)
Create a physics::Shape object.
virtual void InitForThread()
Init the engine for threads.
dart::simulation::WorldPtr DARTWorld() const
Get pointer to DART World associated with this DART Physics.
DARTPhysics(WorldPtr _world)
Constructor.
virtual std::string GetType() const
Return the physics engine type (ode|bullet|dart|simbody).
virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg)
virtual callback for gztopic "~/physics".
virtual boost::any GetParam(const std::string &_key) const
Get an parameter of the physics engine.
virtual void SetGravity(const ignition::math::Vector3d &_gravity)
Set the gravity vector.
virtual CollisionPtr CreateCollision(const std::string &_type, LinkPtr _body)
Create a collision.
void SetSolverType(const std::string &_type)
Set the constraint LCP solver type.
virtual void DebugPrint() const
Debug print out of the physic engine state.
virtual void Load(sdf::ElementPtr _sdf)
Load the physics engine.
virtual bool SetParam(const std::string &_key, const boost::any &_value)
Set a parameter of the physics engine.
virtual void SetSeed(uint32_t _seed)
Set the random number seed for the physics engine.
virtual JointPtr CreateJoint(const std::string &_type, ModelPtr _parent)
Create a new joint.
virtual ModelPtr CreateModel(BasePtr _parent)
Create a new model.
Base class for a physics engine.
Definition PhysicsEngine.hh:42
boost::shared_ptr< Link > LinkPtr
Definition PhysicsTypes.hh:109
boost::shared_ptr< DARTLink > DARTLinkPtr
Definition DARTTypes.hh:47
boost::shared_ptr< Collision > CollisionPtr
Definition PhysicsTypes.hh:113
boost::shared_ptr< Base > BasePtr
Definition PhysicsTypes.hh:77
boost::shared_ptr< Shape > ShapePtr
Definition PhysicsTypes.hh:141
boost::shared_ptr< World > WorldPtr
Definition PhysicsTypes.hh:89
boost::shared_ptr< Model > ModelPtr
Definition PhysicsTypes.hh:93
boost::shared_ptr< Joint > JointPtr
Definition PhysicsTypes.hh:117
Forward declarations for the common classes.
Definition Animation.hh:27