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 2011 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 "gazebo/common/Event.hh"
28 #include "gazebo/math/Angle.hh"
29 #include "gazebo/math/Vector3.hh"
30 #include "gazebo/msgs/MessageTypes.hh"
31 
33 #include "gazebo/physics/Base.hh"
34 
35 namespace gazebo
36 {
37  namespace physics
38  {
41 
44  class Joint : public Base
45  {
48  public: enum Attribute
49  {
52 
55 
58 
61 
64 
66  ERP,
67 
69  CFM,
70 
73 
75  VEL,
76 
79 
82  };
83 
86  public: explicit Joint(BasePtr _parent);
87 
89  public: virtual ~Joint();
90 
95  public: void Load(LinkPtr _parent, LinkPtr _child,
96  const math::Pose &_pose);
97 
100  public: virtual void Load(sdf::ElementPtr _sdf);
101 
103  public: virtual void Init();
104 
106  public: void Update();
107 
110  public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
111 
113  public: virtual void Reset();
114 
117  public: JointState GetState();
118 
121  public: void SetState(const JointState &_state);
122 
125  public: void SetModel(ModelPtr _model);
126 
132  public: virtual LinkPtr GetJointLink(int _index) const = 0;
133 
138  public: virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const = 0;
139 
143  public: virtual void Attach(LinkPtr _parent, LinkPtr _child);
144 
146  public: virtual void Detach();
147 
151  public: virtual void SetAxis(int _index, const math::Vector3 &_axis) = 0;
152 
156  public: virtual void SetDamping(int _index, double _damping) = 0;
157 
161  public: template<typename T>
163  {return jointUpdate.Connect(_subscriber);}
164 
168  {jointUpdate.Disconnect(_conn);}
169 
173  public: math::Vector3 GetLocalAxis(int _index) const;
174 
178  public: virtual math::Vector3 GetGlobalAxis(int _index) const = 0;
179 
183  public: virtual void SetAnchor(int _index,
184  const math::Vector3 &_anchor) = 0;
185 
189  public: virtual math::Vector3 GetAnchor(int _index) const = 0;
190 
194  public: virtual void SetHighStop(int _index,
195  const math::Angle &_angle) = 0;
196 
200  public: virtual void SetLowStop(int _index,
201  const math::Angle &_angle) = 0;
202 
206  public: virtual math::Angle GetHighStop(int _index) = 0;
207 
211  public: virtual math::Angle GetLowStop(int _index) = 0;
212 
216  public: virtual void SetVelocity(int _index, double _vel) = 0;
217 
221  public: virtual double GetVelocity(int _index) const = 0;
222 
231  public: virtual void SetForce(int _index, double _force);
232 
242  public: virtual double GetForce(int _index);
243 
252  public: virtual void SetMaxForce(int _index, double _force) = 0;
253 
262  public: virtual double GetMaxForce(int _index) = 0;
263 
267  public: math::Angle GetAngle(int _index) const;
268 
278  public: void SetAngle(int _index, math::Angle _angle);
279 
289  public: virtual math::Vector3 GetLinkForce(unsigned int _index) const = 0;
290 
300  public: virtual math::Vector3 GetLinkTorque(
301  unsigned int _index) const = 0;
302 
307  public: virtual void SetAttribute(Attribute _attr, int _index,
308  double _value) = 0;
309 
312  public: LinkPtr GetChild() const;
313 
316  public: LinkPtr GetParent() const;
317 
320  public: void FillJointMsg(msgs::Joint &_msg) GAZEBO_DEPRECATED;
321 
324  public: void FillMsg(msgs::Joint &_msg);
325 
329  protected: virtual math::Angle GetAngleImpl(int _index) const = 0;
330 
333  private: void LoadImpl(const math::Pose &_pose);
334 
336  protected: LinkPtr childLink;
337 
339  protected: LinkPtr parentLink;
340 
342  protected: ModelPtr model;
343 
346 
348  protected: LinkPtr anchorLink;
349 
351  private: event::EventT<void ()> jointUpdate;
352 
354  protected: double damping_coefficient;
355 
357  private: math::Angle staticAngle;
358  };
360  }
361 }
362 #endif