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 <ignition/math/Inertial.hh>
30 #include <sdf/sdf.hh>
31 #include <ignition/math/Vector3.hh>
32 #include <ignition/math/Quaternion.hh>
33 #include <ignition/math/Matrix3.hh>
34 
35 #include "gazebo/math/Pose.hh"
36 #include "gazebo/msgs/msgs.hh"
38 #include "gazebo/math/Vector3.hh"
39 #include "gazebo/math/Matrix3.hh"
40 
41 #include "gazebo/util/system.hh"
42 
43 namespace gazebo
44 {
45  namespace physics
46  {
47  // Forward declare private data
48  class InertialPrivate;
49 
52 
55  class GZ_PHYSICS_VISIBLE Inertial
56  {
58  public: Inertial();
59 
62  public: explicit Inertial(const double _mass);
63 
66  public: Inertial(const ignition::math::Inertiald &_inertial);
67 
70  public: Inertial(const Inertial &_inertial);
71 
73  public: virtual ~Inertial();
74 
77  public: void Load(sdf::ElementPtr _sdf);
78 
81  public: void UpdateParameters(sdf::ElementPtr _sdf);
82 
84  public: void Reset();
85 
87  public: ignition::math::Inertiald Ign() const;
88 
91  public: void SetMass(const double _m);
92 
95  public: double GetMass() const GAZEBO_DEPRECATED(8.0);
96 
99  public: double Mass() const;
100 
108  public: void SetInertiaMatrix(
109  const double _ixx, const double _iyy, const double _izz,
110  const double _ixy, const double _ixz, const double iyz);
111 
116  public: void SetCoG(const double _cx, const double _cy, const double _cz);
117 
121  public: void SetCoG(const math::Vector3 &_center) GAZEBO_DEPRECATED(8.0);
122 
125  public: void SetCoG(const ignition::math::Vector3d &_center);
126 
135  public: void SetCoG(const double _cx, const double _cy, const double _cz,
136  const double _rx, const double _ry, const double _rz);
137 
141  public: void SetCoG(const math::Pose &_c) GAZEBO_DEPRECATED(8.0);
142 
145  public: void SetCoG(const ignition::math::Pose3d &_c);
146 
150  public: math::Vector3 GetCoG() const GAZEBO_DEPRECATED(8.0);
151 
154  public: const ignition::math::Vector3d &CoG() const;
155 
160  public: const math::Pose GetPose() const GAZEBO_DEPRECATED(8.0);
161 
165  public: ignition::math::Pose3d Pose() const;
166 
170  public: math::Vector3 GetPrincipalMoments() const GAZEBO_DEPRECATED(8.0);
171 
174  public: const ignition::math::Vector3d &PrincipalMoments() const;
175 
179  public: math::Vector3 GetProductsofInertia() const GAZEBO_DEPRECATED(8.0);
180 
183  public: const ignition::math::Vector3d &ProductsOfInertia() const;
184 
188  public: double GetIXX() const GAZEBO_DEPRECATED(8.0);
189 
192  public: double IXX() const;
193 
197  public: double GetIYY() const GAZEBO_DEPRECATED(8.0);
198 
201  public: double IYY() const;
202 
206  public: double GetIZZ() const GAZEBO_DEPRECATED(8.0);
207 
210  public: double IZZ() const;
211 
215  public: double GetIXY() const GAZEBO_DEPRECATED(8.0);
216 
219  public: double IXY() const;
220 
224  public: double GetIXZ() const GAZEBO_DEPRECATED(8.0);
225 
228  public: double IXZ() const;
229 
233  public: double GetIYZ() const GAZEBO_DEPRECATED(8.0);
234 
237  public: double IYZ() const;
238 
241  public: void SetIXX(const double _v);
242 
245  public: void SetIYY(const double _v);
246 
249  public: void SetIZZ(const double _v);
250 
253  public: void SetIXY(const double _v);
254 
257  public: void SetIXZ(const double _v);
258 
261  public: void SetIYZ(const double _v);
262 
266  public: void Rotate(const math::Quaternion &_rot) GAZEBO_DEPRECATED(8.0);
267 
270  public: void Rotate(const ignition::math::Quaterniond &_rot);
271 
275  public: Inertial &operator=(const Inertial &_inertial);
276 
280  public: Inertial &operator=(const ignition::math::Inertiald &_inertial);
281 
289  public: Inertial operator+(const Inertial &_inertial) const;
290 
294  public: const Inertial &operator+=(const Inertial &_inertial);
295 
298  public: void ProcessMsg(const msgs::Inertial &_msg);
299 
309  public: math::Matrix3 GetMOI(const math::Pose &_pose)
310  const GAZEBO_DEPRECATED(8.0);
311 
320  public: ignition::math::Matrix3d MOI(
321  const ignition::math::Pose3d &_pose) const;
322 
329  public: Inertial GetInertial(const math::Pose &_frameOffset) const
330  GAZEBO_DEPRECATED(8.0);
331 
338  public: Inertial operator()(
339  const ignition::math::Pose3d &_frameOffset) const;
340 
347  public: Inertial operator()(
348  const ignition::math::Vector3d &_frameOffset) const;
349 
353  public: friend std::ostream &operator<<(std::ostream &_out,
354  const gazebo::physics::Inertial &_inertial)
355  {
356  _out << "Mass[" << _inertial.Mass() << "] CoG["
357  << _inertial.CoG() << "]\n";
358  _out << "IXX[" << _inertial.PrincipalMoments().X() << "] "
359  << "IYY[" << _inertial.PrincipalMoments().Y() << "] "
360  << "IZZ[" << _inertial.PrincipalMoments().Z() << "]\n";
361  _out << "IXY[" << _inertial.ProductsOfInertia().X() << "] "
362  << "IXZ[" << _inertial.ProductsOfInertia().Y() << "] "
363  << "IYZ[" << _inertial.ProductsOfInertia().Z() << "]\n";
364  return _out;
365  }
366 
370  public: math::Matrix3 GetMOI() const GAZEBO_DEPRECATED(8.0);
371 
374  public: ignition::math::Matrix3d MOI() const;
375 
379  public: void SetMOI(const math::Matrix3 &_moi) GAZEBO_DEPRECATED(8.0);
380 
383  public: void SetMOI(const ignition::math::Matrix3d &_moi);
384 
387  private: std::unique_ptr<InertialPrivate> dataPtr;
388  };
390  }
391 }
392 #endif
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:55
friend std::ostream & operator<<(std::ostream &_out, const gazebo::physics::Inertial &_inertial)
Output operator.
Definition: Inertial.hh:353
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).