All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimbodyPhysics.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2013 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 _SIMBODY_PHYSICS_HH
19 #define _SIMBODY_PHYSICS_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 
32 namespace gazebo
33 {
34  namespace physics
35  {
39 
42  {
44  public: SimbodyPhysics(WorldPtr _world);
45 
47  public: virtual ~SimbodyPhysics();
48 
49  // Documentation inherited
50  public: virtual void Load(sdf::ElementPtr _sdf);
51 
52  // Documentation inherited
53  public: virtual void Init();
54 
55  // Documentation inherited
56  public: virtual void Reset();
57 
60  public: void InitModel(const physics::ModelPtr _model);
61 
62  // Documentation inherited
63  public: virtual void InitForThread();
64 
65  // Documentation inherited
66  public: virtual void UpdateCollision();
67 
68  // Documentation inherited
69  public: virtual void UpdatePhysics();
70 
71  // Documentation inherited
72  public: virtual void Fini();
73 
74  // Documentation inherited
75  public: virtual std::string GetType() const;
76 
77  // Documentation inherited
78  public: virtual LinkPtr CreateLink(ModelPtr _parent);
79 
80  // Documentation inherited
81  public: virtual CollisionPtr CreateCollision(const std::string &_type,
82  LinkPtr _body);
83 
84  // Documentation inherited
85  public: virtual JointPtr CreateJoint(const std::string &_type,
86  ModelPtr _parent);
87 
88  // Documentation inherited
89  public: virtual ShapePtr CreateShape(const std::string &_shapeType,
90  CollisionPtr _collision);
91 
93  public: SimTK::MultibodySystem *GetDynamicsWorld() const;
94 
95  // Documentation inherited
96  public: virtual void SetGravity(const gazebo::math::Vector3 &_gravity);
97 
98  // Documentation inherited
99  public: virtual void DebugPrint() const;
100 
101  // Documentation inherited
102  public: virtual void SetSeed(uint32_t _seed);
103 
104  // Documentation inherited
105  public: virtual ModelPtr CreateModel(BasePtr _parent);
106 
110  public: static SimTK::Quaternion QuadToQuad(const math::Quaternion &_q);
111 
115  public: static math::Quaternion QuadToQuad(const SimTK::Quaternion &_q);
116 
120  public: static SimTK::Vec3 Vector3ToVec3(const math::Vector3 &_v);
121 
125  public: static math::Vector3 Vec3ToVector3(const SimTK::Vec3 &_v);
126 
133  public: static SimTK::Transform Pose2Transform(const math::Pose &_pose);
134 
139  public: static math::Pose Transform2Pose(const SimTK::Transform &_xAB);
140 
144  public: static SimTK::Transform GetPose(sdf::ElementPtr _element);
145 
150  public: static std::string GetTypeString(unsigned int _type);
151 
156  public: static std::string GetTypeString(physics::Base::EntityType _type);
157 
158  // Documentation inherited
159  protected: virtual void OnRequest(ConstRequestPtr &_msg);
160 
161  // Documentation inherited
162  protected: virtual void OnPhysicsMsg(ConstPhysicsPtr &_msg);
163 
172  private: void CreateMultibodyGraph(
173  SimTK::MultibodyGraphMaker& _mbgraph, const physics::ModelPtr _model);
174 
185  private: void InitSimbodySystem();
186 
189  private: void AddStaticModelToSimbodySystem(
190  const physics::ModelPtr _model);
191 
195  private: void AddDynamicModelToSimbodySystem(
196  const SimTK::MultibodyGraphMaker &_mbgraph,
197  const physics::ModelPtr _model);
198 
200  private: void AddCollisionsToLink(const physics::SimbodyLink *_link,
201  SimTK::MobilizedBody &_mobod, SimTK::ContactCliqueId _modelClique);
202 
203  public: SimTK::MultibodySystem system;
204  public: SimTK::SimbodyMatterSubsystem matter;
205  public: SimTK::GeneralForceSubsystem forces;
206  public: SimTK::Force::Gravity gravity;
207  public: SimTK::Force::DiscreteForces discreteForces;
208  public: SimTK::ContactTrackerSubsystem tracker;
209  public: SimTK::CompliantContactSubsystem contact;
210  public: SimTK:: Integrator *integ;
211 
214 
215  public: bool simbodyPhysicsStepped;
216 
218  private: double contactMaterialStiffness;
219 
221  private: double contactMaterialDissipation;
222 
225  private: double contactMaterialPlasticCoefRestitution;
226 
229  private: double contactMaterialPlasticImpactVelocity;
230 
233  private: double contactMaterialStaticFriction;
234 
237  private: double contactMaterialDynamicFriction;
238 
241  private: double contactMaterialViscousFriction;
242 
245  private: double contactImpactCaptureVelocity;
246 
249  private: double contactStictionTransitionVelocity;
250 
251  private: SimTK::MultibodySystem *dynamicsWorld;
252 
253  private: common::Time lastUpdateTime;
254 
255  private: double stepTimeDouble;
256  };
258  }
259 }
260 #endif