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 #include "gazebo/math/Matrix3.hh"
27 
28 namespace gazebo
29 {
30  namespace physics
31  {
34 
37  class Inertial
38  {
40  public: Inertial();
41 
44  public: explicit Inertial(double _mass);
45 
48  public: Inertial(const Inertial &_inertial);
49 
51  public: virtual ~Inertial();
52 
55  public: void Load(sdf::ElementPtr _sdf);
56 
59  public: void UpdateParameters(sdf::ElementPtr _sdf);
60 
62  public: void Reset();
63 
65  public: void SetMass(double m);
66 
68  public: double GetMass() const;
69 
77  public: void SetInertiaMatrix(double _ixx, double _iyy, double _izz,
78  double _ixy, double _ixz, double iyz);
79 
84  public: void SetCoG(double _cx, double _cy, double _cz);
85 
88  public: void SetCoG(const math::Vector3 &_center);
89 
98  public: void SetCoG(double _cx, double _cy, double _cz,
99  double _rx, double _ry, double _rz);
100 
103  public: void SetCoG(const math::Pose &_c);
104 
107  public: inline const math::Vector3 &GetCoG() const
108  {
109  return this->cog.pos;
110  }
111 
115  public: inline const math::Pose GetPose() const
116  {
117  return math::Pose(this->cog);
118  }
119 
122  public: math::Vector3 GetPrincipalMoments() const;
123 
126  public: math::Vector3 GetProductsofInertia() const;
127 
130  public: double GetIXX() const;
131 
134  public: double GetIYY() const;
135 
138  public: double GetIZZ() const;
139 
142  public: double GetIXY() const;
143 
146  public: double GetIXZ() const;
147 
150  public: double GetIYZ() const;
151 
154  public: void SetIXX(double _v);
155 
158  public: void SetIYY(double _v);
159 
162  public: void SetIZZ(double _v);
163 
166  public: void SetIXY(double _v);
167 
170  public: void SetIXZ(double _v);
171 
174  public: void SetIYZ(double _v);
175 
178  public: void Rotate(const math::Quaternion &_rot);
179 
183  public: Inertial &operator=(const Inertial &_inertial);
184 
192  public: Inertial operator+(const Inertial &_inertial) const;
193 
197  public: const Inertial &operator+=(const Inertial &_inertial);
198 
201  public: void ProcessMsg(const msgs::Inertial &_msg);
202 
211  public: math::Matrix3 GetMOI(const math::Pose &_pose)
212  const;
213 
219  public: Inertial GetInertial(const math::Pose &_frameOffset) const;
220 
224  public: friend std::ostream &operator<<(std::ostream &_out,
225  const gazebo::physics::Inertial &_inertial)
226  {
227  _out << "Mass[" << _inertial.mass << "] CoG["
228  << _inertial.cog << "]\n";
229  _out << "IXX[" << _inertial.principals.x << "] "
230  << "IYY[" << _inertial.principals.y << "] "
231  << "IZZ[" << _inertial.principals.z << "]\n";
232  _out << "IXY[" << _inertial.products.x << "] "
233  << "IXZ[" << _inertial.products.y << "] "
234  << "IYZ[" << _inertial.products.z << "]\n";
235  return _out;
236  }
237 
240  public: math::Matrix3 GetMOI() const;
241 
244  public: void SetMOI(const math::Matrix3 &_moi);
245 
247  private: double mass;
248 
251  private: math::Pose cog;
252 
255  private: math::Vector3 principals;
256 
260  private: math::Vector3 products;
261 
263  private: sdf::ElementPtr sdf;
264 
267  private: static sdf::ElementPtr sdfInertial;
268  };
270  }
271 }
272 #endif