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