All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Joint.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
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 /* Desc: The base joint class
18  * Author: Nate Koenig, Andrew Howard
19  * Date: 21 May 2003
20  */
21 
22 #ifndef _JOINT_HH_
23 #define _JOINT_HH_
24 
25 #include <string>
26 
27 #include <boost/any.hpp>
28 
29 #include "gazebo/common/Event.hh"
30 #include "gazebo/math/Angle.hh"
31 #include "gazebo/math/Vector3.hh"
32 #include "gazebo/msgs/MessageTypes.hh"
33 
35 #include "gazebo/physics/Base.hh"
36 
37 namespace gazebo
38 {
39  namespace physics
40  {
43 
46  class Joint : public Base
47  {
50  public: enum Attribute
51  {
54 
57 
60 
63 
66 
68  ERP,
69 
71  CFM,
72 
75 
77  VEL,
78 
81 
84  };
85 
88  public: explicit Joint(BasePtr _parent);
89 
91  public: virtual ~Joint();
92 
97  public: void Load(LinkPtr _parent, LinkPtr _child,
98  const math::Pose &_pose);
99 
102  public: virtual void Load(sdf::ElementPtr _sdf);
103 
105  public: virtual void Init();
106 
108  public: void Update();
109 
112  public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
113 
115  public: virtual void Reset();
116 
119  public: void SetState(const JointState &_state);
120 
123  public: void SetModel(ModelPtr _model);
124 
130  public: virtual LinkPtr GetJointLink(int _index) const = 0;
131 
136  public: virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const = 0;
137 
141  public: virtual void Attach(LinkPtr _parent, LinkPtr _child);
142 
144  public: virtual void Detach();
145 
149  public: virtual void SetAxis(int _index, const math::Vector3 &_axis) = 0;
150 
154  public: virtual void SetDamping(int _index, double _damping) = 0;
155 
159  public: template<typename T>
161  {return jointUpdate.Connect(_subscriber);}
162 
166  {jointUpdate.Disconnect(_conn);}
167 
171  public: math::Vector3 GetLocalAxis(int _index) const;
172 
176  public: virtual math::Vector3 GetGlobalAxis(int _index) const = 0;
177 
181  public: virtual void SetAnchor(int _index,
182  const math::Vector3 &_anchor) = 0;
183 
187  public: virtual math::Vector3 GetAnchor(int _index) const = 0;
188 
192  public: virtual void SetHighStop(int _index,
193  const math::Angle &_angle) = 0;
194 
198  public: virtual void SetLowStop(int _index,
199  const math::Angle &_angle) = 0;
200 
204  public: virtual math::Angle GetHighStop(int _index) = 0;
205 
209  public: virtual math::Angle GetLowStop(int _index) = 0;
210 
214  public: virtual void SetVelocity(int _index, double _vel) = 0;
215 
219  public: virtual double GetVelocity(int _index) const = 0;
220 
229  public: virtual void SetForce(int _index, double _force);
230 
240  public: virtual double GetForce(int _index);
241 
250  public: virtual void SetMaxForce(int _index, double _force) = 0;
251 
260  public: virtual double GetMaxForce(int _index) = 0;
261 
265  public: math::Angle GetAngle(int _index) const;
266 
269  public: virtual unsigned int GetAngleCount() const = 0;
270 
280  public: void SetAngle(int _index, math::Angle _angle);
281 
291  public: virtual math::Vector3 GetLinkForce(unsigned int _index) const = 0;
292 
302  public: virtual math::Vector3 GetLinkTorque(
303  unsigned int _index) const = 0;
304 
309  public: virtual void SetAttribute(Attribute _attr, int _index,
310  double _value) GAZEBO_DEPRECATED = 0;
311 
317  public: virtual void SetAttribute(const std::string &_key, int _index,
318  const boost::any &_value) = 0;
319 
322  public: LinkPtr GetChild() const;
323 
326  public: LinkPtr GetParent() const;
327 
331  public: void FillJointMsg(msgs::Joint &_msg) GAZEBO_DEPRECATED;
332 
335  public: void FillMsg(msgs::Joint &_msg);
336 
340  protected: virtual math::Angle GetAngleImpl(int _index) const = 0;
341 
344  private: void LoadImpl(const math::Pose &_pose);
345 
347  protected: LinkPtr childLink;
348 
350  protected: LinkPtr parentLink;
351 
353  protected: ModelPtr model;
354 
357 
359  protected: LinkPtr anchorLink;
360 
362  private: event::EventT<void ()> jointUpdate;
363 
365  protected: double damping_coefficient;
366 
368  private: math::Angle staticAngle;
369  };
371  }
372 }
373 #endif