6 #ifndef __pinocchio_joint_translation_hpp__ 7 #define __pinocchio_joint_translation_hpp__ 9 #include "pinocchio/macros.hpp" 10 #include "pinocchio/multibody/joint/joint-base.hpp" 11 #include "pinocchio/multibody/constraint.hpp" 12 #include "pinocchio/spatial/inertia.hpp" 13 #include "pinocchio/spatial/skew.hpp" 23 template<
typename Scalar,
int Options>
29 template<
typename Scalar,
int Options,
typename MotionDerived>
36 template<
typename _Scalar,
int _Options>
39 typedef _Scalar Scalar;
40 enum { Options = _Options };
41 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
42 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
43 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
44 typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6) ToVectorConstReturnType;
45 typedef typename PINOCCHIO_EIGEN_REF_TYPE(Vector6) ToVectorReturnType;
46 typedef Vector3 AngularType;
47 typedef Vector3 LinearType;
48 typedef const Vector3 ConstAngularType;
49 typedef const Vector3 ConstLinearType;
50 typedef Matrix6 ActionMatrixType;
58 template<
typename _Scalar,
int _Options>
61 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
67 template<
typename Vector3Like>
76 Vector3 & operator()() {
return rate; }
77 const Vector3 & operator()()
const {
return rate; }
90 template<
typename Derived>
93 other.linear() += rate;
96 template<
typename Derived>
99 other.linear() = rate;
100 other.angular().setZero();
103 template<
typename S2,
int O2,
typename D2>
106 v.angular().setZero();
107 v.linear().noalias() = m.rotation() * rate;
110 template<
typename S2,
int O2>
114 se3Action_impl(m,res);
118 template<
typename S2,
int O2,
typename D2>
122 v.linear().noalias() = m.rotation().transpose() * rate;
125 v.angular().setZero();
128 template<
typename S2,
int O2>
132 se3ActionInverse_impl(m,res);
136 template<
typename M1,
typename M2>
140 mout.linear().noalias() = v.angular().cross(rate);
143 mout.angular().setZero();
146 template<
typename M1>
159 template<
typename S1,
int O1,
typename MotionDerived>
160 inline typename MotionDerived::MotionPlain
164 return typename MotionDerived::MotionPlain(m2.linear() + m1.rate, m2.angular());
169 template<
typename _Scalar,
int _Options>
177 typedef _Scalar Scalar;
179 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
180 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
181 typedef typename Matrix3::IdentityReturnType AngularType;
182 typedef AngularType AngularRef;
183 typedef AngularType ConstAngularRef;
184 typedef Vector3 LinearType;
185 typedef LinearType & LinearRef;
186 typedef const LinearType & ConstLinearRef;
193 template<
typename Scalar,
int Options>
194 struct SE3GroupAction< TransformTranslationTpl<Scalar,Options> >
198 template<
typename _Scalar,
int _Options>
200 :
SE3Base< TransformTranslationTpl<_Scalar,_Options> >
202 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
208 template<
typename Vector3Like>
210 : m_translation(translation)
213 PlainType plain()
const 215 PlainType res(PlainType::Identity());
216 res.rotation().setIdentity();
217 res.translation() = translation();
222 operator PlainType()
const {
return plain(); }
224 template<
typename S2,
int O2>
230 res.translation() += translation();
235 ConstLinearRef translation()
const {
return m_translation; }
236 LinearRef translation() {
return m_translation; }
238 AngularType rotation()
const {
return AngularType(3,3); }
242 LinearType m_translation;
247 template<
typename _Scalar,
int _Options>
250 typedef _Scalar Scalar;
251 enum { Options = _Options };
252 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
253 typedef Eigen::Matrix<Scalar,4,1,Options> Vector4;
254 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
255 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
256 typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4;
257 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
258 typedef Matrix3 Angular_t;
259 typedef Vector3 Linear_t;
260 typedef const Matrix3 ConstAngular_t;
261 typedef const Vector3 ConstLinear_t;
262 typedef Matrix6 ActionMatrix_t;
263 typedef Eigen::Quaternion<Scalar,Options> Quaternion_t;
273 typedef Eigen::Matrix<Scalar,3,1,Options> JointForce;
274 typedef Eigen::Matrix<Scalar,6,3,Options> DenseBase;
276 typedef DenseBase MatrixReturnType;
277 typedef const DenseBase ConstMatrixReturnType;
280 template<
typename _Scalar,
int _Options>
284 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
288 enum { NV = 3, Options = _Options };
299 template<
typename Vector3Like>
300 JointMotion __mult__(
const Eigen::MatrixBase<Vector3Like> & v)
const 302 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3);
303 return JointMotion(v);
306 int nv_impl()
const {
return NV; }
313 template<
typename Derived>
321 template<
typename MatrixDerived>
323 operator*(
const Eigen::MatrixBase<MatrixDerived> & F)
const 326 return F.derived().template middleRows<3>(LINEAR);
333 DenseBase matrix_impl()
const 336 S.template middleRows<3>(LINEAR).setIdentity();
337 S.template middleRows<3>(ANGULAR).setZero();
341 template<
typename S1,
int O1>
342 Eigen::Matrix<S1,6,3,O1> se3Action(
const SE3Tpl<S1,O1> & m)
const 344 Eigen::Matrix<S1,6,3,O1> M;
345 M.template middleRows<3>(LINEAR) = m.rotation ();
346 M.template middleRows<3>(ANGULAR).setZero ();
351 template<
typename MotionDerived>
354 const typename MotionDerived::ConstAngularType w = m.angular();
357 skew(w,res.template middleRows<3>(LINEAR));
358 res.template middleRows<3>(ANGULAR).setZero();
365 template<
typename MotionDerived,
typename S2,
int O2>
366 inline typename MotionDerived::MotionPlain
370 return m2.motionAction(m1);
374 template<
typename S1,
int O1,
typename S2,
int O2>
375 inline Eigen::Matrix<S2,6,3,O2>
380 Eigen::Matrix<S2,6,3,O2> M;
381 alphaSkew(Y.mass(),Y.lever(),M.template middleRows<3>(Constraint::ANGULAR));
382 M.template middleRows<3>(Constraint::LINEAR).setZero();
383 M.template middleRows<3>(Constraint::LINEAR).diagonal().fill(Y.mass ());
389 template<
typename M6Like,
typename S2,
int O2>
391 operator*(
const Eigen::MatrixBase<M6Like> & Y,
395 return Y.derived().template middleCols<3>(Constraint::LINEAR);
400 template<
typename S1,
int O1>
401 struct SE3GroupAction< ConstraintTranslationTpl<S1,O1> >
402 {
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
404 template<
typename S1,
int O1,
typename MotionDerived>
405 struct MotionAlgebraAction< ConstraintTranslationTpl<S1,O1>,MotionDerived >
406 {
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
412 template<
typename _Scalar,
int _Options>
419 typedef _Scalar Scalar;
420 enum { Options = _Options };
427 typedef Eigen::Matrix<Scalar,6,NV,Options> F_t;
430 typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
431 typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
432 typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
434 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
436 typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
437 typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
440 template<
typename Scalar,
int Options>
444 template<
typename Scalar,
int Options>
448 template<
typename _Scalar,
int _Options>
450 :
public JointDataBase< JointDataTranslationTpl<_Scalar,_Options> >
452 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
455 PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE;
456 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
472 static std::string classname() {
return std::string(
"JointDataTranslation"); }
473 std::string
shortname()
const {
return classname(); }
477 template<
typename _Scalar,
int _Options>
479 :
public JointModelBase< JointModelTranslationTpl<_Scalar,_Options> >
481 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
484 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE;
490 using Base::setIndexes;
492 JointDataDerived
createData()
const {
return JointDataDerived(); }
494 template<
typename ConfigVector>
495 void calc(JointDataDerived & data,
496 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 498 data.M.translation() = this->jointConfigSelector(qs);
501 template<
typename ConfigVector,
typename TangentVector>
502 void calc(JointDataDerived & data,
503 const typename Eigen::MatrixBase<ConfigVector> & qs,
504 const typename Eigen::MatrixBase<TangentVector> & vs)
const 506 calc(data,qs.derived());
508 data.v() = this->jointVelocitySelector(vs);
511 template<
typename Matrix6Like>
512 void calc_aba(JointDataDerived & data,
const Eigen::MatrixBase<Matrix6Like> & I,
const bool update_I)
const 514 data.U = I.template middleCols<3>(Inertia::LINEAR);
517 data.Dinv.setIdentity();
518 data.U.template middleRows<3>(Inertia::LINEAR).llt().solveInPlace(data.Dinv);
520 data.UDinv.template middleRows<3>(Inertia::LINEAR).setIdentity();
521 data.UDinv.template middleRows<3>(Inertia::ANGULAR).noalias() = data.U.template middleRows<3>(Inertia::ANGULAR) * data.Dinv;
525 Matrix6Like & I_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like,I);
526 I_.template block<3,3>(Inertia::ANGULAR,Inertia::ANGULAR)
527 -= data.UDinv.template middleRows<3>(Inertia::ANGULAR) * I_.template block<3,3>(Inertia::LINEAR, Inertia::ANGULAR);
528 I_.template middleCols<3>(Inertia::LINEAR).setZero();
529 I_.template block<3,3>(Inertia::LINEAR,Inertia::ANGULAR).setZero();
536 return sqrt(Eigen::NumTraits<Scalar>::epsilon());
539 static std::string classname() {
return std::string(
"JointModelTranslation"); }
540 std::string
shortname()
const {
return classname(); }
543 template<
typename NewScalar>
556 #include <boost/type_traits.hpp> 560 template<
typename Scalar,
int Options>
562 :
public integral_constant<bool,true> {};
564 template<
typename Scalar,
int Options>
566 :
public integral_constant<bool,true> {};
568 template<
typename Scalar,
int Options>
570 :
public integral_constant<bool,true> {};
572 template<
typename Scalar,
int Options>
574 :
public integral_constant<bool,true> {};
577 #endif // ifndef __pinocchio_joint_translation_hpp__
int idx_q(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxQVisitor to get the index in the full model configuration space...
int idx_v(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxVVisitor to get the index in the full model tangent space corre...
JointDataTpl< Scalar, Options, JointCollectionTpl > createData(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through CreateData visitor to create a JointDataTpl.
ModelTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType finiteDifferenceIncrement(const ModelTpl< Scalar, Options, JointCollectionTpl > &model)
Computes the finite difference increments for each degree of freedom according to the current joint c...
std::string shortname(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointShortnameVisitor to get the shortname of the derived joint model...
Main pinocchio namespace.
void alphaSkew(const Scalar alpha, const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
Computes the skew representation of a given 3d vector multiplied by a given scalar. i.e. the antisymmetric matrix representation of the cross product operator ( )
Common traits structure to fully define base classes for CRTP.
void skew(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
Computes the skew representation of a given 3d vector, i.e. the antisymmetric matrix representation o...
ConstLinearType linear() const
Return the linear part of the force vector.
JointModelTranslationTpl< NewScalar, Options > cast() const
void calc_aba(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata, const Eigen::MatrixBase< Matrix6Type > &I, const bool update_I)
Visit a JointModelTpl and the corresponding JointDataTpl through JointCalcAbaVisitor to...