Inertial.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 #ifdef _WIN32
21  // Ensure that Winsock2.h is included before Windows.h, which can get
22  // pulled in by anybody (e.g., Boost).
23  #include <Winsock2.h>
24 #endif
25 
26 #include <string>
27 
28 #include <sdf/sdf.hh>
29 
30 #include "gazebo/math/Pose.hh"
31 #include "gazebo/msgs/msgs.hh"
33 #include "gazebo/math/Vector3.hh"
34 #include "gazebo/math/Matrix3.hh"
35 #include "gazebo/util/system.hh"
36 
37 namespace gazebo
38 {
39  namespace physics
40  {
43 
46  class GZ_PHYSICS_VISIBLE Inertial
47  {
49  public: Inertial();
50 
53  public: explicit Inertial(double _mass);
54 
57  public: Inertial(const Inertial &_inertial);
58 
60  public: virtual ~Inertial();
61 
64  public: void Load(sdf::ElementPtr _sdf);
65 
68  public: void UpdateParameters(sdf::ElementPtr _sdf);
69 
71  public: void Reset();
72 
74  public: void SetMass(double m);
75 
77  public: double GetMass() const;
78 
86  public: void SetInertiaMatrix(double _ixx, double _iyy, double _izz,
87  double _ixy, double _ixz, double iyz);
88 
93  public: void SetCoG(double _cx, double _cy, double _cz);
94 
97  public: void SetCoG(const math::Vector3 &_center);
98 
107  public: void SetCoG(double _cx, double _cy, double _cz,
108  double _rx, double _ry, double _rz);
109 
112  public: void SetCoG(const math::Pose &_c);
113 
116  public: inline const math::Vector3 &GetCoG() const
117  {
118  return this->cog.pos;
119  }
120 
124  public: inline const math::Pose GetPose() const
125  {
126  return math::Pose(this->cog);
127  }
128 
131  public: math::Vector3 GetPrincipalMoments() const;
132 
135  public: math::Vector3 GetProductsofInertia() const;
136 
139  public: double GetIXX() const;
140 
143  public: double GetIYY() const;
144 
147  public: double GetIZZ() const;
148 
151  public: double GetIXY() const;
152 
155  public: double GetIXZ() const;
156 
159  public: double GetIYZ() const;
160 
163  public: void SetIXX(double _v);
164 
167  public: void SetIYY(double _v);
168 
171  public: void SetIZZ(double _v);
172 
175  public: void SetIXY(double _v);
176 
179  public: void SetIXZ(double _v);
180 
183  public: void SetIYZ(double _v);
184 
187  public: void Rotate(const math::Quaternion &_rot);
188 
192  public: Inertial &operator=(const Inertial &_inertial);
193 
201  public: Inertial operator+(const Inertial &_inertial) const;
202 
206  public: const Inertial &operator+=(const Inertial &_inertial);
207 
210  public: void ProcessMsg(const msgs::Inertial &_msg);
211 
220  public: math::Matrix3 GetMOI(const math::Pose &_pose)
221  const;
222 
228  public: Inertial GetInertial(const math::Pose &_frameOffset) const;
229 
233  public: friend std::ostream &operator<<(std::ostream &_out,
234  const gazebo::physics::Inertial &_inertial)
235  {
236  _out << "Mass[" << _inertial.mass << "] CoG["
237  << _inertial.cog << "]\n";
238  _out << "IXX[" << _inertial.principals.x << "] "
239  << "IYY[" << _inertial.principals.y << "] "
240  << "IZZ[" << _inertial.principals.z << "]\n";
241  _out << "IXY[" << _inertial.products.x << "] "
242  << "IXZ[" << _inertial.products.y << "] "
243  << "IYZ[" << _inertial.products.z << "]\n";
244  return _out;
245  }
246 
249  public: math::Matrix3 GetMOI() const;
250 
253  public: void SetMOI(const math::Matrix3 &_moi);
254 
256  private: double mass;
257 
260  private: math::Pose cog;
261 
264  private: math::Vector3 principals;
265 
269  private: math::Vector3 products;
270 
272  private: sdf::ElementPtr sdf;
273 
276  private: static sdf::ElementPtr sdfInertial;
277  };
279  }
280 }
281 #endif
double x
X location.
Definition: Vector3.hh:311
double y
Y location.
Definition: Vector3.hh:314
Forward declarations for the common classes.
Definition: Animation.hh:33
const math::Pose GetPose() const
Get the pose about which the mass and inertia matrix is specified in the Link frame.
Definition: Inertial.hh:124
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
const math::Vector3 & GetCoG() const
Get the center of gravity.
Definition: Inertial.hh:116
double z
Z location.
Definition: Vector3.hh:317
A 3x3 matrix class.
Definition: Matrix3.hh:34
A class for inertial information about a link.
Definition: Inertial.hh:46
friend std::ostream & operator<<(std::ostream &_out, const gazebo::physics::Inertial &_inertial)
Output operator.
Definition: Inertial.hh:233
A quaternion class.
Definition: Quaternion.hh:42