SimbodyLink.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 #ifndef GAZEBO_PHYSICS_SIMBODY_SIMBODYLINK_HH_
18 #define GAZEBO_PHYSICS_SIMBODY_SIMBODYLINK_HH_
19 
20 #include <vector>
21 
23 #include "gazebo/physics/Link.hh"
24 
26 #include "gazebo/util/system.hh"
27 
28 namespace gazebo
29 {
30  namespace physics
31  {
36 
38  class GZ_PHYSICS_VISIBLE 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 ignition::math::Vector3d &_vel);
66 
67  // Documentation inherited.
68  public: virtual void SetAngularVel(const ignition::math::Vector3d &_vel);
69 
70  // Documentation inherited.
71  public: virtual void SetForce(const ignition::math::Vector3d &_force);
72 
73  // Documentation inherited.
74  public: virtual void SetTorque(const ignition::math::Vector3d &_force);
75 
76  // Documentation inherited.
77  public: virtual ignition::math::Vector3d WorldLinearVel(
78  const ignition::math::Vector3d &_vector3) const;
79 
80  // Documentation inherited.
81  public: virtual ignition::math::Vector3d WorldLinearVel(
82  const ignition::math::Vector3d &_offset,
83  const ignition::math::Quaterniond &_q) const;
84 
85  // Documentation inherited.
86  public: virtual ignition::math::Vector3d WorldCoGLinearVel() const;
87 
88  // Documentation inherited.
89  public: virtual ignition::math::Vector3d WorldAngularVel() const;
90 
91  // Documentation inherited.
92  public: virtual ignition::math::Vector3d WorldForce() const;
93 
94  // Documentation inherited.
95  public: virtual ignition::math::Vector3d WorldTorque() 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 ignition::math::Vector3d &_force);
114 
115  // Documentation inherited.
116  public: virtual void AddRelativeForce(
117  const ignition::math::Vector3d &_force);
118 
119  // Documentation inherited.
120  public: virtual void AddForceAtWorldPosition(
121  const ignition::math::Vector3d &_force,
122  const ignition::math::Vector3d &_pos);
123 
124  // Documentation inherited.
125  public: virtual void AddForceAtRelativePosition(
126  const ignition::math::Vector3d &_force,
127  const ignition::math::Vector3d &_relpos);
128 
129  // Documentation inherited
130  public: virtual void AddLinkForce(const ignition::math::Vector3d &_force,
131  const ignition::math::Vector3d &_offset =
132  ignition::math::Vector3d::Zero);
133 
134  // Documentation inherited.
135  public: virtual void AddTorque(const ignition::math::Vector3d &_torque);
136 
137  // Documentation inherited.
138  public: virtual void AddRelativeTorque(
139  const ignition::math::Vector3d &_torque);
140 
141  // Documentation inherited.
142  public: virtual void SetAutoDisable(bool _disable);
143 
144  // Documentation inherited.
145  public: virtual void SaveSimbodyState(const SimTK::State &_state);
146 
147  // Documentation inherited.
148  public: virtual void RestoreSimbodyState(SimTK::State &_state);
149 
155  public: virtual void SetLinkStatic(bool _static);
156 
160  public: SimTK::MassProperties GetMassProperties() const;
161 
162  public: SimTK::MassProperties GetEffectiveMassProps(
163  int _numFragments) const;
164 
165  public: void SetDirtyPose(const math::Pose &_pose) GAZEBO_DEPRECATED(8.0);
166 
169  public: void SetDirtyPose(const ignition::math::Pose3d &_pose);
170 
171  // Documentation inherited.
172  public: virtual void UpdateMass();
173 
176  private: void ProcessSetGravityMode();
177 
180  private: void ProcessSetLinkStatic();
181 
184  public: bool mustBeBaseLink;
185 
186  // Below to be filled in after everything is loaded
187  // Which MobilizedBody corresponds to the master instance of this link.
188  public: SimTK::MobilizedBody masterMobod;
189 
190  // Keeps track if physics has been initialized
191  public: bool physicsInitialized;
192 
193  // If this link got split into a master and slaves, these are the
194  // MobilizedBodies used to mobilize the slaves.
195  public: std::vector<SimTK::MobilizedBody> slaveMobods;
196 
197  // And these are the Weld constraints used to attach slaves to master.
198  public: std::vector<SimTK::Constraint::Weld> slaveWelds;
199 
201  private: bool gravityMode;
202 
204  private: bool staticLinkDirty;
205 
207  private: bool gravityModeDirty;
208 
210  private: bool staticLink;
211 
213  private: event::ConnectionPtr staticLinkConnection;
214 
216  private: event::ConnectionPtr gravityModeConnection;
217 
219  private: std::vector<double> simbodyQ;
220 
222  private: std::vector<double> simbodyU;
223 
225  private: SimbodyPhysicsPtr simbodyPhysics;
226  };
228  }
229 }
230 #endif
Encapsulates a position and rotation in three space.
Definition: Pose.hh:42
GAZEBO_VISIBLE void enable()
Enable sensors.
boost::shared_ptr< SimbodyPhysics > SimbodyPhysicsPtr
Definition: SimbodyTypes.hh:40
Simbody wrapper forward declarations and typedefs.
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:85
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.