SimbodyJoint.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 
18 #ifndef _SIMBODY_JOINT_HH_
19 #define _SIMBODY_JOINT_HH_
20 
21 #include <boost/any.hpp>
22 #include <string>
23 
25 #include "gazebo/physics/Joint.hh"
26 #include "gazebo/util/system.hh"
27 
28 namespace gazebo
29 {
30  namespace physics
31  {
35 
37  class GZ_PHYSICS_VISIBLE SimbodyJoint : public Joint
38  {
40  public: explicit SimbodyJoint(BasePtr _parent);
41 
43  public: virtual ~SimbodyJoint();
44 
45  // Documentation inherited.
46  public: virtual void Load(sdf::ElementPtr _sdf);
47 
48  // Documentation inherited.
49  public: virtual void Reset();
50 
51  // Documentation inherited.
52  public: virtual LinkPtr GetJointLink(unsigned int _index) const;
53 
54  // Documentation inherited.
55  public: virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const;
56 
57  // Documentation inherited.
58  public: virtual void Detach();
59 
60  // Documentation inherited.
61  public: virtual void SetAnchor(const unsigned int _index,
62  const ignition::math::Vector3d &_anchor);
63 
64  // Documentation inherited.
65  public: virtual void SetDamping(unsigned int _index,
66  const double _damping);
67 
68  // Documentation inherited.
69  public: virtual void SetStiffness(unsigned int _index,
70  const double _stiffness);
71 
72  // Documentation inherited.
73  public: virtual void SetStiffnessDamping(unsigned int _index,
74  double _stiffness, double _damping, double _reference = 0);
75 
76  // Documentation inherited.
77  public: virtual ignition::math::Vector3d Anchor(
78  const unsigned int _index) const;
79 
80  // Documentation inherited.
81  public: virtual bool SetPosition(
82  const unsigned int _index,
83  const double _position,
84  const bool _preserveWorldVelocity = false)
85  override;
86 
87  // Documentation inherited.
88  public: virtual ignition::math::Vector3d LinkForce(
89  const unsigned int _index) const;
90 
91  // Documentation inherited.
92  public: virtual ignition::math::Vector3d LinkTorque(
93  const unsigned int _index) const;
94 
95  // Documentation inherited.
96  public: virtual bool SetParam(const std::string &_key,
97  unsigned int _index,
98  const boost::any &_value);
99 
100  // Documentation inherited.
101  public: virtual double GetParam(const std::string &_key,
102  unsigned int _index);
103 
104  // Save current Simbody State
105  public: virtual void SaveSimbodyState(const SimTK::State &_state);
106 
107  // Restore saved Simbody State
108  public: virtual void RestoreSimbodyState(SimTK::State &_state);
109 
110  // Documentation inherited.
111  public: virtual void SetForce(unsigned int _index, double _force);
112 
113  // Documentation inherited.
114  public: virtual double GetForce(unsigned int _index);
115 
116  // Documentation inherited.
117  public: virtual void SetAxis(const unsigned int _index,
118  const ignition::math::Vector3d &_axis);
119 
120  // Documentation inherited.
121  public: virtual JointWrench GetForceTorque(unsigned int _index);
122 
133  protected: virtual void SetForceImpl(unsigned int _index,
134  double _force) = 0;
135 
139  private: void SaveForce(unsigned int _index, double _force);
140 
141  // Documentation inherited.
142  public: virtual void CacheForceTorque();
143 
147  public: bool mustBreakLoopHere;
148 
151  public: SimTK::Transform xPA;
152 
154  public: SimTK::Transform xCB;
155 
157  public: SimTK::Transform defxAB;
158 
164  public: SimTK::Force::MobilityLinearSpring spring[MAX_JOINT_AXIS];
165 
170  public: SimTK::Force::MobilityLinearDamper damper[MAX_JOINT_AXIS];
171 
177  public: SimTK::Force::MobilityLinearStop limitForce[MAX_JOINT_AXIS];
178 
184  public: SimTK::MobilizedBody mobod;
185 
188  public: bool isReversed;
189 
195  public: SimTK::Constraint constraint;
196 
197  // Keeps track if simbody physics has been initialized
198  public: bool physicsInitialized;
199 
200  // Documentation inherited.
201  public: virtual void SetUpperLimit(const unsigned int _index,
202  const double _limit);
203 
204  // Documentation inherited.
205  public: virtual void SetLowerLimit(const unsigned int _index,
206  const double _limit);
207 
208  // Documentation inherited.
209  public: virtual double UpperLimit(const unsigned int _index) const;
210 
211  // Documentation inherited.
212  public: virtual double LowerLimit(const unsigned int _index) const;
213 
215  protected: SimTK::MultibodySystem *world;
216 
219 
228  private: double forceApplied[MAX_JOINT_AXIS];
229 
232  private: common::Time forceAppliedTime;
233  };
235  }
236 }
237 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
SimTK::Constraint constraint
: isValid() if we used a constraint to model this joint.
Definition: SimbodyJoint.hh:195
bool isReversed
: if mobilizer, did it reverse parent&child? Set when we build the Simbody model. ...
Definition: SimbodyJoint.hh:188
SimTK::Transform xCB
child body frame to mobilizer frame
Definition: SimbodyJoint.hh:154
SimTK::Transform xPA
Normally A=F, B=M.
Definition: SimbodyJoint.hh:151
SimbodyPhysicsPtr simbodyPhysics
keep a pointer to the simbody physics engine for convenience
Definition: SimbodyJoint.hh:218
Base class for all joints.
Definition: SimbodyJoint.hh:37
boost::shared_ptr< SimbodyPhysics > SimbodyPhysicsPtr
Definition: SimbodyTypes.hh:40
#define MAX_JOINT_AXIS
maximum number of axis per joint anticipated.
Definition: Joint.hh:39
SimTK::MultibodySystem * world
Simbody Multibody System.
Definition: SimbodyJoint.hh:215
SimTK::Transform defxAB
default mobilizer pose
Definition: SimbodyJoint.hh:157
Base class for all joints.
Definition: Joint.hh:50
Wrench information from a joint.
Definition: JointWrench.hh:40
SimTK::MobilizedBody mobod
Use isValid() if we used a mobilizer Set when we build the Simbody model.
Definition: SimbodyJoint.hh:184
bool physicsInitialized
Definition: SimbodyJoint.hh:198
bool mustBreakLoopHere
Force Simbody to break a loop by using a weld constraint.
Definition: SimbodyJoint.hh:147
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44