All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimbodyLink.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 
18 #ifndef _SIMBODY_LINK_HH_
19 #define _SIMBODY_LINK_HH_
20 
21 #include <vector>
22 
24 #include "gazebo/physics/Link.hh"
25 
27 
28 namespace gazebo
29 {
30  namespace physics
31  {
36 
38  class SimbodyLink : public Link
39  {
41  public: SimbodyLink(EntityPtr _parent);
42 
44  public: virtual ~SimbodyLink();
45 
46  // Documentation inherited.
47  public: virtual void Load(sdf::ElementPtr _ptr);
48 
49  // Documentation inherited.
50  public: virtual void Init();
51 
52  // Documentation inherited.
53  public: virtual void Fini();
54 
55  // Documentation inherited.
56  public: virtual void OnPoseChange();
57 
58  // Documentation inherited.
59  public: virtual void SetEnabled(bool enable) const;
60 
61  // Documentation inherited.
62  public: virtual bool GetEnabled() const;
63 
64  // Documentation inherited.
65  public: virtual void SetLinearVel(const math::Vector3 &_vel);
66 
67  // Documentation inherited.
68  public: virtual void SetAngularVel(const math::Vector3 &_vel);
69 
70  // Documentation inherited.
71  public: virtual void SetForce(const math::Vector3 &_force);
72 
73  // Documentation inherited.
74  public: virtual void SetTorque(const math::Vector3 &_force);
75 
76  // Documentation inherited.
77  public: virtual math::Vector3 GetWorldLinearVel(
78  const math::Vector3& _vector3) const;
79 
80  // Documentation inherited.
81  public: virtual math::Vector3 GetWorldLinearVel(
82  const math::Vector3 &_offset,
83  const math::Quaternion &_q) const;
84 
85  // Documentation inherited.
86  public: virtual math::Vector3 GetWorldCoGLinearVel() const;
87 
88  // Documentation inherited.
89  public: virtual math::Vector3 GetWorldAngularVel() const;
90 
91  // Documentation inherited.
92  public: virtual math::Vector3 GetWorldForce() const;
93 
94  // Documentation inherited.
95  public: virtual math::Vector3 GetWorldTorque() const;
96 
97  // Documentation inherited.
98  public: virtual void SetGravityMode(bool _mode);
99 
100  // Documentation inherited.
101  public: virtual bool GetGravityMode() const;
102 
103  // Documentation inherited.
104  public: virtual void SetSelfCollide(bool _collide);
105 
106  // Documentation inherited.
107  public: virtual void SetLinearDamping(double _damping);
108 
109  // Documentation inherited.
110  public: virtual void SetAngularDamping(double _damping);
111 
112  // Documentation inherited.
113  public: virtual void AddForce(const math::Vector3 &_force);
114 
115  // Documentation inherited.
116  public: virtual void AddRelativeForce(const math::Vector3 &_force);
117 
118  // Documentation inherited.
119  public: virtual void AddForceAtWorldPosition(const math::Vector3 &_force,
120  const math::Vector3 &_pos);
121 
122  // Documentation inherited.
123  public: virtual void AddForceAtRelativePosition(
124  const math::Vector3 &_force,
125  const math::Vector3 &_relpos);
126 
127  // Documentation inherited.
128  public: virtual void AddTorque(const math::Vector3 &_torque);
129 
130  // Documentation inherited.
131  public: virtual void AddRelativeTorque(const math::Vector3 &_torque);
132 
133  // Documentation inherited.
134  public: virtual void SetAutoDisable(bool _disable);
135 
136  // Documentation inherited.
137  public: virtual void SaveSimbodyState(const SimTK::State &_state);
138 
139  // Documentation inherited.
140  public: virtual void RestoreSimbodyState(SimTK::State &_state);
141 
147  public: virtual void SetLinkStatic(bool _static);
148 
152  public: SimTK::MassProperties GetMassProperties() const;
153 
154  public: SimTK::MassProperties GetEffectiveMassProps(
155  int _numFragments) const;
156 
157  public: void SetDirtyPose(const math::Pose &_pose);
158 
161  private: void ProcessSetLinkStatic();
162 
165  public: bool mustBeBaseLink;
166 
167  // Below to be filled in after everything is loaded
168  // Which MobilizedBody corresponds to the master instance of this link.
169  public: SimTK::MobilizedBody masterMobod;
170 
171  // Keeps track if physics has been initialized
172  public: bool physicsInitialized;
173 
174  // If this link got split into a master and slaves, these are the
175  // MobilizedBodies used to mobilize the slaves.
176  public: std::vector<SimTK::MobilizedBody> slaveMobods;
177 
178  // And these are the Weld constraints used to attach slaves to master.
179  public: std::vector<SimTK::Constraint::Weld> slaveWelds;
180 
182  private: bool gravityMode;
183 
185  private: bool staticLinkDirty;
186 
188  private: bool staticLink;
189 
191  private: event::ConnectionPtr staticLinkConnection;
192 
194  private: std::vector<double> simbodyQ;
195 
197  private: std::vector<double> simbodyU;
198 
200  private: SimbodyPhysicsPtr simbodyPhysics;
201  };
203  }
204 }
205 #endif