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
26#include "gazebo/util/system.hh"
27
28namespace 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) override;
47
48 // Documentation inherited.
49 public: virtual void Reset() override;
50
51 // Documentation inherited.
52 public: virtual LinkPtr GetJointLink(unsigned int _index) const override;
53
54 // Documentation inherited.
55 public: virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const
56 override;
57
58 // Documentation inherited.
59 public: virtual void Detach() override;
60
61 // Documentation inherited.
62 public: virtual void SetAnchor(const unsigned int _index,
63 const ignition::math::Vector3d &_anchor) override;
64
65 // Documentation inherited.
66 public: virtual void SetDamping(unsigned int _index,
67 const double _damping) override;
68
69 // Documentation inherited.
70 public: virtual void SetStiffness(unsigned int _index,
71 const double _stiffness) override;
72
73 // Documentation inherited.
74 public: virtual void SetStiffnessDamping(unsigned int _index,
75 double _stiffness, double _damping, double _reference = 0) override;
76
77 // Documentation inherited.
78 public: virtual ignition::math::Vector3d Anchor(
79 const unsigned int _index) const override;
80
81 // Documentation inherited.
82 public: virtual bool SetPosition(
83 const unsigned int _index,
84 const double _position,
85 const bool _preserveWorldVelocity = false)
86 override;
87
88 // Documentation inherited.
89 public: virtual ignition::math::Vector3d LinkForce(
90 const unsigned int _index) const override;
91
92 // Documentation inherited.
93 public: virtual ignition::math::Vector3d LinkTorque(
94 const unsigned int _index) const override;
95
96 // Documentation inherited.
97 public: virtual bool SetParam(const std::string &_key,
98 unsigned int _index,
99 const boost::any &_value)
100 override;
101
102 // Documentation inherited.
103 public: virtual double GetParam(const std::string &_key,
104 unsigned int _index) override;
105
106 // Save current Simbody State
107 public: virtual void SaveSimbodyState(const SimTK::State &_state);
108
109 // Restore saved Simbody State
110 public: virtual void RestoreSimbodyState(SimTK::State &_state);
111
112 // Documentation inherited.
113 public: virtual void SetForce(unsigned int _index, double _force)
114 override;
115
116 // Documentation inherited.
117 public: virtual double GetForce(unsigned int _index) override;
118
119 // Documentation inherited.
120 public: virtual void SetAxis(const unsigned int _index,
121 const ignition::math::Vector3d &_axis)
122 override;
123
124 // Documentation inherited.
125 public: virtual JointWrench GetForceTorque(unsigned int _index) override;
126
137 protected: virtual void SetForceImpl(unsigned int _index,
138 double _force) = 0;
139
143 private: void SaveForce(unsigned int _index, double _force);
144
145 // Documentation inherited.
146 public: virtual void CacheForceTorque() override;
147
151 public: bool mustBreakLoopHere;
152
155 public: SimTK::Transform xPA;
156
158 public: SimTK::Transform xCB;
159
161 public: SimTK::Transform defxAB;
162
168 public: SimTK::Force::MobilityLinearSpring spring[MAX_JOINT_AXIS];
169
174 public: SimTK::Force::MobilityLinearDamper damper[MAX_JOINT_AXIS];
175
181 public: SimTK::Force::MobilityLinearStop limitForce[MAX_JOINT_AXIS];
182
188 public: SimTK::MobilizedBody mobod;
189
192 public: bool isReversed;
193
199 public: SimTK::Constraint constraint;
200
201 // Keeps track if simbody physics has been initialized
202 public: bool physicsInitialized;
203
204 // Documentation inherited.
205 public: virtual void SetUpperLimit(const unsigned int _index,
206 const double _limit) override;
207
208 // Documentation inherited.
209 public: virtual void SetLowerLimit(const unsigned int _index,
210 const double _limit) override;
211
212 // Documentation inherited.
213 public: virtual double UpperLimit(const unsigned int _index) const
214 override;
215
216 // Documentation inherited.
217 public: virtual double LowerLimit(const unsigned int _index) const
218 override;
219
221 protected: SimTK::MultibodySystem *world;
222
225
234 private: double forceApplied[MAX_JOINT_AXIS];
235
238 private: common::Time forceAppliedTime;
239 };
241 }
242}
243#endif
#define MAX_JOINT_AXIS
maximum number of axis per joint anticipated.
Definition Joint.hh:39
A Time class, can be used to hold wall- or sim-time.
Definition Time.hh:48
Wrench information from a joint.
Definition JointWrench.hh:41
Base class for all joints.
Definition Joint.hh:51
Base class for all joints.
Definition SimbodyJoint.hh:38
bool physicsInitialized
Definition SimbodyJoint.hh:202
virtual void SetAxis(const unsigned int _index, const ignition::math::Vector3d &_axis) override
Set the axis of rotation where axis is specified in local joint frame.
virtual void SetDamping(unsigned int _index, const double _damping) override
Set the joint damping.
virtual ignition::math::Vector3d LinkForce(const unsigned int _index) const override
Get the forces applied to the center of mass of a physics::Link due to the existence of this Joint.
virtual void RestoreSimbodyState(SimTK::State &_state)
bool isReversed
: if mobilizer, did it reverse parent&child? Set when we build the Simbody model.
Definition SimbodyJoint.hh:192
SimbodyPhysicsPtr simbodyPhysics
keep a pointer to the simbody physics engine for convenience
Definition SimbodyJoint.hh:224
bool mustBreakLoopHere
Force Simbody to break a loop by using a weld constraint.
Definition SimbodyJoint.hh:151
virtual void Detach() override
Detach this joint from all links.
virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const override
Determines of the two bodies are connected by a joint.
virtual ignition::math::Vector3d LinkTorque(const unsigned int _index) const override
Get the torque applied to the center of mass of a physics::Link due to the existence of this Joint.
SimTK::Transform xCB
child body frame to mobilizer frame
Definition SimbodyJoint.hh:158
virtual double LowerLimit(const unsigned int _index) const override
Get the joint's lower limit.
virtual ignition::math::Vector3d Anchor(const unsigned int _index) const override
Get the anchor point.
SimTK::Transform defxAB
default mobilizer pose
Definition SimbodyJoint.hh:161
SimTK::Constraint constraint
: isValid() if we used a constraint to model this joint.
Definition SimbodyJoint.hh:199
SimTK::Force::MobilityLinearSpring spring[MAX_JOINT_AXIS]
: Spring force element for enforcing joint stiffness.
Definition SimbodyJoint.hh:168
virtual void SaveSimbodyState(const SimTK::State &_state)
virtual bool SetPosition(const unsigned int _index, const double _position, const bool _preserveWorldVelocity=false) override
The child links of this joint are updated based on desired position.
virtual JointWrench GetForceTorque(unsigned int _index) override
get internal force and torque values at a joint.
virtual double GetForce(unsigned int _index) override
SimTK::Transform xPA
Normally A=F, B=M.
Definition SimbodyJoint.hh:155
SimTK::MultibodySystem * world
Simbody Multibody System.
Definition SimbodyJoint.hh:221
SimTK::Force::MobilityLinearDamper damper[MAX_JOINT_AXIS]
: for enforcing joint damping forces.
Definition SimbodyJoint.hh:174
virtual double GetParam(const std::string &_key, unsigned int _index) override
Get a non-generic parameter for the joint.
virtual void SetLowerLimit(const unsigned int _index, const double _limit) override
Set the joint's lower limit.
virtual double UpperLimit(const unsigned int _index) const override
Get the joint's upper limit.
virtual void SetForce(unsigned int _index, double _force) override
Set the force applied to this physics::Joint.
virtual void SetUpperLimit(const unsigned int _index, const double _limit) override
Set the joint's upper limit.
virtual void SetStiffnessDamping(unsigned int _index, double _stiffness, double _damping, double _reference=0) override
Set the joint spring stiffness.
virtual void SetAnchor(const unsigned int _index, const ignition::math::Vector3d &_anchor) override
Set the anchor point.
SimTK::Force::MobilityLinearStop limitForce[MAX_JOINT_AXIS]
: for enforcing joint stops Set when we build the Simbody model.
Definition SimbodyJoint.hh:181
SimbodyJoint(BasePtr _parent)
Constructor.
virtual void CacheForceTorque() override
Cache Joint Force Torque Values if necessary for physics engine.
SimTK::MobilizedBody mobod
Use isValid() if we used a mobilizer Set when we build the Simbody model.
Definition SimbodyJoint.hh:188
virtual void Reset() override
Reset the joint.
virtual void SetForceImpl(unsigned int _index, double _force)=0
Set the force applied to this physics::Joint.
virtual void SetStiffness(unsigned int _index, const double _stiffness) override
Set the joint spring stiffness.
virtual ~SimbodyJoint()
Destructor.
virtual void Load(sdf::ElementPtr _sdf) override
Load physics::Joint from a SDF sdf::Element.
virtual bool SetParam(const std::string &_key, unsigned int _index, const boost::any &_value) override
Set a non-generic parameter for the joint.
virtual LinkPtr GetJointLink(unsigned int _index) const override
Get the link to which the joint is attached according the _index.
boost::shared_ptr< SimbodyPhysics > SimbodyPhysicsPtr
Definition SimbodyTypes.hh:40
boost::shared_ptr< Link > LinkPtr
Definition PhysicsTypes.hh:109
boost::shared_ptr< Base > BasePtr
Definition PhysicsTypes.hh:77
Forward declarations for the common classes.
Definition Animation.hh:27