Cheetah Software  1.0
SpatialInertia< T > Class Template Reference

#include <SpatialInertia.h>

+ Inheritance diagram for SpatialInertia< T >:
+ Collaboration diagram for SpatialInertia< T >:

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW SpatialInertia (T mass, const Vec3< T > &com, const Mat3< T > &inertia)
 
 SpatialInertia (const Mat6< T > &inertia)
 
 SpatialInertia ()
 
 SpatialInertia (const MassProperties< T > &a)
 
 SpatialInertia (const Mat4< T > &P)
 
MassProperties< T > asMassPropertyVector ()
 
const Mat6< T > & getMatrix () const
 
void setMatrix (const Mat6< T > &mat)
 
void addMatrix (const Mat6< T > &mat)
 
getMass ()
 
Vec3< T > getCOM ()
 
Mat3< T > getInertiaTensor ()
 
Mat4< T > getPseudoInertia ()
 
SpatialInertia flipAlongAxis (CoordinateAxis axis)
 

Private Attributes

Mat6< T > _inertia
 

Detailed Description

template<typename T>
class SpatialInertia< T >

Representation of Rigid Body Inertia as a 6x6 Spatial Inertia Tensor

Definition at line 25 of file SpatialInertia.h.

Constructor & Destructor Documentation

template<typename T>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW SpatialInertia< T >::SpatialInertia ( mass,
const Vec3< T > &  com,
const Mat3< T > &  inertia 
)
inline

Construct spatial inertia from mass, center of mass, and 3x3 rotational inertia

Definition at line 32 of file SpatialInertia.h.

32  {
33  Mat3<T> cSkew = vectorToSkewMat(com);
34  _inertia.template topLeftCorner<3, 3>() =
35  inertia + mass * cSkew * cSkew.transpose();
36  _inertia.template topRightCorner<3, 3>() = mass * cSkew;
37  _inertia.template bottomLeftCorner<3, 3>() = mass * cSkew.transpose();
38  _inertia.template bottomRightCorner<3, 3>() = mass * Mat3<T>::Identity();
39  }
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
Mat6< T > _inertia
Mat3< typename T::Scalar > vectorToSkewMat(const Eigen::MatrixBase< T > &v)
template<typename T>
SpatialInertia< T >::SpatialInertia ( const Mat6< T > &  inertia)
inlineexplicit

Construct spatial inertia from 6x6 matrix

Definition at line 44 of file SpatialInertia.h.

44 { _inertia = inertia; }
Mat6< T > _inertia
template<typename T>
SpatialInertia< T >::SpatialInertia ( )
inline

If no argument is given, zero.

Definition at line 49 of file SpatialInertia.h.

49 { _inertia = Mat6<T>::Zero(); }
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
Mat6< T > _inertia
template<typename T>
SpatialInertia< T >::SpatialInertia ( const MassProperties< T > &  a)
inlineexplicit

Construct spatial inertia from mass property vector

Definition at line 54 of file SpatialInertia.h.

54  {
55  _inertia(0, 0) = a(4);
56  _inertia(0, 1) = a(9);
57  _inertia(0, 2) = a(8);
58  _inertia(1, 0) = a(9);
59  _inertia(1, 1) = a(5);
60  _inertia(1, 2) = a(7);
61  _inertia(2, 0) = a(8);
62  _inertia(2, 1) = a(7);
63  _inertia(2, 2) = a(6);
64  Mat3<T> cSkew = vectorToSkewMat(Vec3<T>(a(1), a(2), a(3)));
65  _inertia.template topRightCorner<3, 3>() = cSkew;
66  _inertia.template bottomLeftCorner<3, 3>() = cSkew.transpose();
67  _inertia.template bottomRightCorner<3, 3>() = a(0) * Mat3<T>::Identity();
68  }
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
Mat6< T > _inertia
Mat3< typename T::Scalar > vectorToSkewMat(const Eigen::MatrixBase< T > &v)
template<typename T>
SpatialInertia< T >::SpatialInertia ( const Mat4< T > &  P)
inlineexplicit

Construct spatial inertia from pseudo-inertia. This is described in Linear Matrix Inequalities for Physically Consistent Inertial Parameter Identification: A Statistical Perspective on the Mass Distribution, by Wensing, Kim, Slotine

Parameters
P

Definition at line 77 of file SpatialInertia.h.

77  {
78  Mat6<T> I;
79  T m = P(3, 3);
80  Vec3<T> h = P.template topRightCorner<3, 1>();
81  Mat3<T> E = P.template topLeftCorner<3, 3>();
82  Mat3<T> Ibar = E.trace() * Mat3<T>::Identity() - E;
83  I.template topLeftCorner<3, 3>() = Ibar;
84  I.template topRightCorner<3, 3>() = vectorToSkewMat(h);
85  I.template bottomLeftCorner<3, 3>() = vectorToSkewMat(h).transpose();
86  I.template bottomRightCorner<3, 3>() = m * Mat3<T>::Identity();
87  _inertia = I;
88  }
typename Eigen::Matrix< T, 6, 6 > Mat6
Definition: cppTypes.h:70
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
Mat6< T > _inertia
Mat3< typename T::Scalar > vectorToSkewMat(const Eigen::MatrixBase< T > &v)

Member Function Documentation

template<typename T>
void SpatialInertia< T >::addMatrix ( const Mat6< T > &  mat)
inline

Definition at line 108 of file SpatialInertia.h.

108 { _inertia += mat; }
Mat6< T > _inertia
template<typename T>
MassProperties<T> SpatialInertia< T >::asMassPropertyVector ( )
inline

Convert spatial inertia to mass property vector

Definition at line 93 of file SpatialInertia.h.

93  {
95  Vec3<T> h = matToSkewVec(_inertia.template topRightCorner<3, 3>());
96  a << _inertia(5, 5), h(0), h(1), h(2), _inertia(0, 0), _inertia(1, 1),
97  _inertia(2, 2), _inertia(2, 1), _inertia(2, 0), _inertia(1, 0);
98  return a;
99  }
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
Mat6< T > _inertia
Vec3< typename T::Scalar > matToSkewVec(const Eigen::MatrixBase< T > &m)
typename Eigen::Matrix< T, 10, 1 > MassProperties
Definition: cppTypes.h:98

+ Here is the caller graph for this function:

template<typename T>
SpatialInertia SpatialInertia< T >::flipAlongAxis ( CoordinateAxis  axis)
inline

Flip inertia matrix around an axis. This isn't efficient, but it works!

Definition at line 158 of file SpatialInertia.h.

158  {
161  if (axis == CoordinateAxis::X)
162  X(0, 0) = -1;
163  else if (axis == CoordinateAxis::Y)
164  X(1, 1) = -1;
165  else if (axis == CoordinateAxis::Z)
166  X(2, 2) = -1;
167  P = X * P * X;
168  return SpatialInertia(P);
169  }
typename Eigen::Matrix< T, 4, 4 > Mat4
Definition: cppTypes.h:94
Mat4< T > getPseudoInertia()
template<typename T>
Vec3<T> SpatialInertia< T >::getCOM ( )
inline

Get center of mass location

Definition at line 118 of file SpatialInertia.h.

118  {
119  T m = getMass();
120  Mat3<T> mcSkew = _inertia.template topRightCorner<3, 3>();
121  Vec3<T> com = matToSkewVec(mcSkew) / m;
122  return com;
123  }
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
Mat6< T > _inertia
Vec3< typename T::Scalar > matToSkewVec(const Eigen::MatrixBase< T > &m)

+ Here is the caller graph for this function:

template<typename T>
Mat3<T> SpatialInertia< T >::getInertiaTensor ( )
inline

Get 3x3 rotational inertia

Definition at line 128 of file SpatialInertia.h.

128  {
129  T m = getMass();
130  Mat3<T> mcSkew = _inertia.template topRightCorner<3, 3>();
131  Mat3<T> I_rot = _inertia.template topLeftCorner<3, 3>() -
132  mcSkew * mcSkew.transpose() / m;
133  return I_rot;
134  }
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
Mat6< T > _inertia

+ Here is the caller graph for this function:

template<typename T>
T SpatialInertia< T >::getMass ( )
inline

Get mass

Definition at line 113 of file SpatialInertia.h.

113 { return _inertia(5, 5); }
Mat6< T > _inertia

+ Here is the caller graph for this function:

template<typename T>
const Mat6<T>& SpatialInertia< T >::getMatrix ( ) const
inline

Get 6x6 spatial inertia

Definition at line 104 of file SpatialInertia.h.

104 { return _inertia; }
Mat6< T > _inertia

+ Here is the caller graph for this function:

template<typename T>
Mat4<T> SpatialInertia< T >::getPseudoInertia ( )
inline

Convert to 4x4 pseudo-inertia matrix. This is described in Linear Matrix Inequalities for Physically Consistent Inertial Parameter Identification: A Statistical Perspective on the Mass Distribution, by Wensing, Kim, Slotine

Definition at line 142 of file SpatialInertia.h.

142  {
143  Vec3<T> h = matToSkewVec(_inertia.template topRightCorner<3, 3>());
144  Mat3<T> Ibar = _inertia.template topLeftCorner<3, 3>();
145  T m = _inertia(5, 5);
146  Mat4<T> P;
147  P.template topLeftCorner<3, 3>() =
148  0.5 * Ibar.trace() * Mat3<T>::Identity() - Ibar;
149  P.template topRightCorner<3, 1>() = h;
150  P.template bottomLeftCorner<1, 3>() = h.transpose();
151  P(3, 3) = m;
152  return P;
153  }
typename Eigen::Matrix< T, 3, 3 > Mat3
Definition: cppTypes.h:54
typename Eigen::Matrix< T, 4, 4 > Mat4
Definition: cppTypes.h:94
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
Mat6< T > _inertia
Vec3< typename T::Scalar > matToSkewVec(const Eigen::MatrixBase< T > &m)

+ Here is the caller graph for this function:

template<typename T>
void SpatialInertia< T >::setMatrix ( const Mat6< T > &  mat)
inline

Definition at line 106 of file SpatialInertia.h.

106 { _inertia = mat; }
Mat6< T > _inertia

Member Data Documentation

template<typename T>
Mat6<T> SpatialInertia< T >::_inertia
private

Definition at line 172 of file SpatialInertia.h.


The documentation for this class was generated from the following file: