Inertial.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 GAZEBO_PHYSICS_INERTIAL_HH_
18 #define GAZEBO_PHYSICS_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 #include <memory>
28 
29 #include <sdf/sdf.hh>
30 #include <ignition/math/Vector3.hh>
31 #include <ignition/math/Quaternion.hh>
32 #include <ignition/math/Matrix3.hh>
33 
34 #include "gazebo/math/Pose.hh"
35 #include "gazebo/msgs/msgs.hh"
37 #include "gazebo/math/Vector3.hh"
38 #include "gazebo/math/Matrix3.hh"
39 
40 #include "gazebo/util/system.hh"
41 
42 namespace gazebo
43 {
44  namespace physics
45  {
46  // Forward declare private data
47  class InertialPrivate;
48 
51 
54  class GZ_PHYSICS_VISIBLE Inertial
55  {
57  public: Inertial();
58 
61  public: explicit Inertial(const double _mass);
62 
65  public: Inertial(const Inertial &_inertial);
66 
68  public: virtual ~Inertial();
69 
72  public: void Load(sdf::ElementPtr _sdf);
73 
76  public: void UpdateParameters(sdf::ElementPtr _sdf);
77 
79  public: void Reset();
80 
83  public: void SetMass(const double _m);
84 
87  public: double GetMass() const GAZEBO_DEPRECATED(8.0);
88 
91  public: double Mass() const;
92 
100  public: void SetInertiaMatrix(
101  const double _ixx, const double _iyy, const double _izz,
102  const double _ixy, const double _ixz, const double iyz);
103 
108  public: void SetCoG(const double _cx, const double _cy, const double _cz);
109 
113  public: void SetCoG(const math::Vector3 &_center) GAZEBO_DEPRECATED(8.0);
114 
117  public: void SetCoG(const ignition::math::Vector3d &_center);
118 
127  public: void SetCoG(const double _cx, const double _cy, const double _cz,
128  const double _rx, const double _ry, const double _rz);
129 
133  public: void SetCoG(const math::Pose &_c) GAZEBO_DEPRECATED(8.0);
134 
137  public: void SetCoG(const ignition::math::Pose3d &_c);
138 
142  public: math::Vector3 GetCoG() const GAZEBO_DEPRECATED(8.0);
143 
146  public: const ignition::math::Vector3d &CoG() const;
147 
152  public: const math::Pose GetPose() const GAZEBO_DEPRECATED(8.0);
153 
157  public: ignition::math::Pose3d Pose() const;
158 
162  public: math::Vector3 GetPrincipalMoments() const GAZEBO_DEPRECATED(8.0);
163 
166  public: const ignition::math::Vector3d &PrincipalMoments() const;
167 
171  public: math::Vector3 GetProductsofInertia() const GAZEBO_DEPRECATED(8.0);
172 
175  public: const ignition::math::Vector3d &ProductsOfInertia() const;
176 
180  public: double GetIXX() const GAZEBO_DEPRECATED(8.0);
181 
184  public: double IXX() const;
185 
189  public: double GetIYY() const GAZEBO_DEPRECATED(8.0);
190 
193  public: double IYY() const;
194 
198  public: double GetIZZ() const GAZEBO_DEPRECATED(8.0);
199 
202  public: double IZZ() const;
203 
207  public: double GetIXY() const GAZEBO_DEPRECATED(8.0);
208 
211  public: double IXY() const;
212 
216  public: double GetIXZ() const GAZEBO_DEPRECATED(8.0);
217 
220  public: double IXZ() const;
221 
225  public: double GetIYZ() const GAZEBO_DEPRECATED(8.0);
226 
229  public: double IYZ() const;
230 
233  public: void SetIXX(const double _v);
234 
237  public: void SetIYY(const double _v);
238 
241  public: void SetIZZ(const double _v);
242 
245  public: void SetIXY(const double _v);
246 
249  public: void SetIXZ(const double _v);
250 
253  public: void SetIYZ(const double _v);
254 
258  public: void Rotate(const math::Quaternion &_rot) GAZEBO_DEPRECATED(8.0);
259 
262  public: void Rotate(const ignition::math::Quaterniond &_rot);
263 
267  public: Inertial &operator=(const Inertial &_inertial);
268 
276  public: Inertial operator+(const Inertial &_inertial) const;
277 
281  public: const Inertial &operator+=(const Inertial &_inertial);
282 
285  public: void ProcessMsg(const msgs::Inertial &_msg);
286 
296  public: math::Matrix3 GetMOI(const math::Pose &_pose)
297  const GAZEBO_DEPRECATED(8.0);
298 
307  public: ignition::math::Matrix3d MOI(
308  const ignition::math::Pose3d &_pose) const;
309 
316  public: Inertial GetInertial(const math::Pose &_frameOffset) const
317  GAZEBO_DEPRECATED(8.0);
318 
325  public: Inertial operator()(
326  const ignition::math::Pose3d &_frameOffset) const;
327 
334  public: Inertial operator()(
335  const ignition::math::Vector3d &_frameOffset) const;
336 
340  public: friend std::ostream &operator<<(std::ostream &_out,
341  const gazebo::physics::Inertial &_inertial)
342  {
343  _out << "Mass[" << _inertial.Mass() << "] CoG["
344  << _inertial.CoG() << "]\n";
345  _out << "IXX[" << _inertial.PrincipalMoments().X() << "] "
346  << "IYY[" << _inertial.PrincipalMoments().Y() << "] "
347  << "IZZ[" << _inertial.PrincipalMoments().Z() << "]\n";
348  _out << "IXY[" << _inertial.ProductsOfInertia().X() << "] "
349  << "IXZ[" << _inertial.ProductsOfInertia().Y() << "] "
350  << "IYZ[" << _inertial.ProductsOfInertia().Z() << "]\n";
351  return _out;
352  }
353 
357  public: math::Matrix3 GetMOI() const GAZEBO_DEPRECATED(8.0);
358 
361  public: ignition::math::Matrix3d MOI() const;
362 
366  public: void SetMOI(const math::Matrix3 &_moi) GAZEBO_DEPRECATED(8.0);
367 
370  public: void SetMOI(const ignition::math::Matrix3d &_moi);
371 
374  private: std::unique_ptr<InertialPrivate> dataPtr;
375  };
377  }
378 }
379 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
Encapsulates a position and rotation in three space.
Definition: Pose.hh:42
const ignition::math::Vector3d & CoG() const
Get the center of gravity.
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:44
const ignition::math::Vector3d & PrincipalMoments() const
Get the principal moments of inertia (Ixx, Iyy, Izz).
double Mass() const
Get the mass.
A 3x3 matrix class.
Definition: Matrix3.hh:40
A class for inertial information about a link.
Definition: Inertial.hh:54
friend std::ostream & operator<<(std::ostream &_out, const gazebo::physics::Inertial &_inertial)
Output operator.
Definition: Inertial.hh:340
A quaternion class.
Definition: Quaternion.hh:48
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
const ignition::math::Vector3d & ProductsOfInertia() const
Get the products of inertia (Ixy, Ixz, Iyz).