HingeJoint.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 body that has a box shape
00018  * Author: Nate Keonig, Andrew Howard
00019  * Date: 21 May 2003
00020  */
00021 
00022 #ifndef HINGEJOINT_HH
00023 #define HINGEJOINT_HH
00024 
00025 #include "math/Angle.hh"
00026 #include "math/Vector3.hh"
00027 
00028 namespace gazebo
00029 {
00030     namespace physics
00031   {
00033     template<class T>
00034     class HingeJoint : public T
00035     {
00037       public: HingeJoint() : T()
00038               { this->AddType(Base::HINGE_JOINT); }
00039    
00041       public: virtual ~HingeJoint()
00042               { }
00043   
00045       protected: virtual void Load( sdf::ElementPtr &_sdf)
00046                  {
00047                    T::Load(_sdf);
00048 
00049                    if (_sdf->HasElement("axis"))
00050                    {
00051                      sdf::ElementPtr axisElem = _sdf->GetElement("axis");
00052                      this->SetAxis(0, axisElem->GetValueVector3("xyz"));
00053                      if (axisElem->HasElement("limit"))
00054                      {
00055                        sdf::ElementPtr limitElem = _sdf->GetElement("axis")->GetElement("limit");
00056 
00057                        // Perform this three step ordering to ensure the 
00058                        // parameters are set properly. 
00059                        // This is taken from the ODE wiki.
00060                        this->SetHighStop(0,limitElem->GetValueDouble("upper"));
00061                        this->SetLowStop( 0,limitElem->GetValueDouble("lower"));
00062                        this->SetHighStop(0,limitElem->GetValueDouble("upper"));
00063                      }
00064                    }
00065 
00066                  }
00067       };
00068   }
00069 }
00070 #endif
00071