All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScrewJoint.hh
Go to the documentation of this file.
1 /*
2  * Gazebo - Outdoor Multi-Robot Simulator
3  * Copyright (C) 2003
4  * Nate Koenig
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 /* Desc: A screw or primastic/rotational joint
22  * Author: Nate Koenig, Andrew Howard
23  * Date: 21 May 2003
24  */
25 
26 #ifndef SCREWJOINT_HH
27 #define SCREWJOINT_HH
28 
29 #include <float.h>
30 #include "physics/Joint.hh"
31 #include "gazebo/common/Console.hh"
32 
33 namespace gazebo
34 {
35  namespace physics
36  {
39 
41  template<class T>
42  class ScrewJoint : public T
43  {
45  public: ScrewJoint(BasePtr _parent) : T(_parent)
46  { this->AddType(Base::SCREW_JOINT); }
48  public: virtual ~ScrewJoint()
49  { }
51  protected: virtual void Load(sdf::ElementPtr _sdf)
52  {
53  T::Load(_sdf);
54 
55  if (_sdf->HasElement("thread_pitch"))
56  {
57  this->threadPitch =
58  _sdf->GetElement("thread_pitch")->GetValueDouble();
59  }
60  else
61  {
62  gzerr << "should not see this\n";
63  this->threadPitch = 1.0;
64  }
65 
66  if (_sdf->HasElement("axis"))
67  {
68  sdf::ElementPtr axisElem = _sdf->GetElement("axis");
69  this->SetAxis(0, axisElem->GetValueVector3("xyz"));
70  if (axisElem->HasElement("limit"))
71  {
72  sdf::ElementPtr limitElem =
73  _sdf->GetElement("axis")->GetElement("limit");
74 
75  // Perform this three step ordering to ensure the
76  // parameters are set properly. This is taken from
77  // the ODE wiki.
78  this->SetHighStop(0, limitElem->GetValueDouble("upper"));
79  this->SetLowStop(0, limitElem->GetValueDouble("lower"));
80  this->SetHighStop(0, limitElem->GetValueDouble("upper"));
81  }
82  }
83  }
84 
86  public: virtual void SetAnchor(int /*_index */,
87  const math::Vector3 &anchor)
88  {fakeAnchor = anchor;}
89 
91  public: virtual math::Vector3 GetAnchor(int /*_index*/) const
92  {return fakeAnchor;}
93 
99  public: virtual void SetThreadPitch(int _index, double _threadPitch) = 0;
100 
102  protected: double threadPitch;
103  };
105  }
106 }
107 #endif
108 
109