DART  6.10.1
Inertial.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_UTILS_MJCF_DETAIL_INERTIAL_HPP_
34 #define DART_UTILS_MJCF_DETAIL_INERTIAL_HPP_
35 
36 #include <tinyxml2.h>
37 
38 #include "dart/common/Optional.hpp"
39 #include "dart/math/MathTypes.hpp"
42 
43 namespace dart {
44 namespace utils {
45 namespace MjcfParser {
46 namespace detail {
47 
48 class Body;
49 
50 class Inertial final
51 {
52 public:
53  Inertial() = default;
54 
55  Errors read(tinyxml2::XMLElement* element);
56 
57  void setMass(double mass);
58  double getMass() const;
59 
60  void setDiagInertia(const Eigen::Vector3d& inertia);
61  const Eigen::Vector3d& getDiagInertia() const;
62 
63  void setOffDiagInertia(const Eigen::Vector3d& inertia);
64  const Eigen::Vector3d& getOffDiagInertia() const;
65 
66  void setRelativeTransform(const Eigen::Isometry3d& tf);
67  const Eigen::Isometry3d& getRelativeTransform() const;
68 
69  void setWorldTransform(const Eigen::Isometry3d& tf);
70  const Eigen::Isometry3d& getWorldTransform() const;
71 
72 private:
73  // Private members used by Body class
74  friend class Body;
75  Errors compile(const Compiler& compiler);
76 
77 private:
78  struct Data
79  {
81  Eigen::Vector3d mPos;
82 
84  Eigen::Quaterniond mQuat{Eigen::Quaterniond::Identity()};
85 
90 
93 
99 
102 
103  Eigen::Isometry3d mRelativeTransform{Eigen::Isometry3d::Identity()};
104  Eigen::Isometry3d mWorldTransform{Eigen::Isometry3d::Identity()};
105 
107  double mMass;
108 
112 
115  };
116 
118 
120  Eigen::Vector3d mPos;
121 
122  Eigen::Isometry3d mRelativeTransform{Eigen::Isometry3d::Identity()};
123  Eigen::Isometry3d mWorldTransform{Eigen::Isometry3d::Identity()};
124 
126  double mMass;
127 
128  Eigen::Vector3d mDiagonalInertia;
129  Eigen::Vector3d mOffDiagonalInertia;
130 };
131 
132 } // namespace detail
133 } // namespace MjcfParser
134 } // namespace utils
135 } // namespace dart
136 
137 #endif // #ifndef DART_UTILS_MJCF_DETAIL_INERTIAL_HPP_
Errors compile(const Compiler &compiler)
Definition: Inertial.cpp:148
void setMass(double mass)
Definition: Inertial.cpp:195
Eigen::Isometry3d mRelativeTransform
Definition: Inertial.hpp:122
Eigen::Vector3d mDiagonalInertia
Definition: Inertial.hpp:128
Eigen::Isometry3d mWorldTransform
Definition: Inertial.hpp:123
void setOffDiagInertia(const Eigen::Vector3d &inertia)
Definition: Inertial.cpp:219
void setWorldTransform(const Eigen::Isometry3d &tf)
Definition: Inertial.cpp:243
const Eigen::Isometry3d & getRelativeTransform() const
Definition: Inertial.cpp:237
const Eigen::Vector3d & getOffDiagInertia() const
Definition: Inertial.cpp:225
double getMass() const
Definition: Inertial.cpp:201
Eigen::Vector3d mOffDiagonalInertia
Definition: Inertial.hpp:129
const Eigen::Isometry3d & getWorldTransform() const
Definition: Inertial.cpp:249
Data mData
Definition: Inertial.hpp:117
void setDiagInertia(const Eigen::Vector3d &inertia)
Definition: Inertial.cpp:207
const Eigen::Vector3d & getDiagInertia() const
Definition: Inertial.cpp:213
Errors read(tinyxml2::XMLElement *element)
Definition: Inertial.cpp:44
double mMass
Mass of the body.
Definition: Inertial.hpp:126
void setRelativeTransform(const Eigen::Isometry3d &tf)
Definition: Inertial.cpp:231
Eigen::Vector3d mPos
Position of the inertial frame.
Definition: Inertial.hpp:120
boost::optional< T > optional
Definition: Optional.hpp:50
std::vector< Error > Errors
Definition: Error.hpp:85
Definition: BulletCollisionDetector.cpp:65
double mMass
Mass of the body.
Definition: Inertial.hpp:107
common::optional< Eigen::Vector3d > mDiagInertia
Diagonal inertia matrix, expressing the body inertia relative to the inertial frame.
Definition: Inertial.hpp:111
Eigen::Vector3d mPos
Position of the inertial frame.
Definition: Inertial.hpp:81
Eigen::Isometry3d mWorldTransform
Definition: Inertial.hpp:104
common::optional< Eigen::Vector4d > mAxisAngle
These are the quantities (x, y, z, a) mentioned above.
Definition: Inertial.hpp:89
Eigen::Isometry3d mRelativeTransform
Definition: Inertial.hpp:103
common::optional< Eigen::Vector3d > mEuler
Rotation angles around three coordinate axes.
Definition: Inertial.hpp:92
Eigen::Quaterniond mQuat
Quaternion.
Definition: Inertial.hpp:84
common::optional< Eigen::Vector3d > mZAxis
The Z axis of the frame.
Definition: Inertial.hpp:101
common::optional< Eigen::Vector6d > mFullInertia
Full inertia matrix M.
Definition: Inertial.hpp:114
common::optional< Eigen::Vector6d > mXYAxes
The first 3 numbers are the X axis of the frame.
Definition: Inertial.hpp:98