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 rate; }
76 const Vector3 & operator()()
const {
return rate; }
89 template<
typename Derived>
92 other.linear() += rate;
95 template<
typename Derived>
98 other.linear() = rate;
99 other.angular().setZero();
102 template<
typename S2,
int O2,
typename D2>
105 v.angular().setZero();
106 v.linear().noalias() = m.rotation() * rate;
109 template<
typename S2,
int O2>
113 se3Action_impl(m,res);
117 template<
typename S2,
int O2,
typename D2>
121 v.linear().noalias() = m.rotation().transpose() * rate;
124 v.angular().setZero();
127 template<
typename S2,
int O2>
131 se3ActionInverse_impl(m,res);
135 template<
typename M1,
typename M2>
139 mout.linear().noalias() = v.angular().cross(rate);
142 mout.angular().setZero();
145 template<
typename M1>
158 template<
typename S1,
int O1,
typename MotionDerived>
159 inline typename MotionDerived::MotionPlain
163 return typename MotionDerived::MotionPlain(m2.linear() + m1.rate, m2.angular());
168 template<
typename _Scalar,
int _Options>
176 typedef _Scalar Scalar;
178 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
179 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
180 typedef typename Matrix3::IdentityReturnType AngularType;
181 typedef AngularType AngularRef;
182 typedef AngularType ConstAngularRef;
183 typedef Vector3 LinearType;
184 typedef LinearType & LinearRef;
185 typedef const LinearType & ConstLinearRef;
190 template<
typename Scalar,
int Options>
194 template<
typename _Scalar,
int _Options>
196 :
SE3Base< TransformTranslationTpl<_Scalar,_Options> >
198 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
204 template<
typename Vector3Like>
206 : m_translation(translation)
209 PlainType plain()
const 211 PlainType res(PlainType::Identity());
212 res.rotation().setIdentity();
213 res.translation() = translation();
218 operator PlainType()
const {
return plain(); }
220 template<
typename S2,
int O2>
226 res.translation() += translation();
231 ConstLinearRef translation()
const {
return m_translation; }
232 LinearRef translation() {
return m_translation; }
234 AngularType rotation()
const {
return AngularType(3,3); }
238 LinearType m_translation;
243 template<
typename _Scalar,
int _Options>
246 typedef _Scalar Scalar;
248 enum { Options = _Options };
249 enum { LINEAR = 0, ANGULAR = 3 };
252 typedef Eigen::Matrix<Scalar,3,1,Options> JointForce;
253 typedef Eigen::Matrix<Scalar,6,3,Options> DenseBase;
255 typedef DenseBase MatrixReturnType;
256 typedef const DenseBase ConstMatrixReturnType;
259 template<
typename _Scalar,
int _Options>
263 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
275 template<
typename Vector3Like>
276 JointMotion __mult__(
const Eigen::MatrixBase<Vector3Like> & v)
const 278 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3);
282 int nv_impl()
const {
return NV; }
289 template<
typename Derived>
297 template<
typename MatrixDerived>
299 operator*(
const Eigen::MatrixBase<MatrixDerived> & F)
const 302 return F.derived().template middleRows<3>(LINEAR);
309 DenseBase matrix_impl()
const 312 S.template middleRows<3>(LINEAR).setIdentity();
313 S.template middleRows<3>(ANGULAR).setZero();
317 template<
typename S1,
int O1>
318 Eigen::Matrix<S1,6,3,O1> se3Action(
const SE3Tpl<S1,O1> & m)
const 320 Eigen::Matrix<S1,6,3,O1> M;
321 M.template middleRows<3>(LINEAR) = m.rotation();
322 M.template middleRows<3>(ANGULAR).setZero();
327 template<
typename S1,
int O1>
328 Eigen::Matrix<S1,6,3,O1> se3ActionInverse(
const SE3Tpl<S1,O1> & m)
const 330 Eigen::Matrix<S1,6,3,O1> M;
331 M.template middleRows<3>(LINEAR) = m.rotation().transpose();
332 M.template middleRows<3>(ANGULAR).setZero();
337 template<
typename MotionDerived>
340 const typename MotionDerived::ConstAngularType w = m.angular();
343 skew(w,res.template middleRows<3>(LINEAR));
344 res.template middleRows<3>(ANGULAR).setZero();
351 template<
typename MotionDerived,
typename S2,
int O2>
352 inline typename MotionDerived::MotionPlain
356 return m2.motionAction(m1);
360 template<
typename S1,
int O1,
typename S2,
int O2>
361 inline Eigen::Matrix<S2,6,3,O2>
366 Eigen::Matrix<S2,6,3,O2> M;
367 alphaSkew(Y.mass(),Y.lever(),M.template middleRows<3>(Constraint::ANGULAR));
368 M.template middleRows<3>(Constraint::LINEAR).setZero();
369 M.template middleRows<3>(Constraint::LINEAR).diagonal().fill(Y.mass ());
375 template<
typename M6Like,
typename S2,
int O2>
377 operator*(
const Eigen::MatrixBase<M6Like> & Y,
381 return Y.derived().template middleCols<3>(Constraint::LINEAR);
384 template<
typename S1,
int O1>
386 {
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
388 template<
typename S1,
int O1,
typename MotionDerived>
390 {
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
394 template<
typename _Scalar,
int _Options>
401 typedef _Scalar Scalar;
402 enum { Options = _Options };
411 typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
412 typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
413 typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
415 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
417 typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
418 typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
421 template<
typename Scalar,
int Options>
425 template<
typename Scalar,
int Options>
429 template<
typename _Scalar,
int _Options>
431 :
public JointDataBase< JointDataTranslationTpl<_Scalar,_Options> >
433 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
436 PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE(JointDerived);
437 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
451 static std::string classname() {
return std::string(
"JointDataTranslation"); }
452 std::string
shortname()
const {
return classname(); }
456 template<
typename _Scalar,
int _Options>
458 :
public JointModelBase< JointModelTranslationTpl<_Scalar,_Options> >
460 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
463 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(JointDerived);
469 using Base::setIndexes;
471 JointDataDerived
createData()
const {
return JointDataDerived(); }
473 template<
typename ConfigVector>
474 void calc(JointDataDerived & data,
475 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 477 data.M.translation() = this->jointConfigSelector(qs);
480 template<
typename ConfigVector,
typename TangentVector>
481 void calc(JointDataDerived & data,
482 const typename Eigen::MatrixBase<ConfigVector> & qs,
483 const typename Eigen::MatrixBase<TangentVector> & vs)
const 485 calc(data,qs.derived());
487 data.v() = this->jointVelocitySelector(vs);
490 template<
typename Matrix6Like>
491 void calc_aba(JointDataDerived & data,
492 const Eigen::MatrixBase<Matrix6Like> & I,
493 const bool update_I)
const 495 data.U = I.template middleCols<3>(Inertia::LINEAR);
500 internal::PerformStYSInversion<Scalar>::run(data.U.template middleRows<3>(Inertia::LINEAR),data.Dinv);
502 data.UDinv.template middleRows<3>(Inertia::LINEAR).setIdentity();
503 data.UDinv.template middleRows<3>(Inertia::ANGULAR).noalias() = data.U.template middleRows<3>(Inertia::ANGULAR) * data.Dinv;
507 Matrix6Like & I_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like,I);
508 I_.template block<3,3>(Inertia::ANGULAR,Inertia::ANGULAR)
509 -= data.UDinv.template middleRows<3>(Inertia::ANGULAR) * I_.template block<3,3>(Inertia::LINEAR, Inertia::ANGULAR);
510 I_.template middleCols<3>(Inertia::LINEAR).setZero();
511 I_.template block<3,3>(Inertia::LINEAR,Inertia::ANGULAR).setZero();
515 static std::string classname() {
return std::string(
"JointModelTranslation"); }
516 std::string
shortname()
const {
return classname(); }
519 template<
typename NewScalar>
532 #include <boost/type_traits.hpp> 536 template<
typename Scalar,
int Options>
538 :
public integral_constant<bool,true> {};
540 template<
typename Scalar,
int Options>
542 :
public integral_constant<bool,true> {};
544 template<
typename Scalar,
int Options>
546 :
public integral_constant<bool,true> {};
548 template<
typename Scalar,
int Options>
550 :
public integral_constant<bool,true> {};
553 #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.
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)