11 #ifndef __RDL_EIGENMATH_H__ 12 #define __RDL_EIGENMATH_H__ 14 #include <Eigen/Dense> 15 #include <Eigen/StdVector> 17 #include <eigen3/Eigen/Eigen> 57 typedef Eigen::Vector3d
Base;
59 template <
typename OtherDerived>
65 template <
typename OtherDerived>
68 this->Base::operator=(other);
72 EIGEN_STRONG_INLINE
Vector3d() : Vector3d(0., 0., 0.)
76 EIGEN_STRONG_INLINE
Vector3d(
const double& v0,
const double& v1,
const double& v2)
78 Base::_check_template_params();
80 (*this) << v0, v1, v2;
83 void set(
const Eigen::Vector3d& v)
85 Base::_check_template_params();
87 set(v[0], v[1], v[2]);
90 void set(
const double& v0,
const double& v1,
const double& v2)
92 Base::_check_template_params();
94 (*this) << v0, v1, v2;
107 template <
typename OtherDerived>
113 template <
typename OtherDerived>
116 this->Base::operator=(other);
124 EIGEN_STRONG_INLINE
Matrix3d(
const double& m00,
const double& m01,
const double& m02,
const double& m10,
const double& m11,
const double& m12,
const double& m20,
125 const double& m21,
const double& m22)
127 Base::_check_template_params();
129 (*this) << m00, m01, m02, m10, m11, m12, m20, m21, m22;
138 template <
typename OtherDerived>
144 template <
typename OtherDerived>
147 this->Base::operator=(other);
155 EIGEN_STRONG_INLINE
Vector4d(
const double& v0,
const double& v1,
const double& v2,
const double& v3)
157 Base::_check_template_params();
159 (*this) << v0, v1, v2, v3;
162 void set(
const double& v0,
const double& v1,
const double& v2,
const double& v3)
164 Base::_check_template_params();
166 (*this) << v0, v1, v2, v3;
173 typedef Eigen::Matrix<double, 6, 1>
Base;
175 template <
typename OtherDerived>
177 SpatialVector(
const Eigen::MatrixBase<OtherDerived>& other) : Eigen::Matrix<double, 6, 1>(other)
181 template <
typename OtherDerived>
184 this->Base::operator=(other);
190 (*this) << 0., 0., 0., 0., 0., 0.;
193 EIGEN_STRONG_INLINE
SpatialVector(
const double& v0,
const double& v1,
const double& v2,
const double& v3,
const double& v4,
const double& v5)
195 Base::_check_template_params();
197 (*this) << v0, v1, v2, v3, v4, v5;
200 EIGEN_STRONG_INLINE
void set(
const double& v0,
const double& v1,
const double& v2,
const double& v3,
const double& v4,
const double& v5)
202 Base::_check_template_params();
204 (*this) << v0, v1, v2, v3, v4, v5;
209 return Vector3d(this->data()[0], this->data()[1], this->data()[2]);
214 return Vector3d(this->data()[3], this->data()[4], this->data()[5]);
219 this->data()[0] = v(0);
220 this->data()[1] = v(1);
221 this->data()[2] = v(2);
226 this->data()[3] = v(0);
227 this->data()[4] = v(1);
228 this->data()[5] = v(2);
233 Base::_check_template_params();
235 (*this) << angularPart[0], angularPart[1], angularPart[2], linearPart[0], linearPart[1], linearPart[2];
239 class Matrix4d :
public Eigen::Matrix<double, 4, 4>
242 typedef Eigen::Matrix<double, 4, 4>
Base;
244 template <
typename OtherDerived>
246 Matrix4d(
const Eigen::MatrixBase<OtherDerived>& other) : Eigen::Matrix<double, 4, 4>(other)
250 template <
typename OtherDerived>
253 this->Base::operator=(other);
261 EIGEN_STRONG_INLINE
Matrix4d(
const Scalar& m00,
const Scalar& m01,
const Scalar& m02,
const Scalar& m03,
const Scalar& m10,
const Scalar& m11,
const Scalar& m12,
262 const Scalar& m13,
const Scalar& m20,
const Scalar& m21,
const Scalar& m22,
const Scalar& m23,
const Scalar& m30,
const Scalar& m31,
263 const Scalar& m32,
const Scalar& m33)
265 Base::_check_template_params();
267 (*this) << m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33;
270 void set(
const Scalar& m00,
const Scalar& m01,
const Scalar& m02,
const Scalar& m03,
const Scalar& m10,
const Scalar& m11,
const Scalar& m12,
const Scalar& m13,
271 const Scalar& m20,
const Scalar& m21,
const Scalar& m22,
const Scalar& m23,
const Scalar& m30,
const Scalar& m31,
const Scalar& m32,
const Scalar& m33)
273 Base::_check_template_params();
275 (*this) << m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33;
282 typedef Eigen::Matrix<double, 6, 6>
Base;
284 template <
typename OtherDerived>
286 SpatialMatrix(
const Eigen::MatrixBase<OtherDerived>& other) : Eigen::Matrix<double, 6, 6>(other)
290 template <
typename OtherDerived>
293 this->Base::operator=(other);
299 Base::_check_template_params();
301 (*this) << 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.;
304 EIGEN_STRONG_INLINE
SpatialMatrix(
const Scalar& m00,
const Scalar& m01,
const Scalar& m02,
const Scalar& m03,
const Scalar& m04,
const Scalar& m05,
const Scalar& m10,
305 const Scalar& m11,
const Scalar& m12,
const Scalar& m13,
const Scalar& m14,
const Scalar& m15,
const Scalar& m20,
const Scalar& m21,
306 const Scalar& m22,
const Scalar& m23,
const Scalar& m24,
const Scalar& m25,
const Scalar& m30,
const Scalar& m31,
const Scalar& m32,
307 const Scalar& m33,
const Scalar& m34,
const Scalar& m35,
const Scalar& m40,
const Scalar& m41,
const Scalar& m42,
const Scalar& m43,
308 const Scalar& m44,
const Scalar& m45,
const Scalar& m50,
const Scalar& m51,
const Scalar& m52,
const Scalar& m53,
const Scalar& m54,
311 Base::_check_template_params();
313 (*this) << m00, m01, m02, m03, m04, m05, m10, m11, m12, m13, m14, m15, m20, m21, m22, m23, m24, m25, m30, m31, m32, m33, m34, m35, m40, m41, m42, m43, m44, m45,
314 m50, m51, m52, m53, m54, m55;
317 void set(
const Scalar& m00,
const Scalar& m01,
const Scalar& m02,
const Scalar& m03,
const Scalar& m04,
const Scalar& m05,
const Scalar& m10,
const Scalar& m11,
318 const Scalar& m12,
const Scalar& m13,
const Scalar& m14,
const Scalar& m15,
const Scalar& m20,
const Scalar& m21,
const Scalar& m22,
const Scalar& m23,
319 const Scalar& m24,
const Scalar& m25,
const Scalar& m30,
const Scalar& m31,
const Scalar& m32,
const Scalar& m33,
const Scalar& m34,
const Scalar& m35,
320 const Scalar& m40,
const Scalar& m41,
const Scalar& m42,
const Scalar& m43,
const Scalar& m44,
const Scalar& m45,
const Scalar& m50,
const Scalar& m51,
321 const Scalar& m52,
const Scalar& m53,
const Scalar& m54,
const Scalar& m55)
323 Base::_check_template_params();
325 (*this) << m00, m01, m02, m03, m04, m05, m10, m11, m12, m13, m14, m15, m20, m21, m22, m23, m24, m25, m30, m31, m32, m33, m34, m35, m40, m41, m42, m43, m44, m45,
326 m50, m51, m52, m53, m54, m55;
392 Vector3d v_rxw(v_sp[3] - r[1] * v_sp[2] + r[2] * v_sp[1], v_sp[4] - r[2] * v_sp[0] + r[0] * v_sp[2], v_sp[5] - r[0] * v_sp[1] + r[1] * v_sp[0]);
394 return SpatialVector(E(0, 0) * v_sp[0] + E(0, 1) * v_sp[1] + E(0, 2) * v_sp[2], E(1, 0) * v_sp[0] + E(1, 1) * v_sp[1] + E(1, 2) * v_sp[2],
395 E(2, 0) * v_sp[0] + E(2, 1) * v_sp[1] + E(2, 2) * v_sp[2], E(0, 0) * v_rxw[0] + E(0, 1) * v_rxw[1] + E(0, 2) * v_rxw[2],
396 E(1, 0) * v_rxw[0] + E(1, 1) * v_rxw[1] + E(1, 2) * v_rxw[2], E(2, 0) * v_rxw[0] + E(2, 1) * v_rxw[1] + E(2, 2) * v_rxw[2]);
407 Vector3d E_T_f(E(0, 0) * f_sp[3] + E(1, 0) * f_sp[4] + E(2, 0) * f_sp[5], E(0, 1) * f_sp[3] + E(1, 1) * f_sp[4] + E(2, 1) * f_sp[5],
408 E(0, 2) * f_sp[3] + E(1, 2) * f_sp[4] + E(2, 2) * f_sp[5]);
410 return SpatialVector(E(0, 0) * f_sp[0] + E(1, 0) * f_sp[1] + E(2, 0) * f_sp[2] - r[2] * E_T_f[1] + r[1] * E_T_f[2],
411 E(0, 1) * f_sp[0] + E(1, 1) * f_sp[1] + E(2, 1) * f_sp[2] + r[2] * E_T_f[0] - r[0] * E_T_f[2],
412 E(0, 2) * f_sp[0] + E(1, 2) * f_sp[1] + E(2, 2) * f_sp[2] - r[1] * E_T_f[0] + r[0] * E_T_f[1], E_T_f[0], E_T_f[1], E_T_f[2]);
425 return SpatialVector(En_rxf[0], En_rxf[1], En_rxf[2], E(0, 0) * f_sp[3] + E(0, 1) * f_sp[4] + E(0, 2) * f_sp[5],
426 E(1, 0) * f_sp[3] + E(1, 1) * f_sp[4] + E(1, 2) * f_sp[5], E(2, 0) * f_sp[3] + E(2, 1) * f_sp[4] + E(2, 2) * f_sp[5]);
436 Matrix3d _Erx = E *
Matrix3d(0., -r[2], r[1], r[2], 0., -r[0], -r[1], r[0], 0.);
439 result.block<3, 3>(0, 0) = E;
440 result.block<3, 3>(0, 3) = Matrix3d::Zero(3, 3);
441 result.block<3, 3>(3, 0) = -_Erx;
442 result.block<3, 3>(3, 3) = E;
454 Matrix3d _Erx = E *
Matrix3d(0., -r[2], r[1], r[2], 0., -r[0], -r[1], r[0], 0.);
457 result.block<3, 3>(0, 0) = E;
458 result.block<3, 3>(0, 3) = -_Erx;
459 result.block<3, 3>(3, 0) = Matrix3d::Zero(3, 3);
460 result.block<3, 3>(3, 3) = E;
472 Matrix3d _Erx = E *
Matrix3d(0., -r[2], r[1], r[2], 0., -r[0], -r[1], r[0], 0.);
475 result.block<3, 3>(0, 0) = E.transpose();
476 result.block<3, 3>(0, 3) = -_Erx.transpose();
477 result.block<3, 3>(3, 0) = Matrix3d::Zero(3, 3);
478 result.block<3, 3>(3, 3) = E.transpose();
499 E.transposeInPlace();
514 r = XT.
r + XT.
E.transpose() * r;
524 return X.
E * (*this);
529 *
this = X.
E * (*this);
540 #endif // ifndef __RDL_EIGENMATH_H__
EIGEN_STRONG_INLINE Vector3d(const double &v0, const double &v1, const double &v2)
Eigen::Matrix< double, 6, 6 > Base
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(RobotDynamics::Joint)
void setAngularPart(const Vector3d &v)
Vector4d & operator=(const Eigen::MatrixBase< OtherDerived > &other)
void setLinearPart(const Vector3d &v)
EIGEN_STRONG_INLINE SpatialMatrix(const Scalar &m00, const Scalar &m01, const Scalar &m02, const Scalar &m03, const Scalar &m04, const Scalar &m05, const Scalar &m10, const Scalar &m11, const Scalar &m12, const Scalar &m13, const Scalar &m14, const Scalar &m15, const Scalar &m20, const Scalar &m21, const Scalar &m22, const Scalar &m23, const Scalar &m24, const Scalar &m25, const Scalar &m30, const Scalar &m31, const Scalar &m32, const Scalar &m33, const Scalar &m34, const Scalar &m35, const Scalar &m40, const Scalar &m41, const Scalar &m42, const Scalar &m43, const Scalar &m44, const Scalar &m45, const Scalar &m50, const Scalar &m51, const Scalar &m52, const Scalar &m53, const Scalar &m54, const Scalar &m55)
EIGEN_STRONG_INLINE SpatialMatrix()
EIGEN_STRONG_INLINE Matrix3d(const double &m00, const double &m01, const double &m02, const double &m10, const double &m11, const double &m12, const double &m20, const double &m21, const double &m22)
Vector3d transform_copy(const RobotDynamics::Math::SpatialTransform &X) const
EIGEN_STRONG_INLINE Matrix4d(const Scalar &m00, const Scalar &m01, const Scalar &m02, const Scalar &m03, const Scalar &m10, const Scalar &m11, const Scalar &m12, const Scalar &m13, const Scalar &m20, const Scalar &m21, const Scalar &m22, const Scalar &m23, const Scalar &m30, const Scalar &m31, const Scalar &m32, const Scalar &m33)
Matrix4d(const Eigen::MatrixBase< OtherDerived > &other)
Eigen::Matrix< double, 6, 1 > Base
Matrix3d & operator=(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE Matrix4d()
EIGEN_STRONG_INLINE SpatialVector(const double &v0, const double &v1, const double &v2, const double &v3, const double &v4, const double &v5)
EIGEN_STRONG_INLINE Matrix3d()
SpatialVector & operator=(const Eigen::MatrixBase< OtherDerived > &other)
void transform(const RobotDynamics::Math::SpatialTransform &X)
Pure virtual object. This object forces objects that inherit from it to have a method that tells how ...
EIGEN_STRONG_INLINE Vector4d(const double &v0, const double &v1, const double &v2, const double &v3)
Vector3d & operator=(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE Vector3d getAngularPart() const
SpatialMatrix(const Eigen::MatrixBase< OtherDerived > &other)
Vector4d(const Eigen::MatrixBase< OtherDerived > &other)
Eigen::Matrix< double, 6, 3 > Matrix63
EIGEN_STRONG_INLINE SpatialVector()
EIGEN_STRONG_INLINE Vector4d()
Matrix3d(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE Vector3d getLinearPart() const
SpatialVector(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE Vector3d()
SpatialMatrix & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Matrix4d & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Eigen::AngleAxisd AxisAngle
Namespace for all structures of the RobotDynamics library.
Vector3d(const Eigen::MatrixBase< OtherDerived > &other)
Eigen::Matrix< double, 4, 4 > Base