All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ODEJoint.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 #ifndef _ODEJOINT_HH_
18 #define _ODEJOINT_HH_
19 
20 #include <boost/any.hpp>
21 #include <string>
22 
24 #include "gazebo/physics/Joint.hh"
25 #include "gazebo/util/system.hh"
26 
27 namespace gazebo
28 {
29  namespace physics
30  {
32  class GAZEBO_VISIBLE ODEJoint : public Joint
33  {
35  public: enum CFMMode
36  {
38  NONE = 0x00000000,
40  DAMPING_ACTIVE = 0x00000001,
42  JOINT_LIMIT = 0x00000002
43  };
44 
47  public: ODEJoint(BasePtr _parent);
48 
50  public: virtual ~ODEJoint();
51 
52  // Documentation inherited.
53  public: virtual void Load(sdf::ElementPtr _sdf);
54 
55  // Documentation inherited.
56  public: virtual void Reset();
57 
58  // Documentation inherited.
59  public: virtual LinkPtr GetJointLink(unsigned int _index) const;
60 
61  // Documentation inherited.
62  public: virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const;
63 
70  public: virtual double GetParam(unsigned int _parameter) const;
71 
78  public: virtual void SetParam(unsigned int _parameter, double _value);
79 
80  // Documentation inherited
81  public: virtual void SetDamping(unsigned int _index, double _damping);
82 
83  // Documentation inherited.
84  public: virtual bool SetPosition(unsigned int _index, double _position);
85 
86  // Documentation inherited.
87  public: virtual void SetStiffness(unsigned int _index,
88  const double _stiffness);
89 
90  // Documentation inherited.
91  public: virtual void SetStiffnessDamping(unsigned int _index,
92  double _stiffness, double _damping, double _reference = 0);
93 
94  // Documentation inherited.
95  public: virtual void Attach(LinkPtr _parent, LinkPtr _child);
96 
97  // Documentation inherited.
98  public: virtual void Detach();
99 
102  public: void SetERP(double _erp);
103 
106  public: double GetERP();
107 
110  public: void SetCFM(double _cfm);
111 
114  public: double GetCFM();
115 
118  public: dJointFeedback *GetFeedback();
119 
122  public: bool UsesImplicitSpringDamper();
123 
126  public: void ApplyImplicitStiffnessDamping();
127 
129  public: void ApplyExplicitStiffnessDamping();
130 
133  public: double GetStopCFM()
134  {
135  return this->stopCFM;
136  }
137 
140  public: double GetStopERP()
141  {
142  return this->stopERP;
143  }
144 
154  private: double ApplyAdaptiveDamping(unsigned int _index,
155  const double _damping);
156 
163  private: void KpKdToCFMERP(const double _dt,
164  const double _kp, const double _kd,
165  double &_cfm, double &_erp);
166 
173  private: void CFMERPToKpKd(const double _dt,
174  const double _cfm, const double _erp,
175  double &_kp, double &_kd);
176 
178  private: int implicitDampingState[MAX_JOINT_AXIS];
179 
181  private: double currentKd[MAX_JOINT_AXIS];
182 
184  private: double currentKp[MAX_JOINT_AXIS];
185 
188  private: bool stiffnessDampingInitialized;
189 
191  private: bool useImplicitSpringDamper;
192 
193  // Documentation inherited.
194  public: virtual bool SetHighStop(unsigned int _index,
195  const math::Angle &_angle);
196 
197  // Documentation inherited.
198  public: virtual bool SetLowStop(unsigned int _index,
199  const math::Angle &_angle);
200 
201  // Documentation inherited.
202  public: virtual math::Angle GetHighStop(unsigned int _index);
203 
204  // Documentation inherited.
205  public: virtual math::Angle GetLowStop(unsigned int _index);
206 
207  // Documentation inherited.
208  public: virtual math::Vector3 GetLinkForce(unsigned int _index) const;
209 
210  // Documentation inherited.
211  public: virtual math::Vector3 GetLinkTorque(unsigned int _index) const;
212 
213  // Documentation inherited.
214  public: virtual void SetAxis(unsigned int _index,
215  const math::Vector3 &_axis);
216 
217  // Documentation inherited.
218  public: virtual bool SetParam(const std::string &_key,
219  unsigned int _index,
220  const boost::any &_value);
221 
222  // Documentation inherited.
223  public: virtual double GetParam(const std::string &_key,
224  unsigned int _index);
225 
226  // Documentation inherited.
227  public: virtual void SetProvideFeedback(bool _enable);
228 
229  // Documentation inherited.
230  public: virtual JointWrench GetForceTorque(unsigned int _index);
231 
232  // Documentation inherited.
233  public: virtual void SetForce(unsigned int _index, double _force);
234 
235  // Documentation inherited.
236  public: virtual double GetForce(unsigned int _index);
237 
238  // Documentation inherited.
239  public: virtual void ApplyStiffnessDamping();
240 
241  // Documentation inherited.
250  protected: virtual void SetForceImpl(
251  unsigned int _index, double _force) = 0;
252 
256  private: void SaveForce(unsigned int _index, double _force);
257 
259  protected: dJointID jointId;
260 
262  private: dJointFeedback *feedback;
263 
265  private: double stopCFM;
266 
268  private: double stopERP;
269 
275  private: double forceApplied[MAX_JOINT_AXIS];
276 
279  private: common::Time forceAppliedTime;
280  };
281  }
282 }
283 #endif
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:66
double GetStopCFM()
Get access to stopCFM.
Definition: ODEJoint.hh:133
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
dJointID jointId
This is our ODE ID.
Definition: ODEJoint.hh:259
CFMMode
internal variables used for implicit damping
Definition: ODEJoint.hh:35
#define MAX_JOINT_AXIS
maximum number of axis per joint anticipated.
Definition: Joint.hh:39
double GetStopERP()
Get access to stopERP.
Definition: ODEJoint.hh:140
Base class for all joints.
Definition: Joint.hh:50
Wrench information from a joint.
Definition: JointWrench.hh:39
ODE joint interface.
Definition: ODEJoint.hh:32
An angle and related functions.
Definition: Angle.hh:52
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:90
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:43