Robotics Library  0.6.2
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 
42  template< typename Scalar >
44  {
45  public:
46  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
47 
48  typedef Scalar ScalarType;
49 
50  typedef ::Eigen::Matrix< Scalar, 6, 6 > MatrixType;
51 
52  typedef ::Eigen::Matrix< Scalar, 3, 3 > CenterOfGravityType;
53 
55 
56  typedef ::Eigen::Matrix< Scalar, 3, 3 > InertiaType;
57 
59 
60  typedef ::Eigen::Matrix< Scalar, 3, 3 > MassType;
61 
62  typedef const MassType ConstMassType;
63 
65  {
66  }
67 
68  template< typename OtherDerived >
69  ArticulatedBodyInertia(const ::Eigen::DenseBase< OtherDerived >& other) :
70  centerOfGravityData(other.template topRightCorner< 3, 3 >()),
71  inertiaData(other.template topLeftCorner< 3, 3 >()),
72  massData(other.template bottomRightCorner< 3, 3 >())
73  {
74  }
75 
77  {
78  }
79 
81  {
82  return centerOfGravityData;
83  }
84 
86  {
87  return centerOfGravityData;
88  }
89 
91  {
92  return inertiaData;
93  }
94 
96  {
97  return inertiaData;
98  }
99 
101  {
102  return massData;
103  }
104 
106  {
107  return massData;
108  }
109 
111  {
112  MatrixType res;
113  res.template topLeftCorner< 3, 3 >() = inertia();
114  res.template topRightCorner< 3, 3 >() = cog();
115  res.template bottomLeftCorner< 3, 3 >() = cog().transpose();
116  res.template bottomRightCorner< 3, 3 >() = mass();
117  return res;
118  }
119 
120  template< typename OtherDerived >
121  ArticulatedBodyInertia& operator=(const ::Eigen::MatrixBase< OtherDerived >& other)
122  {
123  cog() = other.template topRightCorner< 3, 3 >();
124  inertia() = other.template topLeftCorner< 3, 3 >();
125  mass() = other.template bottomRightCorner< 3, 3 >();
126  return *this;
127  }
128 
129  template< typename OtherScalar >
131 
133  {
135  res.cog() = cog() + other.cog();
136  res.inertia() = inertia() + other.inertia();
137  res.mass() = mass() + other.mass();
138  return res;
139  }
140 
142  {
144  res.cog() = cog() - other.cog();
145  res.inertia() = inertia() - other.inertia();
146  res.mass() = mass() - other.mass();
147  return res;
148  }
149 
150  template< typename OtherScalar >
151  ArticulatedBodyInertia operator*(const OtherScalar& other) const
152  {
154  res.cog() = cog() * other;
155  res.inertia() = inertia() * other;
156  res.mass() = mass() * other;
157  return res;
158  }
159 
160  template< typename OtherScalar >
162 
163  template< typename OtherScalar >
164  ArticulatedBodyInertia operator/(const OtherScalar& other) const
165  {
167  res.cog() = cog() / other;
168  res.inertia() = inertia() / other;
169  res.mass() = mass() / other;
170  return res;
171  }
172 
173  void setIdentity()
174  {
175  cog().setZero();
176  inertia().setIdentity();
177  mass().setIdentity();
178  }
179 
180  void setZero()
181  {
182  cog().setZero();
183  inertia().setZero();
184  mass().setZero();
185  }
186 
187  protected:
188 
189  private:
191 
193 
195  };
196  }
197  }
198 }
199 
200 #endif // _RL_MATH_ARTICULATEDBODYINERTIA_H_
rl::math::spatial::ArticulatedBodyInertia::matrix
MatrixType matrix() const
Definition: ArticulatedBodyInertia.h:110
rl::math::spatial::ArticulatedBodyInertia::MatrixType
::Eigen::Matrix< Scalar, 6, 6 > MatrixType
Definition: ArticulatedBodyInertia.h:50
rl::math::spatial::ArticulatedBodyInertia::mass
MassType & mass()
Definition: ArticulatedBodyInertia.h:100
rl::math::spatial::ArticulatedBodyInertia
Definition: ArticulatedBodyInertia.h:44
rl::math::spatial::RigidBodyInertia
Definition: RigidBodyInertia.h:44
rl::math::spatial::ArticulatedBodyInertia::operator*
ArticulatedBodyInertia operator*(const OtherScalar &other) const
Definition: ArticulatedBodyInertia.h:151
rl::math::spatial::ArticulatedBodyInertia::MassType
::Eigen::Matrix< Scalar, 3, 3 > MassType
Definition: ArticulatedBodyInertia.h:60
rl::math::spatial::ArticulatedBodyInertia::operator=
ArticulatedBodyInertia & operator=(const RigidBodyInertia< OtherScalar > &other)
rl::math::spatial::ArticulatedBodyInertia::inertia
InertiaType & inertia()
Definition: ArticulatedBodyInertia.h:90
rl::math::spatial::ArticulatedBodyInertia::massData
MassType massData
Definition: ArticulatedBodyInertia.h:194
rl::math::spatial::ArticulatedBodyInertia::centerOfGravityData
CenterOfGravityType centerOfGravityData
Definition: ArticulatedBodyInertia.h:190
rl::math::spatial::ArticulatedBodyInertia::cog
ConstCenterOfGravityType & cog() const
Definition: ArticulatedBodyInertia.h:85
rl::math::spatial::ArticulatedBodyInertia::inertiaData
InertiaType inertiaData
Definition: ArticulatedBodyInertia.h:192
rl::math::spatial::ArticulatedBodyInertia::operator/
ArticulatedBodyInertia operator/(const OtherScalar &other) const
Definition: ArticulatedBodyInertia.h:164
rl::math::spatial::ArticulatedBodyInertia::~ArticulatedBodyInertia
virtual ~ArticulatedBodyInertia()
Definition: ArticulatedBodyInertia.h:76
rl::math::spatial::ArticulatedBodyInertia::operator=
ArticulatedBodyInertia & operator=(const ::Eigen::MatrixBase< OtherDerived > &other)
Definition: ArticulatedBodyInertia.h:121
rl::math::spatial::ArticulatedBodyInertia::cog
CenterOfGravityType & cog()
Definition: ArticulatedBodyInertia.h:80
rl::math::spatial::ArticulatedBodyInertia::ArticulatedBodyInertia
ArticulatedBodyInertia(const ::Eigen::DenseBase< OtherDerived > &other)
Definition: ArticulatedBodyInertia.h:69
rl::math::spatial::ArticulatedBodyInertia::ConstCenterOfGravityType
const CenterOfGravityType ConstCenterOfGravityType
Definition: ArticulatedBodyInertia.h:54
rl::math::spatial::ArticulatedBodyInertia::operator+
ArticulatedBodyInertia operator+(const ArticulatedBodyInertia &other) const
Definition: ArticulatedBodyInertia.h:132
rl::math::spatial::ArticulatedBodyInertia::operator-
ArticulatedBodyInertia operator-(const ArticulatedBodyInertia &other) const
Definition: ArticulatedBodyInertia.h:141
rl::math::spatial::ArticulatedBodyInertia::mass
ConstMassType & mass() const
Definition: ArticulatedBodyInertia.h:105
rl::math::spatial::ArticulatedBodyInertia::ScalarType
Scalar ScalarType
Definition: ArticulatedBodyInertia.h:48
rl::math::spatial::ArticulatedBodyInertia::ConstMassType
const MassType ConstMassType
Definition: ArticulatedBodyInertia.h:62
rl::math::spatial::ArticulatedBodyInertia::inertia
ConstInertiaType & inertia() const
Definition: ArticulatedBodyInertia.h:95
rl::math::spatial::ArticulatedBodyInertia::InertiaType
::Eigen::Matrix< Scalar, 3, 3 > InertiaType
Definition: ArticulatedBodyInertia.h:56
rl::math::spatial::ArticulatedBodyInertia::setZero
void setZero()
Definition: ArticulatedBodyInertia.h:180
rl::math::spatial::ArticulatedBodyInertia::ConstInertiaType
const InertiaType ConstInertiaType
Definition: ArticulatedBodyInertia.h:58
rl::math::spatial::ArticulatedBodyInertia::ArticulatedBodyInertia
ArticulatedBodyInertia()
Definition: ArticulatedBodyInertia.h:64
rl::math::spatial::ForceVector
Definition: ForceVector.h:43
rl::math::spatial::ArticulatedBodyInertia::setIdentity
void setIdentity()
Definition: ArticulatedBodyInertia.h:173
rl::math::spatial::MotionVector
Definition: MotionVector.h:42
rl::math::spatial::ArticulatedBodyInertia::CenterOfGravityType
::Eigen::Matrix< Scalar, 3, 3 > CenterOfGravityType
Definition: ArticulatedBodyInertia.h:52
rl
Definition: Ati.cpp:35