SliderJoint.hh
00001 /*
00002  * Copyright 2011 Nate Koenig & Andrew Howard
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  *
00016 */
00017 /* Desc: A slider or primastic joint
00018  * Author: Nate Keonig, Andrew Howard
00019  * Date: 21 May 2003
00020  */
00021 
00022 #ifndef SLIDERJOINT_HH
00023 #define SLIDERJOINT_HH
00024 
00025 #include <float.h>
00026 #include "physics/Joint.hh"
00027 
00028 namespace gazebo
00029 {
00030     namespace physics
00031   {
00034 
00036     template<class T>
00037     class SliderJoint : public T
00038     {
00040       public: SliderJoint( ) : T()
00041               { this->AddType(Base::SLIDER_JOINT); } 
00042   
00044       public: virtual ~SliderJoint()
00045               { }
00046   
00048       protected: virtual void Load( sdf::ElementPtr &_sdf )
00049                  {
00050                    T::Load(_sdf);
00051   
00052                    if (_sdf->HasElement("axis"))
00053                    {
00054                      sdf::ElementPtr axisElem = _sdf->GetElement("axis");
00055                      this->SetAxis(0, axisElem->GetValueVector3("xyz"));
00056                      if (axisElem->HasElement("limit"))
00057                      {
00058                        sdf::ElementPtr limitElem = _sdf->GetElement("axis")->GetElement("limit");
00059                        // Perform this three step ordering to ensure the parameters 
00060                        // are set properly. This is taken from the ODE wiki.
00061                        this->SetHighStop(0,limitElem->GetValueDouble("upper"));
00062                        this->SetLowStop( 0,limitElem->GetValueDouble("lower"));
00063                        this->SetHighStop(0,limitElem->GetValueDouble("upper"));
00064                      }
00065                    }
00066                  }
00067     
00069       public: virtual void SetAnchor( int /*_index*/, 
00070                                       const math::Vector3 &_anchor) 
00071               {this->fakeAnchor = _anchor;}
00072   
00074       public: virtual math::Vector3 GetAnchor(int /*_index*/) const 
00075               {return this->fakeAnchor;}
00076    
00077       protected: math::Vector3 fakeAnchor;
00078     };
00080     
00081   }
00082 }
00083 #endif