Robotics Library  0.7.0
ArticulatedBodyInertia.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_MATH_ARTICULATEDBODYINERTIA_H
28 #define RL_MATH_ARTICULATEDBODYINERTIA_H
29 
30 #include <Eigen/Core>
31 
32 namespace rl
33 {
34  namespace math
35  {
36  namespace spatial
37  {
38  template<typename Scalar> class ForceVector;
39  template<typename Scalar> class MotionVector;
40  template<typename Scalar> class RigidBodyInertia;
41 
45  template<typename Scalar>
47  {
48  public:
49  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50 
51  typedef Scalar ScalarType;
52 
53  typedef ::Eigen::Matrix<Scalar, 6, 6> MatrixType;
54 
55  typedef ::Eigen::Matrix<Scalar, 3, 3> CenterOfGravityType;
56 
58 
59  typedef ::Eigen::Matrix<Scalar, 3, 3> InertiaType;
60 
62 
63  typedef ::Eigen::Matrix<Scalar, 3, 3> MassType;
64 
65  typedef const MassType ConstMassType;
66 
68  {
69  }
70 
71  template<typename OtherDerived>
72  ArticulatedBodyInertia(const ::Eigen::DenseBase<OtherDerived>& other) :
73  centerOfGravityData(other.template topRightCorner<3, 3>()),
74  inertiaData(other.template topLeftCorner<3, 3>()),
75  massData(other.template bottomRightCorner<3, 3>())
76  {
77  }
78 
80  {
81  }
82 
84  {
85  return centerOfGravityData;
86  }
87 
89  {
90  return centerOfGravityData;
91  }
92 
94  {
95  return inertiaData;
96  }
97 
99  {
100  return inertiaData;
101  }
102 
104  {
105  return massData;
106  }
107 
109  {
110  return massData;
111  }
112 
114  {
115  MatrixType res;
116  res.template topLeftCorner<3, 3>() = inertia();
117  res.template topRightCorner<3, 3>() = cog();
118  res.template bottomLeftCorner<3, 3>() = cog().transpose();
119  res.template bottomRightCorner<3, 3>() = mass();
120  return res;
121  }
122 
123  template<typename OtherDerived>
124  ArticulatedBodyInertia& operator=(const ::Eigen::MatrixBase<OtherDerived>& other)
125  {
126  cog() = other.template topRightCorner<3, 3>();
127  inertia() = other.template topLeftCorner<3, 3>();
128  mass() = other.template bottomRightCorner<3, 3>();
129  return *this;
130  }
131 
132  template<typename OtherScalar>
134 
136  {
138  res.cog() = cog() + other.cog();
139  res.inertia() = inertia() + other.inertia();
140  res.mass() = mass() + other.mass();
141  return res;
142  }
143 
145  {
147  res.cog() = cog() - other.cog();
148  res.inertia() = inertia() - other.inertia();
149  res.mass() = mass() - other.mass();
150  return res;
151  }
152 
153  template<typename OtherScalar>
154  ArticulatedBodyInertia operator*(const OtherScalar& other) const
155  {
157  res.cog() = cog() * other;
158  res.inertia() = inertia() * other;
159  res.mass() = mass() * other;
160  return res;
161  }
162 
163  template<typename OtherScalar>
165 
166  template<typename OtherScalar>
167  ArticulatedBodyInertia operator/(const OtherScalar& other) const
168  {
170  res.cog() = cog() / other;
171  res.inertia() = inertia() / other;
172  res.mass() = mass() / other;
173  return res;
174  }
175 
176  void setIdentity()
177  {
178  cog().setZero();
179  inertia().setIdentity();
180  mass().setIdentity();
181  }
182 
183  void setZero()
184  {
185  cog().setZero();
186  inertia().setZero();
187  mass().setZero();
188  }
189 
190  protected:
191 
192  private:
194 
196 
198  };
199  }
200  }
201 }
202 
203 #endif // RL_MATH_ARTICULATEDBODYINERTIA_H
rl::math::spatial::ArticulatedBodyInertia::matrix
MatrixType matrix() const
Definition: ArticulatedBodyInertia.h:113
rl::math::spatial::ArticulatedBodyInertia::mass
MassType & mass()
Definition: ArticulatedBodyInertia.h:103
rl::math::spatial::ArticulatedBodyInertia
Articulated-body inertia.
Definition: ArticulatedBodyInertia.h:47
rl::math::spatial::RigidBodyInertia
Rigid-body inertia.
Definition: RigidBodyInertia.h:47
rl::math::spatial::ArticulatedBodyInertia::operator*
ArticulatedBodyInertia operator*(const OtherScalar &other) const
Definition: ArticulatedBodyInertia.h:154
rl::math::spatial::ArticulatedBodyInertia::MatrixType
::Eigen::Matrix< Scalar, 6, 6 > MatrixType
Definition: ArticulatedBodyInertia.h:53
rl::math::spatial::ArticulatedBodyInertia::operator=
ArticulatedBodyInertia & operator=(const RigidBodyInertia< OtherScalar > &other)
rl::math::spatial::ArticulatedBodyInertia::inertia
InertiaType & inertia()
Definition: ArticulatedBodyInertia.h:93
rl::math::spatial::ArticulatedBodyInertia::massData
MassType massData
Definition: ArticulatedBodyInertia.h:197
rl::math::spatial::ArticulatedBodyInertia::centerOfGravityData
CenterOfGravityType centerOfGravityData
Definition: ArticulatedBodyInertia.h:193
rl::math::spatial::ArticulatedBodyInertia::cog
ConstCenterOfGravityType & cog() const
Definition: ArticulatedBodyInertia.h:88
rl::math::spatial::ArticulatedBodyInertia::inertiaData
InertiaType inertiaData
Definition: ArticulatedBodyInertia.h:195
rl::math::spatial::ArticulatedBodyInertia::operator/
ArticulatedBodyInertia operator/(const OtherScalar &other) const
Definition: ArticulatedBodyInertia.h:167
rl::math::spatial::ArticulatedBodyInertia::~ArticulatedBodyInertia
virtual ~ArticulatedBodyInertia()
Definition: ArticulatedBodyInertia.h:79
rl::math::spatial::ArticulatedBodyInertia::operator=
ArticulatedBodyInertia & operator=(const ::Eigen::MatrixBase< OtherDerived > &other)
Definition: ArticulatedBodyInertia.h:124
rl::math::spatial::ArticulatedBodyInertia::cog
CenterOfGravityType & cog()
Definition: ArticulatedBodyInertia.h:83
rl::math::spatial::ArticulatedBodyInertia::ArticulatedBodyInertia
ArticulatedBodyInertia(const ::Eigen::DenseBase< OtherDerived > &other)
Definition: ArticulatedBodyInertia.h:72
rl::math::spatial::ArticulatedBodyInertia::CenterOfGravityType
::Eigen::Matrix< Scalar, 3, 3 > CenterOfGravityType
Definition: ArticulatedBodyInertia.h:55
rl::math::spatial::ArticulatedBodyInertia::ConstCenterOfGravityType
const CenterOfGravityType ConstCenterOfGravityType
Definition: ArticulatedBodyInertia.h:57
rl::math::spatial::ArticulatedBodyInertia::operator+
ArticulatedBodyInertia operator+(const ArticulatedBodyInertia &other) const
Definition: ArticulatedBodyInertia.h:135
rl::math::spatial::ArticulatedBodyInertia::operator-
ArticulatedBodyInertia operator-(const ArticulatedBodyInertia &other) const
Definition: ArticulatedBodyInertia.h:144
rl::math::spatial::ArticulatedBodyInertia::mass
ConstMassType & mass() const
Definition: ArticulatedBodyInertia.h:108
rl::math::spatial::ArticulatedBodyInertia::ScalarType
Scalar ScalarType
Definition: ArticulatedBodyInertia.h:51
rl::math::spatial::ArticulatedBodyInertia::ConstMassType
const MassType ConstMassType
Definition: ArticulatedBodyInertia.h:65
rl::math::spatial::ArticulatedBodyInertia::inertia
ConstInertiaType & inertia() const
Definition: ArticulatedBodyInertia.h:98
rl::math::spatial::ArticulatedBodyInertia::MassType
::Eigen::Matrix< Scalar, 3, 3 > MassType
Definition: ArticulatedBodyInertia.h:63
rl::math::spatial::ArticulatedBodyInertia::setZero
void setZero()
Definition: ArticulatedBodyInertia.h:183
rl::math::spatial::ArticulatedBodyInertia::ConstInertiaType
const InertiaType ConstInertiaType
Definition: ArticulatedBodyInertia.h:61
rl::math::spatial::ArticulatedBodyInertia::ArticulatedBodyInertia
ArticulatedBodyInertia()
Definition: ArticulatedBodyInertia.h:67
rl::math::spatial::ForceVector
Force vector.
Definition: ForceVector.h:46
rl::math::spatial::ArticulatedBodyInertia::setIdentity
void setIdentity()
Definition: ArticulatedBodyInertia.h:176
rl::math::spatial::MotionVector
Motion vector.
Definition: MotionVector.h:45
rl::math::spatial::ArticulatedBodyInertia::InertiaType
::Eigen::Matrix< Scalar, 3, 3 > InertiaType
Definition: ArticulatedBodyInertia.h:59
rl
Robotics Library.
Definition: AnalogInput.cpp:30