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
214 template<
typename Vector3Like>
216 : m_translation(translation)
219 PlainType plain()
const 221 PlainType res(PlainType::Identity());
222 res.rotation().setIdentity();
223 res.translation() = translation();
228 operator PlainType()
const {
return plain(); }
230 template<
typename S2,
int O2>
236 res.translation() += translation();
241 ConstLinearRef translation()
const {
return m_translation; }
242 LinearRef translation() {
return m_translation; }
244 AngularType rotation()
const {
return AngularType(3,3); }
248 return m_translation == other.m_translation;
253 LinearType m_translation;
258 template<
typename _Scalar,
int _Options>
261 typedef _Scalar Scalar;
263 enum { Options = _Options };
264 enum { LINEAR = 0, ANGULAR = 3 };
267 typedef Eigen::Matrix<Scalar,3,1,Options> JointForce;
268 typedef Eigen::Matrix<Scalar,6,3,Options> DenseBase;
270 typedef DenseBase MatrixReturnType;
271 typedef const DenseBase ConstMatrixReturnType;
274 template<
typename _Scalar,
int _Options>
278 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
290 template<
typename Vector3Like>
291 JointMotion __mult__(
const Eigen::MatrixBase<Vector3Like> & v)
const 293 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3);
297 int nv_impl()
const {
return NV; }
304 template<
typename Derived>
312 template<
typename MatrixDerived>
314 operator*(
const Eigen::MatrixBase<MatrixDerived> & F)
const 317 return F.derived().template middleRows<3>(LINEAR);
324 DenseBase matrix_impl()
const 327 S.template middleRows<3>(LINEAR).setIdentity();
328 S.template middleRows<3>(ANGULAR).setZero();
332 template<
typename S1,
int O1>
333 Eigen::Matrix<S1,6,3,O1> se3Action(
const SE3Tpl<S1,O1> & m)
const 335 Eigen::Matrix<S1,6,3,O1> M;
336 M.template middleRows<3>(LINEAR) = m.rotation();
337 M.template middleRows<3>(ANGULAR).setZero();
342 template<
typename S1,
int O1>
343 Eigen::Matrix<S1,6,3,O1> se3ActionInverse(
const SE3Tpl<S1,O1> & m)
const 345 Eigen::Matrix<S1,6,3,O1> M;
346 M.template middleRows<3>(LINEAR) = m.rotation().transpose();
347 M.template middleRows<3>(ANGULAR).setZero();
352 template<
typename MotionDerived>
355 const typename MotionDerived::ConstAngularType w = m.angular();
358 skew(w,res.template middleRows<3>(LINEAR));
359 res.template middleRows<3>(ANGULAR).setZero();
368 template<
typename MotionDerived,
typename S2,
int O2>
369 inline typename MotionDerived::MotionPlain
373 return m2.motionAction(m1);
377 template<
typename S1,
int O1,
typename S2,
int O2>
378 inline Eigen::Matrix<S2,6,3,O2>
383 Eigen::Matrix<S2,6,3,O2> M;
384 alphaSkew(Y.mass(),Y.lever(),M.template middleRows<3>(Constraint::ANGULAR));
385 M.template middleRows<3>(Constraint::LINEAR).setZero();
386 M.template middleRows<3>(Constraint::LINEAR).diagonal().fill(Y.mass ());
392 template<
typename M6Like,
typename S2,
int O2>
394 operator*(
const Eigen::MatrixBase<M6Like> & Y,
398 return Y.derived().template middleCols<3>(Constraint::LINEAR);
401 template<
typename S1,
int O1>
403 {
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
405 template<
typename S1,
int O1,
typename MotionDerived>
407 {
typedef Eigen::Matrix<S1,6,3,O1> ReturnType; };
411 template<
typename _Scalar,
int _Options>
418 typedef _Scalar Scalar;
419 enum { Options = _Options };
428 typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
429 typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
430 typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
432 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
434 typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
435 typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
438 template<
typename Scalar,
int Options>
442 template<
typename Scalar,
int Options>
446 template<
typename _Scalar,
int _Options>
448 :
public JointDataBase< JointDataTranslationTpl<_Scalar,_Options> >
450 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
453 PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE(JointDerived);
454 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
467 : M(Transformation_t::Vector3::Zero())
468 , v(Motion_t::Vector3::Zero())
471 , UDinv(UD_t::Zero())
474 static std::string classname() {
return std::string(
"JointDataTranslation"); }
475 std::string
shortname()
const {
return classname(); }
479 template<
typename _Scalar,
int _Options>
481 :
public JointModelBase< JointModelTranslationTpl<_Scalar,_Options> >
483 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
486 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(JointDerived);
492 using Base::setIndexes;
494 JointDataDerived
createData()
const {
return JointDataDerived(); }
496 template<
typename ConfigVector>
497 void calc(JointDataDerived & data,
498 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 500 data.M.translation() = this->jointConfigSelector(qs);
503 template<
typename ConfigVector,
typename TangentVector>
504 void calc(JointDataDerived & data,
505 const typename Eigen::MatrixBase<ConfigVector> & qs,
506 const typename Eigen::MatrixBase<TangentVector> & vs)
const 508 calc(data,qs.derived());
510 data.v.linear() = this->jointVelocitySelector(vs);
513 template<
typename Matrix6Like>
514 void calc_aba(JointDataDerived & data,
515 const Eigen::MatrixBase<Matrix6Like> & I,
516 const bool update_I)
const 518 data.U = I.template middleCols<3>(Inertia::LINEAR);
523 internal::PerformStYSInversion<Scalar>::run(data.U.template middleRows<3>(Inertia::LINEAR),data.Dinv);
525 data.UDinv.template middleRows<3>(Inertia::LINEAR).setIdentity();
526 data.UDinv.template middleRows<3>(Inertia::ANGULAR).noalias() = data.U.template middleRows<3>(Inertia::ANGULAR) * data.Dinv;
530 Matrix6Like & I_ = PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like,I);
531 I_.template block<3,3>(Inertia::ANGULAR,Inertia::ANGULAR)
532 -= data.UDinv.template middleRows<3>(Inertia::ANGULAR) * I_.template block<3,3>(Inertia::LINEAR, Inertia::ANGULAR);
533 I_.template middleCols<3>(Inertia::LINEAR).setZero();
534 I_.template block<3,3>(Inertia::LINEAR,Inertia::ANGULAR).setZero();
538 static std::string classname() {
return std::string(
"JointModelTranslation"); }
539 std::string
shortname()
const {
return classname(); }
542 template<
typename NewScalar>
555 #include <boost/type_traits.hpp> 559 template<
typename Scalar,
int Options>
561 :
public integral_constant<bool,true> {};
563 template<
typename Scalar,
int Options>
565 :
public integral_constant<bool,true> {};
567 template<
typename Scalar,
int Options>
569 :
public integral_constant<bool,true> {};
571 template<
typename Scalar,
int Options>
573 :
public integral_constant<bool,true> {};
576 #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)
.