SimbodyPhysics.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 
18 #ifndef GAZEBO_PHYSICS_SIMBODY_SIMBODYPHYSICS_HH
19 #define GAZEBO_PHYSICS_SIMBODY_SIMBODYPHYSICS_HH
20 #include <string>
21 
22 #include <boost/thread/thread.hpp>
23 #include <boost/thread/mutex.hpp>
24 
27 #include "gazebo/physics/Shape.hh"
29 
31 #include "gazebo/util/system.hh"
32 
33 namespace gazebo
34 {
35  namespace physics
36  {
40 
42  class GZ_PHYSICS_VISIBLE SimbodyPhysics : public PhysicsEngine
43  {
45  public: SimbodyPhysics(WorldPtr _world);
46 
48  public: virtual ~SimbodyPhysics();
49 
50  // Documentation inherited
51  public: virtual void Load(sdf::ElementPtr _sdf);
52 
53  // Documentation inherited
54  public: virtual void Init();
55 
56  // Documentation inherited
57  public: virtual void Reset();
58 
61  public: void InitModel(const physics::ModelPtr _model);
62 
63  // Documentation inherited
64  public: virtual void InitForThread();
65 
66  // Documentation inherited
67  public: virtual void UpdateCollision();
68 
69  // Documentation inherited
70  public: virtual void UpdatePhysics();
71 
72  // Documentation inherited
73  public: virtual void Fini();
74 
75  // Documentation inherited
76  public: virtual std::string GetType() const;
77 
78  // Documentation inherited
79  public: virtual LinkPtr CreateLink(ModelPtr _parent);
80 
81  // Documentation inherited
82  public: virtual CollisionPtr CreateCollision(const std::string &_type,
83  LinkPtr _body);
84 
85  // Documentation inherited
86  public: virtual JointPtr CreateJoint(const std::string &_type,
87  ModelPtr _parent);
88 
89  // Documentation inherited
90  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
91  CollisionPtr _collision);
92 
94  public: SimTK::MultibodySystem *GetDynamicsWorld() const;
95 
96  // Documentation inherited
97  public: virtual void SetGravity(const ignition::math::Vector3d &_gravity);
98 
99  // Documentation inherited
100  public: virtual void DebugPrint() const;
101 
102  // Documentation inherited
103  public: virtual void SetSeed(uint32_t _seed);
104 
105  // Documentation inherited
106  public: virtual ModelPtr CreateModel(BasePtr _parent);
107 
112  public: static SimTK::Quaternion QuadToQuad(const math::Quaternion &_q)
113  GAZEBO_DEPRECATED(8.0);
114 
118  public: static SimTK::Quaternion QuadToQuad(
119  const ignition::math::Quaterniond &_q);
120 
125  public: static math::Quaternion QuadToQuad(const SimTK::Quaternion &_q)
126  GAZEBO_DEPRECATED(8.0);
127 
131  public: static ignition::math::Quaterniond QuadToQuadIgn(
132  const SimTK::Quaternion &_q);
133 
138  public: static SimTK::Vec3 Vector3ToVec3(const math::Vector3 &_v)
139  GAZEBO_DEPRECATED(8.0);
140 
144  public: static SimTK::Vec3 Vector3ToVec3(
145  const ignition::math::Vector3d &_v);
146 
151  public: static math::Vector3 Vec3ToVector3(const SimTK::Vec3 &_v)
152  GAZEBO_DEPRECATED(8.0);
153 
157  public: static ignition::math::Vector3d Vec3ToVector3Ign(
158  const SimTK::Vec3 &_v);
159 
167  public: static SimTK::Transform Pose2Transform(const math::Pose &_pose)
168  GAZEBO_DEPRECATED(8.0);
169 
176  public: static SimTK::Transform Pose2Transform(
177  const ignition::math::Pose3d &_pose);
178 
184  public: static math::Pose Transform2Pose(const SimTK::Transform &_xAB)
185  GAZEBO_DEPRECATED(8.0);
186 
191  public: static ignition::math::Pose3d Transform2PoseIgn(
192  const SimTK::Transform &_xAB);
193 
197  public: static SimTK::Transform GetPose(sdf::ElementPtr _element);
198 
203  public: static std::string GetTypeString(unsigned int _type);
204 
209  public: static std::string GetTypeString(physics::Base::EntityType _type);
210 
211  // Documentation inherited
212  protected: virtual void OnRequest(ConstRequestPtr &_msg);
213 
214  // Documentation inherited
215  protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
216 
225  private: void CreateMultibodyGraph(
226  SimTK::MultibodyGraphMaker& _mbgraph, const physics::ModelPtr _model);
227 
238  private: void InitSimbodySystem();
239 
242  private: void AddStaticModelToSimbodySystem(
243  const physics::ModelPtr _model);
244 
248  private: void AddDynamicModelToSimbodySystem(
249  const SimTK::MultibodyGraphMaker &_mbgraph,
250  const physics::ModelPtr _model);
251 
253  private: void AddCollisionsToLink(const physics::SimbodyLink *_link,
254  SimTK::MobilizedBody &_mobod, SimTK::ContactCliqueId _modelClique);
255 
256  public: SimTK::MultibodySystem system;
257  public: SimTK::SimbodyMatterSubsystem matter;
258  public: SimTK::GeneralForceSubsystem forces;
259  public: SimTK::Force::Gravity gravity;
260  public: SimTK::Force::DiscreteForces discreteForces;
261  public: SimTK::ContactTrackerSubsystem tracker;
262  public: SimTK::CompliantContactSubsystem contact;
263  public: SimTK:: Integrator *integ;
264 
267 
268  public: bool simbodyPhysicsStepped;
269 
270  // Documentation inherited
271  public: virtual boost::any GetParam(const std::string &_key) const;
272 
273  // Documentation inherited
274  public: virtual bool GetParam(const std::string &_key,
275  boost::any &_value) const;
276 
277  // Documentation inherited
278  public: virtual bool SetParam(const std::string &_key,
279  const boost::any &_value);
280 
282  private: double contactMaterialStiffness;
283 
285  private: double contactMaterialDissipation;
286 
289  private: double contactMaterialPlasticCoefRestitution;
290 
293  private: double contactMaterialPlasticImpactVelocity;
294 
297  private: double contactMaterialStaticFriction;
298 
301  private: double contactMaterialDynamicFriction;
302 
305  private: double contactMaterialViscousFriction;
306 
309  private: double contactImpactCaptureVelocity;
310 
313  private: double contactStictionTransitionVelocity;
314 
315  private: SimTK::MultibodySystem *dynamicsWorld;
316 
317  private: common::Time lastUpdateTime;
318 
319  private: double stepTimeDouble;
320 
323  private: std::string solverType;
324 
330  private: std::string integratorType;
331  };
333  }
334 }
335 #endif
SimTK::Integrator * integ
Definition: SimbodyPhysics.hh:263
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
SimTK::Force::DiscreteForces discreteForces
Definition: SimbodyPhysics.hh:260
Encapsulates a position and rotation in three space.
Definition: Pose.hh:42
SimTK::SimbodyMatterSubsystem matter
Definition: SimbodyPhysics.hh:257
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:44
Base class for a physics engine.
Definition: PhysicsEngine.hh:41
bool simbodyPhysicsStepped
Definition: SimbodyPhysics.hh:268
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
Simbody physics engine.
Definition: SimbodyPhysics.hh:42
A quaternion class.
Definition: Quaternion.hh:48
SimTK::CompliantContactSubsystem contact
Definition: SimbodyPhysics.hh:262
SimTK::MultibodySystem system
Definition: SimbodyPhysics.hh:256
Simbody wrapper forward declarations and typedefs.
SimTK::Force::Gravity gravity
Definition: SimbodyPhysics.hh:259
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
boost::shared_ptr< Shape > ShapePtr
Definition: PhysicsTypes.hh:141
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
EntityType
Unique identifiers for all entity types.
Definition: Base.hh:81
SimTK::GeneralForceSubsystem forces
Definition: SimbodyPhysics.hh:258
bool simbodyPhysicsInitialized
true if initialized
Definition: SimbodyPhysics.hh:266
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
SimTK::ContactTrackerSubsystem tracker
Definition: SimbodyPhysics.hh:261
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44