- 3.0.2 rigid body dynamics module.
rbd.h
Go to the documentation of this file.
1 /* CPYHDR { */
2 /*
3  * This file is part of the 'iit-rbd' library.
4  * Copyright © 2015 2016, Marco Frigerio (marco.frigerio@iit.it)
5  *
6  * See the LICENSE file for more information.
7  */
8 /* } CPYHDR */
9 #ifndef IIT_RBD_H_
10 #define IIT_RBD_H_
11 
12 #include <Eigen/Dense>
13 #include <Eigen/StdVector>
14 #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 1
15 #include <Eigen/Sparse>
16 
17 
18 namespace iit {
36 namespace rbd {
37 
47 // Use alias templates to limit the references to 'Eigen' to this header
49 
50 template<typename Derived>
51 using MatrixBase = Eigen::MatrixBase< Derived >;
52 
53 template<typename Scalar, int R, int C>
54 using PlainMatrix = Eigen::Matrix< Scalar, R, C >;
55 
56 template<typename XprType, int R, int C>
57 using MatrixBlock = Eigen::Block< XprType, R, C >;
58 
59 template<typename Scalar>
60 using SparseMatrix = Eigen::SparseMatrix<Scalar>;
61 
62 template<typename Scalar>
63 using SparseVector = Eigen::SparseVector<Scalar>;
65 
71 template<typename SCALAR>
72 struct Core
73 {
74  typedef SCALAR Scalar;
75 
83 
88  typedef Vector6 Vector6D; // here the 'D' stands for Dimension, not double !
90  typedef Vector6D Column6D;
91  typedef Vector6D VelocityVector;
92  typedef Vector6D ForceVector;
93 
96 
98 
104 
109  static inline Part3D angularPart(Vector6D& f) {
110  return f.template topRows<3>();
111  }
116  static inline Part3D linearPart(Vector6D& f) {
117  return f.template bottomRows<3>();
118  }
119  static inline Part3DConst angularPart(const Vector6D& f) {
120  return f.template topRows<3>();
121  }
122  static inline Part3DConst linearPart(const Vector6D& f) {
123  return f.template bottomRows<3>();
124  }
125 };
126 
127 
133 typedef Core<double> Cored;
135 
140 
144 
147 
148 using Column6d = Cored::Column6D; // an alias
149 
152 
153 
155  return Cored::angularPart(f);
156 }
158  return Cored::linearPart(f);
159 }
160 inline Part3DConst angularPart(const Vector6D& f) {
161  return Cored::angularPart(f);
162 }
163 inline Part3DConst linearPart(const Vector6D& f) {
164  return Cored::linearPart(f);
165 }
167 
172 enum Coords3D { X=0, Y, Z};
175 enum Coords6D { AX=0, AY, AZ, LX, LY, LZ };
177 
179 
185 static const double g = 9.81;
186 
187 }
188 }
189 
190 
191 #endif /* IIT_RBD_H_ */
SCALAR Scalar
Definition: rbd.h:74
static Part3DConst linearPart(const Vector6D &f)
Definition: rbd.h:122
Eigen::SparseVector< Scalar > SparseVector
Definition: rbd.h:63
Definition: rbd.h:173
PlainMatrix< Scalar, 6, 6 > Matrix66
Definition: rbd.h:79
Cored::Vector3 Vector3d
Definition: rbd.h:137
Definition: rbd.h:175
Definition: rbd.h:175
Coords6D
To be used with 6D vectors. &#39;A&#39; stands for angular, &#39;L&#39; for linear.
Definition: rbd.h:175
SparseVector< double > SparseColumnd
Definition: rbd.h:151
Cored::ForceVector ForceVector
Definition: rbd.h:143
Definition: rbd.h:175
Coords3D
To be used with 6D vectors. &#39;A&#39; stands for angular, &#39;L&#39; for linear.
Definition: rbd.h:173
PlainMatrix< Scalar, 3, 3 > Matrix33
Definition: rbd.h:78
CppAD::AD< CppAD::cg::CG< double > > SCALAR
Cored::Vector6 Vector6d
Definition: rbd.h:139
Definition: rbd.h:175
Eigen::Block< XprType, R, C > MatrixBlock
Definition: rbd.h:57
MatrixBlock< Vector6D, 3, 1 > Part3D
a 3D subvector of a 6D vector
Definition: rbd.h:94
Vector6D Column6D
a 3D subvector of a 6D vector
Definition: rbd.h:90
MatrixBlock< const Vector6D, 3, 1 > Part3DConst
a const 3D subvector of a 6D vector
Definition: rbd.h:95
Definition: rbd.h:72
SparseMatrix< double > SparseMatrixd
Definition: rbd.h:150
Vector6D ForceVector
a 3D subvector of a 6D vector
Definition: rbd.h:92
Cored::Column6D Column6d
Definition: rbd.h:148
Cored::VelocityVector VelocityVector
Definition: rbd.h:142
Cored::Matrix66 Matrix66d
Definition: rbd.h:138
static Part3D angularPart(Vector6D &f)
Definition: rbd.h:109
Eigen::MatrixBase< Derived > MatrixBase
Definition: rbd.h:51
Cored::Matrix33 Matrix33d
Definition: rbd.h:136
Core< double > Cored
Definition: rbd.h:134
Cored::Part3DConst Part3DConst
Definition: rbd.h:146
Vector6 Vector6D
a 3D subvector of a 6D vector
Definition: rbd.h:89
PlainMatrix< Scalar, 6, 1 > Vector6
Definition: rbd.h:81
Definition: rbd.h:173
static Part3D linearPart(Vector6D &f)
Definition: rbd.h:116
Eigen::Matrix< Scalar, R, C > PlainMatrix
Definition: rbd.h:54
Cored::Vector6D Vector6D
Definition: rbd.h:141
Cored::Part3D Part3D
Definition: rbd.h:145
Vector6D VelocityVector
a 3D subvector of a 6D vector
Definition: rbd.h:91
PlainMatrix< Scalar, 3, 1 > Vector3
Definition: rbd.h:80
Definition: rbd.h:173
Definition: rbd.h:175
Eigen::SparseMatrix< Scalar > SparseMatrix
Definition: rbd.h:60
Definition: rbd.h:175
static Part3DConst angularPart(const Vector6D &f)
Definition: rbd.h:119