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 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 /* 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/common/Events.hh"
31 #include "gazebo/math/Angle.hh"
32 #include "gazebo/math/Vector3.hh"
33 #include "gazebo/msgs/MessageTypes.hh"
34 
36 #include "gazebo/physics/Base.hh"
38 
39 namespace gazebo
40 {
41  namespace physics
42  {
45 
48  class Joint : public Base
49  {
52  public: enum Attribute
53  {
56 
59 
62 
65 
68 
70  ERP,
71 
73  CFM,
74 
77 
79  VEL,
80 
83 
86  };
87 
90  public: explicit Joint(BasePtr _parent);
91 
93  public: virtual ~Joint();
94 
99  public: void Load(LinkPtr _parent, LinkPtr _child,
100  const math::Pose &_pose);
101 
109  public: void Load(LinkPtr _parent, LinkPtr _child,
110  const math::Vector3 &_pos) GAZEBO_DEPRECATED;
111 
114  public: virtual void Load(sdf::ElementPtr _sdf);
115 
117  public: virtual void Init();
118 
120  public: void Update();
121 
124  public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
125 
127  public: virtual void Reset();
128 
131  public: void SetState(const JointState &_state);
132 
135  public: void SetModel(ModelPtr _model);
136 
142  public: virtual LinkPtr GetJointLink(int _index) const = 0;
143 
148  public: virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const = 0;
149 
153  public: virtual void Attach(LinkPtr _parent, LinkPtr _child);
154 
156  public: virtual void Detach();
157 
161  public: virtual void SetAxis(int _index, const math::Vector3 &_axis) = 0;
162 
166  public: virtual void SetDamping(int _index, double _damping) = 0;
167 
169  public: virtual void ApplyDamping();
170 
174  public: template<typename T>
176  {return jointUpdate.Connect(_subscriber);}
177 
181  {jointUpdate.Disconnect(_conn);}
182 
186  public: math::Vector3 GetLocalAxis(int _index) const;
187 
191  public: virtual math::Vector3 GetGlobalAxis(int _index) const = 0;
192 
196  public: virtual void SetAnchor(int _index,
197  const math::Vector3 &_anchor) = 0;
198 
202  public: virtual math::Vector3 GetAnchor(int _index) const = 0;
203 
207  public: virtual void SetHighStop(int _index,
208  const math::Angle &_angle) = 0;
209 
213  public: virtual void SetLowStop(int _index,
214  const math::Angle &_angle) = 0;
215 
219  public: virtual math::Angle GetHighStop(int _index) = 0;
220 
224  public: virtual math::Angle GetLowStop(int _index) = 0;
225 
229  public: virtual void SetVelocity(int _index, double _vel) = 0;
230 
234  public: virtual double GetVelocity(int _index) const = 0;
235 
244  public: virtual void SetForce(int _index, double _force);
245 
255  public: virtual double GetForce(int _index);
256 
261  public: virtual JointWrench GetForceTorque(int _index) = 0;
262 
271  public: virtual void SetMaxForce(int _index, double _force) = 0;
272 
281  public: virtual double GetMaxForce(int _index) = 0;
282 
286  public: math::Angle GetAngle(int _index) const;
287 
290  public: virtual unsigned int GetAngleCount() const = 0;
291 
301  public: void SetAngle(int _index, math::Angle _angle);
302 
312  public: virtual math::Vector3 GetLinkForce(unsigned int _index) const = 0;
313 
323  public: virtual math::Vector3 GetLinkTorque(
324  unsigned int _index) const = 0;
325 
331  public: virtual void SetAttribute(const std::string &_key, int _index,
332  const boost::any &_value) = 0;
333 
336  public: LinkPtr GetChild() const;
337 
340  public: LinkPtr GetParent() const;
341 
344  public: void FillMsg(msgs::Joint &_msg);
345 
349  protected: virtual math::Angle GetAngleImpl(int _index) const = 0;
350 
353  private: void LoadImpl(const math::Pose &_pose);
354 
358  private: void LoadImpl(const math::Vector3 &_pos) GAZEBO_DEPRECATED;
359 
361  protected: LinkPtr childLink;
362 
364  protected: LinkPtr parentLink;
365 
367  protected: ModelPtr model;
368 
371 
373  protected: LinkPtr anchorLink;
374 
376  private: event::EventT<void ()> jointUpdate;
377 
379  protected: double dampingCoefficient;
380 
382  private: math::Angle staticAngle;
383 
386 
391  protected: double forceApplied[2];
392  };
394  }
395 }
396 #endif