ScrewJoint.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 _SCREWJOINT_HH_
18 #define _SCREWJOINT_HH_
19 
20 #include "gazebo/physics/Joint.hh"
21 #include "gazebo/common/Console.hh"
22 #include "gazebo/msgs/msgs.hh"
23 #include "gazebo/util/system.hh"
24 
25 namespace gazebo
26 {
27  namespace physics
28  {
31 
34  template<class T>
35  class GZ_PHYSICS_VISIBLE ScrewJoint : public T
36  {
39  public: explicit ScrewJoint(BasePtr _parent) : T(_parent), threadPitch(0)
40  {this->AddType(Base::SCREW_JOINT);}
41 
43  public: virtual ~ScrewJoint()
44  { }
45 
46  // Documentation inherited.
47  public: virtual unsigned int GetAngleCount() const
48  {return 2;}
49 
52  public: virtual void Load(sdf::ElementPtr _sdf)
53  {
54  T::Load(_sdf);
55 
56  this->threadPitch =
57  _sdf->GetElement("thread_pitch")->Get<double>();
58  }
59 
69  public: virtual void SetThreadPitch(double _threadPitch) = 0;
70 
76  public: virtual double GetThreadPitch() = 0;
77 
78  // Documentation inherited
79  public: virtual void FillMsg(msgs::Joint &_msg)
80  {
81  Joint::FillMsg(_msg);
82  msgs::Joint::Screw *screwMsg = _msg.mutable_screw();
83  screwMsg->set_thread_pitch(this->threadPitch);
84  }
85 
87  protected: double threadPitch;
88 
90  protected: virtual void Init()
91  {
92  T::Init();
93  }
94  };
96  }
97 }
98 #endif
ScrewJoint(BasePtr _parent)
Constructor.
Definition: ScrewJoint.hh:39
ScrewJoint type.
Definition: Base.hh:114
Forward declarations for the common classes.
Definition: Animation.hh:33
virtual void Init()
Initialize joint.
Definition: ScrewJoint.hh:90
virtual ~ScrewJoint()
Destructor.
Definition: ScrewJoint.hh:43
virtual void Load(sdf::ElementPtr _sdf)
Load a ScrewJoint.
Definition: ScrewJoint.hh:52
A screw joint, which has both prismatic and rotational DOFs.
Definition: ScrewJoint.hh:35
virtual void FillMsg(msgs::Joint &_msg)
Definition: ScrewJoint.hh:79
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
double threadPitch
Pitch of the thread.
Definition: ScrewJoint.hh:87
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:72
virtual void FillMsg(msgs::Joint &_msg)
Fill a joint message.
virtual unsigned int GetAngleCount() const
Definition: ScrewJoint.hh:47