SimbodyLink.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 
39  class GZ_PHYSICS_VISIBLE SimbodyLink : public Link
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 AddLinkForce(const math::Vector3 &_force,
130  const math::Vector3 &_offset = math::Vector3::Zero);
131 
132  // Documentation inherited.
133  public: virtual void AddTorque(const math::Vector3 &_torque);
134 
135  // Documentation inherited.
136  public: virtual void AddRelativeTorque(const math::Vector3 &_torque);
137 
138  // Documentation inherited.
139  public: virtual void SetAutoDisable(bool _disable);
140 
141  // Documentation inherited.
142  public: virtual void SaveSimbodyState(const SimTK::State &_state);
143 
144  // Documentation inherited.
145  public: virtual void RestoreSimbodyState(SimTK::State &_state);
146 
152  public: virtual void SetLinkStatic(bool _static);
153 
157  public: SimTK::MassProperties GetMassProperties() const;
158 
159  public: SimTK::MassProperties GetEffectiveMassProps(
160  int _numFragments) const;
161 
162  public: void SetDirtyPose(const math::Pose &_pose);
163 
164  // Documentation inherited.
165  public: virtual void UpdateMass();
166 
169  private: void ProcessSetGravityMode();
170 
173  private: void ProcessSetLinkStatic();
174 
177  public: bool mustBeBaseLink;
178 
179  // Below to be filled in after everything is loaded
180  // Which MobilizedBody corresponds to the master instance of this link.
181  public: SimTK::MobilizedBody masterMobod;
182 
183  // Keeps track if physics has been initialized
184  public: bool physicsInitialized;
185 
186  // If this link got split into a master and slaves, these are the
187  // MobilizedBodies used to mobilize the slaves.
188  public: std::vector<SimTK::MobilizedBody> slaveMobods;
189 
190  // And these are the Weld constraints used to attach slaves to master.
191  public: std::vector<SimTK::Constraint::Weld> slaveWelds;
192 
194  private: bool gravityMode;
195 
197  private: bool staticLinkDirty;
198 
200  private: bool gravityModeDirty;
201 
203  private: bool staticLink;
204 
206  private: event::ConnectionPtr staticLinkConnection;
207 
209  private: event::ConnectionPtr gravityModeConnection;
210 
212  private: std::vector<double> simbodyQ;
213 
215  private: std::vector<double> simbodyU;
216 
218  private: SimbodyPhysicsPtr simbodyPhysics;
219  };
221  }
222 }
223 #endif
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
GAZEBO_VISIBLE void enable()
Enable sensors.
boost::shared_ptr< SimbodyPhysics > SimbodyPhysicsPtr
Definition: SimbodyTypes.hh:40
A quaternion class.
Definition: Quaternion.hh:42
Simbody wrapper forward declarations and typedefs.
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:153
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:85
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
static const Vector3 Zero
math::Vector3(0, 0, 0)
Definition: Vector3.hh:42