19 #ifndef __se3_joint_translation_hpp__    20 #define __se3_joint_translation_hpp__    22 #include "pinocchio/macros.hpp"    23 #include "pinocchio/multibody/joint/joint-base.hpp"    24 #include "pinocchio/multibody/constraint.hpp"    25 #include "pinocchio/spatial/inertia.hpp"    26 #include "pinocchio/spatial/skew.hpp"    33   template<
typename _Scalar, 
int _Options>
    36     typedef _Scalar Scalar;
    37     enum { Options = _Options };
    38     typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
    39     typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
    40     typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
    41     typedef typename EIGEN_REF_CONSTTYPE(Vector6) ToVectorConstReturnType;
    42     typedef typename EIGEN_REF_TYPE(Vector6) ToVectorReturnType;
    43     typedef Vector3 AngularType;
    44     typedef Vector3 LinearType;
    45     typedef const Vector3 ConstAngularType;
    46     typedef const Vector3 ConstLinearType;
    47     typedef Matrix6 ActionMatrixType;
    55   template<
typename _Scalar, 
int _Options>
    61     template<
typename Vector3Like>
    66     Vector3 & operator()() { 
return v; }
    67     const Vector3 & operator()()
 const { 
return v; }
    80     template<
typename Derived>
    91   template<
typename S1, 
int O1, 
typename MotionDerived>
    94     return typename MotionDerived::MotionPlain(m2.linear() + m1.v, m2.angular());
    99   template<
typename _Scalar, 
int _Options>
   102     typedef _Scalar Scalar;
   103     enum { Options = _Options };
   104     typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
   105     typedef Eigen::Matrix<Scalar,4,1,Options> Vector4;
   106     typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
   107     typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
   108     typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4;
   109     typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
   110     typedef Matrix3 Angular_t;
   111     typedef Vector3 Linear_t;
   112     typedef const Matrix3 ConstAngular_t;
   113     typedef const Vector3 ConstLinear_t;
   114     typedef Matrix6 ActionMatrix_t;
   115     typedef Eigen::Quaternion<Scalar,Options> Quaternion_t;
   124     typedef Eigen::Matrix<Scalar,3,1,Options> JointMotion;
   125     typedef Eigen::Matrix<Scalar,3,1,Options> JointForce;
   126     typedef Eigen::Matrix<Scalar,6,3,Options> DenseBase;
   127     typedef DenseBase MatrixReturnType;
   128     typedef const DenseBase ConstMatrixReturnType;
   131   template<
typename _Scalar, 
int _Options>
   143     template<
typename S1, 
int O1>
   145     { 
return Motion(vj(), Motion::Vector3::Zero()); }
   147     template<
typename Vector3Like>
   149     operator*(
const Eigen::MatrixBase<Vector3Like> & v)
 const   151       EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3);
   155     int nv_impl()
 const { 
return NV; }
   162       template<
typename Derived>
   170       template<
typename MatrixDerived>
   172       operator*(
const Eigen::MatrixBase<MatrixDerived> & F)
 const   175         return F.derived().template middleRows<3>(LINEAR);
   182     DenseBase matrix_impl()
 const   185       S.template middleRows<3>(LINEAR).setIdentity();
   186       S.template middleRows<3>(ANGULAR).setZero();
   190     template<
typename S1, 
int O1>
   191     Eigen::Matrix<S1,6,3,O1> se3Action(
const SE3Tpl<S1,O1> & m)
 const   193       Eigen::Matrix<S1,6,3,O1> M;
   194       M.template middleRows<3>(LINEAR) = m.rotation ();
   195       M.template middleRows<3>(ANGULAR).setZero ();
   200     template<
typename MotionDerived>
   203       const typename MotionDerived::ConstAngularType w = m.angular();
   206       skew(w,res.template middleRows<3>(LINEAR));
   207       res.template middleRows<3>(ANGULAR).setZero();
   214   template<
typename MotionDerived, 
typename S2, 
int O2>
   215   inline typename MotionDerived::MotionPlain
   219     typedef typename MotionDerived::MotionPlain ReturnType;
   220     return ReturnType(m1.angular().cross(m2.v),
   221                       ReturnType::Vector3::Zero());
   225   template<
typename S1, 
int O1, 
typename S2, 
int O2>
   226   inline Eigen::Matrix<S2,6,3,O2>
   231     Eigen::Matrix<S2,6,3,O2> M;
   232     alphaSkew(Y.mass(),Y.lever(),M.template middleRows<3>(Constraint::ANGULAR));
   233     M.template middleRows<3>(Constraint::LINEAR).setZero();
   234     M.template middleRows<3>(Constraint::LINEAR).diagonal().fill(Y.mass ());
   240   template<
typename M6Like, 
typename S2, 
int O2>
   242   operator*(
const Eigen::MatrixBase<M6Like> & Y,
   246     return Y.derived().template middleCols<3>(Constraint::LINEAR);
   251     template<
typename S1, 
int O1>
   252     struct SE3GroupAction< ConstraintTranslationTpl<S1,O1> >
   253     { 
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
   255     template<
typename S1, 
int O1, 
typename MotionDerived>
   256     struct MotionAlgebraAction< ConstraintTranslationTpl<S1,O1>,MotionDerived >
   257     { 
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
   263   template<
typename _Scalar, 
int _Options>
   270     typedef _Scalar Scalar;
   271     enum { Options = _Options };
   278     typedef Eigen::Matrix<Scalar,6,NV,Options> F_t;
   281     typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
   282     typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
   283     typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
   285     typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
   286     typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
   289   template<
typename Scalar, 
int Options>
   293   template<
typename Scalar, 
int Options>
   297   template<
typename _Scalar, 
int _Options>
   301     SE3_JOINT_TYPEDEF_TEMPLATE;
   319   template<
typename _Scalar, 
int _Options>
   323     SE3_JOINT_TYPEDEF_TEMPLATE;
   330     JointDataDerived 
createData()
 const { 
return JointDataDerived(); }
   332     template<
typename ConfigVector>
   333     void calc(JointDataDerived & data,
   334               const typename Eigen::MatrixBase<ConfigVector> & qs)
 const   336       EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(ConfigVector_t,ConfigVector);
   337       data.M.translation(qs.template segment<NQ>(
idx_q()));
   340     template<
typename ConfigVector, 
typename TangentVector>
   341     void calc(JointDataDerived & data,
   342               const typename Eigen::MatrixBase<ConfigVector> & qs,
   343               const typename Eigen::MatrixBase<TangentVector> & vs)
 const   345       EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TangentVector_t,TangentVector);
   346       calc(data,qs.derived());
   348       data.v() = vs.template segment<NQ>(
idx_v());
   351     template<
typename S2, 
int O2>
   352     void calc_aba(JointDataDerived & data, Eigen::Matrix<S2,6,6,O2> & I, 
const bool update_I)
 const   354       data.U = I.template middleCols<3>(Inertia::LINEAR);
   355       data.Dinv = data.U.template middleRows<3>(Inertia::LINEAR).inverse();
   356       data.UDinv.template middleRows<3>(Inertia::LINEAR).setIdentity(); 
   357       data.UDinv.template middleRows<3>(Inertia::ANGULAR).noalias() = data.U.template middleRows<3>(Inertia::ANGULAR) * data.Dinv;
   361         I.template block<3,3>(Inertia::ANGULAR,Inertia::ANGULAR)
   362         -= data.UDinv.template middleRows<3>(Inertia::ANGULAR) * I.template block<3,3>(Inertia::LINEAR, Inertia::ANGULAR);
   363         I.template middleCols<3>(Inertia::LINEAR).setZero();
   364         I.template block<3,3>(Inertia::LINEAR,Inertia::ANGULAR).setZero();
   371       return sqrt(Eigen::NumTraits<Scalar>::epsilon());
   374     static std::string classname() { 
return std::string(
"JointModelTranslation"); }
   375     std::string 
shortname()
 const { 
return classname(); }
   381 #endif // ifndef __se3_joint_translation_hpp__ 
JointDataVariant createData(const JointModelVariant &jmodel)
Visit a JointModelVariant through CreateData visitor to create a JointDataVariant. 
 
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 ( ) 
 
void calc_aba(const JointModelVariant &jmodel, JointDataVariant &jdata, Inertia::Matrix6 &I, const bool update_I)
Visit a JointDataVariant and the corresponding JointModelVariant through JointCalcAbaVisitor to...
 
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. 
 
std::string shortname(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointShortnameVisitor to get the shortname of the derived joint mod...
 
int idx_q(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointIdxQVisitor to get the index in the full model configuration s...
 
Eigen::VectorXd finiteDifferenceIncrement(const Model &model)
Computes the finite difference increments for each degree of freedom according to the current joint c...
 
int idx_v(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointIdxVVisitor to get the index in the full model tangent space c...