All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Inertial.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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 _INERTIAL_HH_
18 #define _INERTIAL_HH_
19 
20 #include <string>
21 
22 #include "gazebo/msgs/msgs.hh"
23 #include "gazebo/sdf/sdf.hh"
25 #include "gazebo/math/Vector3.hh"
26 
27 namespace gazebo
28 {
29  namespace physics
30  {
33 
36  class Inertial
37  {
39  public: Inertial();
40 
43  public: explicit Inertial(double _mass);
44 
47  public: Inertial(const Inertial &_inertial);
48 
50  public: virtual ~Inertial();
51 
54  public: void Load(sdf::ElementPtr _sdf);
55 
58  public: void UpdateParameters(sdf::ElementPtr _sdf);
59 
61  public: void Reset();
62 
64  public: void SetMass(double m);
65 
67  public: double GetMass() const;
68 
76  public: void SetInertiaMatrix(double _ixx, double _iyy, double _izz,
77  double _ixy, double _ixz, double iyz);
78 
83  public: void SetCoG(double _cx, double _cy, double _cz);
84 
87  public: void SetCoG(const math::Vector3 &_center);
88 
91  public: inline const math::Vector3 &GetCoG() const
92  {return this->cog;}
93 
97  public: inline const math::Pose GetPose() const
98  { return math::Pose(this->cog, math::Quaternion());}
99 
102  public: math::Vector3 GetPrincipalMoments() const;
103 
106  public: math::Vector3 GetProductsofInertia() const;
107 
110  public: double GetIXX() const;
111 
114  public: double GetIYY() const;
115 
118  public: double GetIZZ() const;
119 
122  public: double GetIXY() const;
123 
126  public: double GetIXZ() const;
127 
130  public: double GetIYZ() const;
131 
134  public: void SetIXX(double _v);
135 
138  public: void SetIYY(double _v);
139 
142  public: void SetIZZ(double _v);
143 
146  public: void SetIXY(double _v);
147 
150  public: void SetIXZ(double _v);
151 
154  public: void SetIYZ(double _v);
155 
158  public: void Rotate(const math::Quaternion &_rot);
159 
163  public: Inertial &operator=(const Inertial &_inertial);
164 
168  public: Inertial operator+(const Inertial &_inertial) const;
169 
173  public: const Inertial &operator+=(const Inertial &_inertial);
174 
177  public: void ProcessMsg(const msgs::Inertial &_msg);
178 
182  public: friend std::ostream &operator<<(std::ostream &_out,
183  const gazebo::physics::Inertial &_inertial)
184  {
185  _out << "Mass[" << _inertial.mass << "] CoG["
186  << _inertial.cog << "]\n";
187  _out << "IXX[" << _inertial.principals.x << "] "
188  << "IYY[" << _inertial.principals.y << "] "
189  << "IZZ[" << _inertial.principals.z << "]\n";
190  _out << "IXY[" << _inertial.products.x << "] "
191  << "IXZ[" << _inertial.products.y << "] "
192  << "IYZ[" << _inertial.products.z << "]\n";
193  return _out;
194  }
195 
197  private: double mass;
198 
200  private: math::Vector3 cog;
201 
203  private: math::Vector3 principals;
204 
206  private: math::Vector3 products;
207 
209  private: sdf::ElementPtr sdf;
210 
213  private: static sdf::ElementPtr sdfInertial;
214  };
216  }
217 }
218 #endif