10 #ifndef IIT_RBD_ROBCOGEN_COMMON_EXPRESSIONS_ 11 #define IIT_RBD_ROBCOGEN_COMMON_EXPRESSIONS_ 41 #define DScalar typename Derived::Scalar 57 template <
typename Derived>
67 Scalar wx2 = v(
AX)*v(
AX);
68 Scalar wy2 = v(
AY)*v(
AY);
69 Scalar wz2 = v(
AZ)*v(
AZ);
71 Scalar v_AXAY = v(
AX)*v(
AY);
72 Scalar v_AXAZ = v(
AX)*v(
AZ);
73 Scalar v_AXLY = v(
AX)*v(
LY);
74 Scalar v_AXLZ = v(
AX)*v(
LZ);
76 Scalar v_AYAZ = v(
AY)*v(
AZ);
77 Scalar v_AYLX = v(
AY)*v(
LX);
78 Scalar v_AYLZ = v(
AY)*v(
LZ);
80 Scalar v_AZLX = v(
AZ)*v(
LX);
81 Scalar v_AZLY = v(
AZ)*v(
LY);
90 Scalar cmX = I(
AZ,
LY);
91 Scalar cmY = I(
AX,
LZ);
92 Scalar cmZ = I(
AY,
LX);
95 ret(
AX) = cmZ * (v_AXLZ - v_AZLX)
96 + cmY * (v_AXLY - v_AYLX)
97 + v_AYAZ * (Iaa.
ZZ - Iaa.
YY)
98 - v_AXAZ*Iaa.
XY - (wz2 - wy2)*Iaa.
YZ + v_AXAY*Iaa.
XZ;
100 ret(
AY) = cmZ * (v_AYLZ - v_AZLY)
101 - cmX * (v_AXLY - v_AYLX)
102 - v_AXAZ * (Iaa.
ZZ - Iaa.
XX)
103 + v_AYAZ*Iaa.
XY - v_AXAY*Iaa.
YZ + (wz2 - wx2)*Iaa.
XZ;
105 ret(
AZ) = cmX * (v_AZLX - v_AXLZ)
106 - cmY * (v_AYLZ - v_AZLY)
107 + v_AXAY * (Iaa.
YY - Iaa.
XX)
108 + v_AXAZ*Iaa.
YZ - Iaa.
XZ*v_AYAZ - (wy2 - wx2)*Iaa.
XY;
110 ret(
LX) = m * (v_AYLZ - v_AZLY) - cmX * (wz2 + wy2) + v_AXAZ*cmZ + v_AXAY*cmY;
111 ret(
LY) = - m * (v_AXLZ - v_AZLX) - cmY * (wz2 + wx2) + v_AXAY*cmX + v_AYAZ*cmZ;
112 ret(
LZ) = m * (v_AXLY - v_AYLX) - cmZ * (wy2 + wx2) + v_AXAZ*cmX + v_AYAZ*cmY;
125 template <
typename Derived>
130 ret(
AX) = -I(
AY,
AZ) * wz2;
152 template<
typename S =
double>
171 template<
typename S =
double>
184 template<
typename S =
double>
217 template<
typename Scalar =
double>
267 I_translated.
XX += mass*( py2 + pz2 - cy2 - cz2 );
268 I_translated.
YY += mass*( px2 + pz2 - cx2 - cz2 );
269 I_translated.
ZZ += mass*( px2 + py2 - cx2 - cy2 );
270 I_translated.
XY += mass*( comAx*comAy - p(
X)*p(
Y) );
271 I_translated.
XZ += mass*( comAx*comAz - p(
X)*p(
Z) );
272 I_translated.
YZ += mass*( comAy*comAz - p(
Y)*p(
Z) );
276 internal::rot_symmetric_EAET<Scalar>(E, I_translated, I3x3_B);
279 E.XX*p(
X) + E.XY*p(
Y) + E.XZ*p(
Z),
280 E.YX*p(
X) + E.YY*p(
Y) + E.YZ*p(
Z),
281 E.ZX*p(
X) + E.ZY*p(
Y) + E.ZZ*p(
Z)
292 #define block33 template block<3,3> 314 template <
typename D1,
typename D2,
typename D3>
320 typedef typename D1::Scalar
Scalar;
331 Scalar rx = E.XY * XM(
LZ,
AX) + E.YY * XM(
LZ,
AY) + E.ZY * XM(
LZ,
AZ);
332 Scalar ry = E.XZ * XM(
LX,
AX) + E.YZ * XM(
LX,
AY) + E.ZZ * XM(
LX,
AZ);
333 Scalar rz = E.XX * XM(
LY,
AX) + E.YX * XM(
LY,
AY) + E.ZX * XM(
LY,
AZ);
355 Scalar(0), Scalar(0), Scalar(0));
357 aux1.
XX = Ia_A(
AX,
AX) + 2*C.
XY*rz - 2*C.
XZ*ry;
358 aux1.
YY = Ia_A(
AY,
AY) + 2*C.
YZ*rx - 2*C.
YX*rz;
361 aux1.
XZ = C.
XX*ry - C.
XY*rx;
362 aux1.
YZ = C.
YX*ry - C.
YY*rx;
370 rxM.
XX = rz*M.
XY - ry*M.
XZ;
371 rxM.
YY = rx*M.
YZ - rz*M.
XY;
372 rxM.
ZZ = ry*M.
XZ - rx*M.
YZ;
373 rxM.
XY = rz*M.
YY - ry*M.
YZ;
374 rxM.
YX = rx*M.
XZ - rz*M.
XX;
375 rxM.
XZ = rz*M.
YZ - ry*M.
ZZ;
376 rxM.
ZX = ry*M.
XX - rx*M.
XY;
377 rxM.
YZ = rx*M.
ZZ - rz*M.
XZ;
378 rxM.
ZY = ry*M.
XY - rx*M.
YY;
381 aux1.
XX += rxM.
XY*rz - rxM.
XZ*ry;
382 aux1.
YY += rxM.
YZ*rx - rxM.
YX*rz;
383 aux1.
ZZ += rxM.
ZX*ry - rxM.
ZY*rx;
384 aux1.
XY += rxM.
XZ*rx - rxM.
XX*rz;
385 aux1.
XZ += rxM.
XX*ry - rxM.
XY*rx;
386 aux1.
YZ += rxM.
YX*ry - rxM.
YY*rx;
389 internal::rot_symmetric_EAET<Scalar>(E, aux1, aux2);
413 internal::rot_EAET<Scalar>(E, rxM, aux3);
426 internal::rot_symmetric_EAET<Scalar>(E, M, aux1);
427 Ia_B(
LX,
LX) = aux1.XX;
428 Ia_B(
LY,
LY) = aux1.YY;
429 Ia_B(
LZ,
LZ) = aux1.ZZ;
430 Ia_B(
LY,
LX) = Ia_B(
LX,
LY) = aux1.XY;
431 Ia_B(
LZ,
LX) = Ia_B(
LX,
LZ) = aux1.XZ;
432 Ia_B(
LZ,
LY) = Ia_B(
LY,
LZ) = aux1.YZ;
437 template <
typename D1,
typename D2,
typename D3>
443 typedef typename D1::Scalar
Scalar;
454 Scalar rx = E.XY * XM(
LZ,
AX) + E.YY * XM(
LZ,
AY) + E.ZY * XM(
LZ,
AZ);
455 Scalar ry = E.XZ * XM(
LX,
AX) + E.YZ * XM(
LX,
AY) + E.ZZ * XM(
LX,
AZ);
456 Scalar rz = E.XX * XM(
LY,
AX) + E.YX * XM(
LY,
AY) + E.ZX * XM(
LY,
AZ);
487 aux1.
ZZ = Ia_A(
AZ,
AZ) + 2*C.
ZX*ry - 2*C.
ZY*rx;
503 rxM.
ZX = ry*M.
XX - rx*M.
XY;
504 rxM.
ZY = ry*M.
XY - rx*M.
YY;
510 aux1.
XX += rxM.
XY*rz;
511 aux1.
YY += - rxM.
YX*rz;
512 aux1.
ZZ += rxM.
ZX*ry - rxM.
ZY*rx;
513 aux1.
XY += - rxM.
XX*rz;
514 aux1.
XZ += rxM.
XX*ry - rxM.
XY*rx;
515 aux1.
YZ += rxM.
YX*ry - rxM.
YY*rx;
518 internal::rot_symmetric_EAET<Scalar>(E, aux1, aux2);
544 internal::rot_EAET<Scalar>(E, rxM, aux3);
557 internal::rot_symmetric_EAET<Scalar>(E, M, aux1);
558 Ia_B(
LX,
LX) = aux1.XX;
559 Ia_B(
LY,
LY) = aux1.YY;
560 Ia_B(
LZ,
LZ) = aux1.ZZ;
561 Ia_B(
LY,
LX) = Ia_B(
LX,
LY) = aux1.XY;
562 Ia_B(
LZ,
LX) = Ia_B(
LX,
LZ) = aux1.XZ;
563 Ia_B(
LZ,
LY) = Ia_B(
LY,
LZ) = aux1.YZ;
594 template <
typename D1,
typename D2>
598 const typename D1::Scalar& D,
601 typedef typename D1::Scalar
Scalar;
605 Scalar UD_AX = U(
AX) / D;
606 Scalar UD_AY = U(
AY) / D;
608 Scalar UD_LX = U(
LX) / D;
609 Scalar UD_LY = U(
LY) / D;
610 Scalar UD_LZ = U(
LZ) / D;
638 template <
typename D1,
typename D2>
642 const typename D1::Scalar& D,
645 typedef typename D1::Scalar
Scalar;
649 Scalar UD_AX = U(
AX) / D;
650 Scalar UD_AY = U(
AY) / D;
651 Scalar UD_AZ = U(
AZ) / D;
652 Scalar UD_LX = U(
LX) / D;
653 Scalar UD_LY = U(
LY) / D;
Scalar YZ
Definition: internals.h:30
void compute_Ia_revolute(const MatrixBase< D1 > &IA, const Vec6< typename D1::Scalar > &U, const typename D1::Scalar &D, const MatrixBase< D2 > &Ia_const)
Definition: robcogen_commons.h:595
typename Core< S >::VelocityVector Velocity
Definition: types.h:21
Scalar YX
Definition: internals.h:30
Scalar XZ
Definition: internals.h:64
void compute_Ia_prismatic(const MatrixBase< D1 > &IA, const Vec6< typename D1::Scalar > &U, const typename D1::Scalar &D, const MatrixBase< D2 > &Ia_const)
Definition: robcogen_commons.h:639
Scalar ZZ
Definition: internals.h:64
ct::core::ADCodegenLinearizer< state_dim, control_dim >::ADCGScalar Scalar
Definition: internals.h:63
Force< DScalar > vxIv(const Velocity< DScalar > &v, const MatrixBase< Derived > &I)
Definition: robcogen_commons.h:58
Definition: internals.h:28
Scalar YZ
Definition: internals.h:64
Definition: InertiaMatrix.h:25
Scalar XX
Definition: internals.h:64
Scalar XY
Definition: internals.h:64
void transformInertia(const InertiaMat< Scalar > &I_A, const Mat66< Scalar > &XF, InertiaMat< Scalar > &I_B)
Definition: robcogen_commons.h:218
typename Core< S >::Vector6 Vec6
Definition: types.h:26
typename Core< S >::Matrix66 Mat66
Definition: types.h:24
Scalar XX
Definition: internals.h:30
Vector6D ForceVector
a 3D subvector of a 6D vector
Definition: rbd.h:92
void fillInertia(S mass, const Vec3< S > &com, const internal::SymmMat3x3Coefficients< S > &I3x3, InertiaMat< S > &I)
Definition: robcogen_commons.h:185
Eigen::MatrixBase< Derived > MatrixBase
Definition: rbd.h:51
Scalar YY
Definition: internals.h:30
void forceCrossProductMx(const Velocity< S > &v, Mat66< S > &vx)
Definition: robcogen_commons.h:172
Scalar ZX
Definition: internals.h:30
Scalar XZ
Definition: internals.h:30
void ctransform_Ia_prismatic(const MatrixBase< D1 > &Ia_A, const MatrixBase< D2 > &XM, const MatrixBase< D3 > &Ia_B_const)
Definition: robcogen_commons.h:438
typename Core< S >::ForceVector Force
Definition: types.h:22
Scalar YY
Definition: internals.h:64
Scalar XY
Definition: internals.h:30
Scalar ZY
Definition: internals.h:30
PlainMatrix< Scalar, 3, 1 > Vector3
Definition: rbd.h:80
Scalar ZZ
Definition: internals.h:30
typename Core< S >::Vector3 Vec3
Definition: types.h:25
void ctransform_Ia_revolute(const MatrixBase< D1 > &Ia_A, const MatrixBase< D2 > &XM, const MatrixBase< D3 > &Ia_B_const)
Definition: robcogen_commons.h:315
#define DScalar
Definition: robcogen_commons.h:41
void motionCrossProductMx(const Velocity< S > &v, Mat66< S > &vx)
Definition: robcogen_commons.h:153