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" 21 template<
typename Scalar,
int Options>
27 template<
typename Scalar,
int Options,
typename MotionDerived>
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 PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6) ToVectorConstReturnType;
42 typedef typename PINOCCHIO_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;
56 template<
typename _Scalar,
int _Options>
58 :
MotionBase< MotionTranslationTpl<_Scalar,_Options> >
60 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
66 template<
typename Vector3Like>
75 Vector3 & operator()() {
return m_v; }
76 const Vector3 & operator()()
const {
return m_v; }
85 return m_v == other.m_v;
94 template<
typename Derived>
97 other.linear() += m_v;
100 template<
typename Derived>
103 other.linear() = m_v;
104 other.angular().setZero();
107 template<
typename S2,
int O2,
typename D2>
110 v.angular().setZero();
111 v.linear().noalias() = m.rotation() * m_v;
114 template<
typename S2,
int O2>
118 se3Action_impl(m,res);
122 template<
typename S2,
int O2,
typename D2>
126 v.linear().noalias() = m.rotation().transpose() * m_v;
129 v.angular().setZero();
132 template<
typename S2,
int O2>
136 se3ActionInverse_impl(m,res);
140 template<
typename M1,
typename M2>
144 mout.linear().noalias() = v.angular().cross(m_v);
147 mout.angular().setZero();
150 template<
typename M1>
158 const Vector3 & linear()
const {
return m_v; }
159 Vector3 & linear() {
return m_v; }
167 template<
typename S1,
int O1,
typename MotionDerived>
168 inline typename MotionDerived::MotionPlain
172 return typename MotionDerived::MotionPlain(m2.linear() + m1.linear(), m2.angular());
177 template<
typename _Scalar,
int _Options>
185 typedef _Scalar Scalar;
187 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
188 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
189 typedef typename Matrix3::IdentityReturnType AngularType;
190 typedef AngularType AngularRef;
191 typedef AngularType ConstAngularRef;
192 typedef Vector3 LinearType;
193 typedef LinearType & LinearRef;
194 typedef const LinearType & ConstLinearRef;
199 template<
typename Scalar,
int Options>
203 template<
typename _Scalar,
int _Options>
205 :
SE3Base< TransformTranslationTpl<_Scalar,_Options> >
207 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
213 template<
typename Vector3Like>
215 : m_translation(translation)
218 PlainType plain()
const 220 PlainType res(PlainType::Identity());
221 res.rotation().setIdentity();
222 res.translation() = translation();
227 operator PlainType()
const {
return plain(); }
229 template<
typename S2,
int O2>
235 res.translation() += translation();
240 ConstLinearRef translation()
const {
return m_translation; }
241 LinearRef translation() {
return m_translation; }
243 AngularType rotation()
const {
return AngularType(3,3); }
247 return m_translation == other.m_translation;
252 LinearType m_translation;
257 template<
typename _Scalar,
int _Options>
260 typedef _Scalar Scalar;
262 enum { Options = _Options };
263 enum { LINEAR = 0, ANGULAR = 3 };
266 typedef Eigen::Matrix<Scalar,3,1,Options> JointForce;
267 typedef Eigen::Matrix<Scalar,6,3,Options> DenseBase;
269 typedef DenseBase MatrixReturnType;
270 typedef const DenseBase ConstMatrixReturnType;
273 template<
typename _Scalar,
int _Options>
277 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
289 template<
typename Vector3Like>
290 JointMotion __mult__(
const Eigen::MatrixBase<Vector3Like> & v)
const 292 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3);
296 int nv_impl()
const {
return NV; }
303 template<
typename Derived>
311 template<
typename MatrixDerived>
313 operator*(
const Eigen::MatrixBase<MatrixDerived> & F)
const 316 return F.derived().template middleRows<3>(LINEAR);
323 DenseBase matrix_impl()
const 326 S.template middleRows<3>(LINEAR).setIdentity();
327 S.template middleRows<3>(ANGULAR).setZero();
331 template<
typename S1,
int O1>
332 Eigen::Matrix<S1,6,3,O1> se3Action(
const SE3Tpl<S1,O1> & m)
const 334 Eigen::Matrix<S1,6,3,O1> M;
335 M.template middleRows<3>(LINEAR) = m.rotation();
336 M.template middleRows<3>(ANGULAR).setZero();
341 template<
typename S1,
int O1>
342 Eigen::Matrix<S1,6,3,O1> se3ActionInverse(
const SE3Tpl<S1,O1> & m)
const 344 Eigen::Matrix<S1,6,3,O1> M;
345 M.template middleRows<3>(LINEAR) = m.rotation().transpose();
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();
367 template<
typename MotionDerived,
typename S2,
int O2>
368 inline typename MotionDerived::MotionPlain
372 return m2.motionAction(m1);
376 template<
typename S1,
int O1,
typename S2,
int O2>
377 inline Eigen::Matrix<S2,6,3,O2>
382 Eigen::Matrix<S2,6,3,O2> M;
383 alphaSkew(Y.mass(),Y.lever(),M.template middleRows<3>(Constraint::ANGULAR));
384 M.template middleRows<3>(Constraint::LINEAR).setZero();
385 M.template middleRows<3>(Constraint::LINEAR).diagonal().fill(Y.mass ());
391 template<
typename M6Like,
typename S2,
int O2>
393 operator*(
const Eigen::MatrixBase<M6Like> & Y,
397 return Y.derived().template middleCols<3>(Constraint::LINEAR);
400 template<
typename S1,
int O1>
402 {
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
404 template<
typename S1,
int O1,
typename MotionDerived>
406 {
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
410 template<
typename _Scalar,
int _Options>
417 typedef _Scalar Scalar;
418 enum { Options = _Options };
427 typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
428 typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
429 typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
431 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
433 typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
434 typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
437 template<
typename Scalar,
int Options>
441 template<
typename Scalar,
int Options>
445 template<
typename _Scalar,
int _Options>
447 :
public JointDataBase< JointDataTranslationTpl<_Scalar,_Options> >
449 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
452 PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE(JointDerived);
453 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
466 : M(Transformation_t::Vector3::Zero())
467 , v(Motion_t::Vector3::Zero())
470 , UDinv(UD_t::Zero())
473 static std::string classname() {
return std::string(
"JointDataTranslation"); }
474 std::string
shortname()
const {
return classname(); }
478 template<
typename _Scalar,
int _Options>
480 :
public JointModelBase< JointModelTranslationTpl<_Scalar,_Options> >
482 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
485 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(JointDerived);
491 using Base::setIndexes;
493 JointDataDerived
createData()
const {
return JointDataDerived(); }
495 template<
typename ConfigVector>
496 void calc(JointDataDerived & data,
497 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 499 data.M.translation() = this->jointConfigSelector(qs);
502 template<
typename ConfigVector,
typename TangentVector>
503 void calc(JointDataDerived & data,
504 const typename Eigen::MatrixBase<ConfigVector> & qs,
505 const typename Eigen::MatrixBase<TangentVector> & vs)
const 507 calc(data,qs.derived());
509 data.v.linear() = this->jointVelocitySelector(vs);
512 template<
typename Matrix6Like>
513 void calc_aba(JointDataDerived & data,
514 const Eigen::MatrixBase<Matrix6Like> & I,
515 const bool update_I)
const 517 data.U = I.template middleCols<3>(Inertia::LINEAR);
522 internal::PerformStYSInversion<Scalar>::run(data.U.template middleRows<3>(Inertia::LINEAR),data.Dinv);
524 data.UDinv.template middleRows<3>(Inertia::LINEAR).setIdentity();
525 data.UDinv.template middleRows<3>(Inertia::ANGULAR).noalias() = data.U.template middleRows<3>(Inertia::ANGULAR) * data.Dinv;
529 Matrix6Like & I_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like,I);
530 I_.template block<3,3>(Inertia::ANGULAR,Inertia::ANGULAR)
531 -= data.UDinv.template middleRows<3>(Inertia::ANGULAR) * I_.template block<3,3>(Inertia::LINEAR, Inertia::ANGULAR);
532 I_.template middleCols<3>(Inertia::LINEAR).setZero();
533 I_.template block<3,3>(Inertia::LINEAR,Inertia::ANGULAR).setZero();
537 static std::string classname() {
return std::string(
"JointModelTranslation"); }
538 std::string
shortname()
const {
return classname(); }
541 template<
typename NewScalar>
554 #include <boost/type_traits.hpp> 558 template<
typename Scalar,
int Options>
560 :
public integral_constant<bool,true> {};
562 template<
typename Scalar,
int Options>
564 :
public integral_constant<bool,true> {};
566 template<
typename Scalar,
int Options>
568 :
public integral_constant<bool,true> {};
570 template<
typename Scalar,
int Options>
572 :
public integral_constant<bool,true> {};
575 #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...
Return type of the ation of a Motion onto an object of type D.
JointDataTpl< Scalar, Options, JointCollectionTpl > createData(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through CreateData visitor to create a JointDataTpl.
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.
Base class for rigid transformation.
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...
MultiplicationOp< InertiaTpl< Scalar, Options >, ConstraintDerived >::ReturnType operator*(const InertiaTpl< Scalar, Options > &Y, const ConstraintBase< ConstraintDerived > &constraint)
.