Inertial.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 #ifndef INERTIAL_HH
00018 #define INERTIAL_HH
00019 
00020 #include "msgs/msgs.h"
00021 #include "sdf/sdf.h"
00022 #include "math/Quaternion.hh"
00023 #include "math/Vector3.hh"
00024 
00025 namespace gazebo
00026 {
00027   namespace physics
00028   {
00031 
00033     class Inertial
00034     {
00036       public: Inertial();
00037   
00039       public: Inertial(double mass);
00040   
00042       public: Inertial(const Inertial &_inertial);
00043   
00045       public: virtual ~Inertial();
00046   
00047       public: void Load( sdf::ElementPtr _sdf);
00048 
00050       public: void UpdateParameters( sdf::ElementPtr &_sdf );
00051 
00052       public: double GetLinearDamping();
00053       public: double GetAngularDamping();
00054 
00055       public: void SetLinearDamping(double _damping);
00056       public: void SetAngularDamping(double _damping);
00057 
00059       public: void Reset();
00060 
00062       public: void SetMass(double m);
00063 
00065       public: double GetMass() const;
00066   
00068       public: void SetInertiaMatrix( double ixx, double iyy, double izz,
00069                                      double ixy, double ixz, double iyz);
00070   
00072       public: void SetCoG(double cx, double cy, double cz);
00073   
00075       public: void SetCoG(const math::Vector3 &c);
00076   
00078       public: inline const math::Vector3 &GetCoG() const
00079               { return this->cog; }
00080 
00081       public: inline const math::Pose GetPose() const
00082               { return math::Pose(this->cog, math::Quaternion());}
00083   
00085       public: math::Vector3 GetPrincipalMoments() const;
00086   
00088       public: math::Vector3 GetProductsofInertia() const;
00089 
00090       public: double GetIXX() const;
00091       public: double GetIYY() const;
00092       public: double GetIZZ() const;
00093       public: double GetIXY() const;
00094       public: double GetIXZ() const;
00095       public: double GetIYZ() const;
00096 
00097       public: void SetIXX(double _v);
00098       public: void SetIYY(double _v);
00099       public: void SetIZZ(double _v);
00100       public: void SetIXY(double _v);
00101       public: void SetIXZ(double _v);
00102       public: void SetIYZ(double _v);
00103  
00105       public: void Rotate(const math::Quaternion &rot);
00106   
00108       public: void operator=(const Inertial &_inertial);
00109   
00110       public: Inertial operator+(const Inertial &_inertial ) const;
00111       public: const Inertial &operator+=(const Inertial &_inertial );
00112 
00115       public: void ProcessMsg(const msgs::Inertial &_msg);
00116 
00117       public: friend std::ostream &operator<<(std::ostream &out, 
00118                                               const gazebo::physics::Inertial &_inertial)
00119               {
00120                 out << "Mass[" << _inertial.mass << "] CoG[" 
00121                     << _inertial.cog << "]";
00122                 return out;
00123               }
00124  
00126       private: double mass;
00127       private: math::Vector3 cog;
00128       private: math::Vector3 principals;
00129       private: math::Vector3 products;
00130       private: sdf::ElementPtr sdf;
00131     };
00133   }
00134 }
00135 
00136 #endif