6 #ifndef __pinocchio_multibody_joint_translation_hpp__
7 #define __pinocchio_multibody_joint_translation_hpp__
9 #include "pinocchio/macros.hpp"
10 #include "pinocchio/multibody/joint/joint-base.hpp"
11 #include "pinocchio/multibody/joint-motion-subspace.hpp"
12 #include "pinocchio/spatial/inertia.hpp"
13 #include "pinocchio/spatial/skew.hpp"
18 template<
typename Scalar,
int Options = context::Options>
19 struct MotionTranslationTpl;
20 typedef MotionTranslationTpl<context::Scalar> MotionTranslation;
22 template<
typename Scalar,
int Options>
28 template<
typename Scalar,
int Options,
typename MotionDerived>
34 template<
typename _Scalar,
int _Options>
37 typedef _Scalar Scalar;
42 typedef Eigen::Matrix<Scalar, 3, 1, Options> Vector3;
43 typedef Eigen::Matrix<Scalar, 6, 1, Options> Vector6;
44 typedef Eigen::Matrix<Scalar, 4, 4, Options> Matrix4;
45 typedef Eigen::Matrix<Scalar, 6, 6, Options> Matrix6;
46 typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6) ToVectorConstReturnType;
47 typedef typename PINOCCHIO_EIGEN_REF_TYPE(Vector6) ToVectorReturnType;
48 typedef Vector3 AngularType;
49 typedef Vector3 LinearType;
50 typedef const Vector3 ConstAngularType;
51 typedef const Vector3 ConstLinearType;
52 typedef Matrix6 ActionMatrixType;
53 typedef Matrix4 HomogeneousMatrixType;
63 template<
typename _Scalar,
int _Options>
66 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
74 template<
typename Vector3Like>
85 Vector3 & operator()()
89 const Vector3 & operator()()
const
94 inline PlainReturnType plain()
const
96 return PlainReturnType(m_v, PlainReturnType::Vector3::Zero());
101 return internal::comparison_eq(m_v, other.m_v);
110 template<
typename Derived>
113 other.linear() += m_v;
116 template<
typename Derived>
119 other.linear() = m_v;
120 other.angular().setZero();
123 template<
typename S2,
int O2,
typename D2>
126 v.angular().setZero();
127 v.linear().noalias() = m.rotation() * m_v;
130 template<
typename S2,
int O2>
134 se3Action_impl(m, res);
138 template<
typename S2,
int O2,
typename D2>
142 v.linear().noalias() = m.rotation().transpose() * m_v;
145 v.angular().setZero();
148 template<
typename S2,
int O2>
152 se3ActionInverse_impl(m, res);
156 template<
typename M1,
typename M2>
160 mout.linear().noalias() = v.angular().cross(m_v);
163 mout.angular().setZero();
166 template<
typename M1>
170 motionAction(v, res);
174 const Vector3 & linear()
const
188 template<
typename S1,
int O1,
typename MotionDerived>
189 inline typename MotionDerived::MotionPlain
192 return typename MotionDerived::MotionPlain(m2.linear() + m1.linear(), m2.angular());
195 template<
typename Scalar,
int Options>
196 struct TransformTranslationTpl;
198 template<
typename _Scalar,
int _Options>
207 typedef _Scalar Scalar;
209 typedef Eigen::Matrix<Scalar, 3, 1, Options> Vector3;
210 typedef Eigen::Matrix<Scalar, 3, 3, Options> Matrix3;
211 typedef typename Matrix3::IdentityReturnType AngularType;
212 typedef AngularType AngularRef;
213 typedef AngularType ConstAngularRef;
214 typedef Vector3 LinearType;
215 typedef LinearType & LinearRef;
216 typedef const LinearType & ConstLinearRef;
221 template<
typename Scalar,
int Options>
227 template<
typename _Scalar,
int _Options>
230 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
238 template<
typename Vector3Like>
240 : m_translation(translation)
244 PlainType plain()
const
246 PlainType res(PlainType::Identity());
247 res.rotation().setIdentity();
248 res.translation() = translation();
253 operator PlainType()
const
258 template<
typename S2,
int O2>
259 typename SE3GroupAction<TransformTranslationTpl>::ReturnType
262 typedef typename SE3GroupAction<TransformTranslationTpl>::ReturnType ReturnType;
264 res.translation() += translation();
269 ConstLinearRef translation()
const
271 return m_translation;
273 LinearRef translation()
275 return m_translation;
278 AngularType rotation()
const
280 return AngularType(3, 3);
285 return internal::comparison_eq(m_translation, other.m_translation);
289 LinearType m_translation;
292 template<
typename Scalar,
int Options>
295 template<
typename _Scalar,
int _Options>
298 typedef _Scalar Scalar;
311 typedef Eigen::Matrix<Scalar, 3, 1, Options> JointForce;
312 typedef Eigen::Matrix<Scalar, 6, 3, Options> DenseBase;
313 typedef Eigen::Matrix<Scalar, 3, 3, Options> ReducedSquaredMatrix;
315 typedef DenseBase MatrixReturnType;
316 typedef const DenseBase ConstMatrixReturnType;
318 typedef typename ReducedSquaredMatrix::IdentityReturnType StDiagonalMatrixSOperationReturnType;
321 template<
typename _Scalar,
int _Options>
325 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
342 template<
typename Vector3Like>
343 JointMotion __mult__(
const Eigen::MatrixBase<Vector3Like> & v)
const
345 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like, 3);
346 return JointMotion(v);
362 template<
typename Derived>
369 template<
typename MatrixDerived>
371 operator*(
const Eigen::MatrixBase<MatrixDerived> & F)
const
373 assert(F.rows() == 6);
374 return F.derived().template middleRows<3>(LINEAR);
384 DenseBase matrix_impl()
const
387 S.template middleRows<3>(LINEAR).setIdentity();
388 S.template middleRows<3>(ANGULAR).setZero();
392 template<
typename S1,
int O1>
393 Eigen::Matrix<S1, 6, 3, O1> se3Action(
const SE3Tpl<S1, O1> & m)
const
395 Eigen::Matrix<S1, 6, 3, O1> M;
396 M.template middleRows<3>(LINEAR) = m.rotation();
397 M.template middleRows<3>(ANGULAR).setZero();
402 template<
typename S1,
int O1>
403 Eigen::Matrix<S1, 6, 3, O1> se3ActionInverse(
const SE3Tpl<S1, O1> & m)
const
405 Eigen::Matrix<S1, 6, 3, O1> M;
406 M.template middleRows<3>(LINEAR) = m.rotation().transpose();
407 M.template middleRows<3>(ANGULAR).setZero();
412 template<
typename MotionDerived>
413 DenseBase motionAction(
const MotionDense<MotionDerived> & m)
const
415 const typename MotionDerived::ConstAngularType w = m.angular();
418 skew(w, res.template middleRows<3>(LINEAR));
419 res.template middleRows<3>(ANGULAR).setZero();
424 bool isEqual(
const JointMotionSubspaceTranslationTpl &)
const
431 template<
typename MotionDerived,
typename S2,
int O2>
432 inline typename MotionDerived::MotionPlain
433 operator^(
const MotionDense<MotionDerived> & m1,
const MotionTranslationTpl<S2, O2> & m2)
435 return m2.motionAction(m1);
439 template<
typename S1,
int O1,
typename S2,
int O2>
440 inline Eigen::Matrix<S2, 6, 3, O2>
441 operator*(
const InertiaTpl<S1, O1> & Y,
const JointMotionSubspaceTranslationTpl<S2, O2> &)
443 typedef JointMotionSubspaceTranslationTpl<S2, O2> Constraint;
444 Eigen::Matrix<S2, 6, 3, O2> M;
445 alphaSkew(Y.mass(), Y.lever(), M.template middleRows<3>(Constraint::ANGULAR));
446 M.template middleRows<3>(Constraint::LINEAR).setZero();
447 M.template middleRows<3>(Constraint::LINEAR).diagonal().fill(Y.mass());
453 template<
typename M6Like,
typename S2,
int O2>
454 inline const typename SizeDepType<3>::ColsReturn<M6Like>::ConstType
455 operator*(
const Eigen::MatrixBase<M6Like> & Y,
const JointMotionSubspaceTranslationTpl<S2, O2> &)
457 typedef JointMotionSubspaceTranslationTpl<S2, O2> Constraint;
458 return Y.derived().template middleCols<3>(Constraint::LINEAR);
461 template<
typename S1,
int O1>
464 typedef Eigen::Matrix<S1, 6, 3, O1> ReturnType;
467 template<
typename S1,
int O1,
typename MotionDerived>
470 typedef Eigen::Matrix<S1, 6, 3, O1> ReturnType;
473 template<
typename Scalar,
int Options>
476 template<
typename _Scalar,
int _Options>
484 typedef _Scalar Scalar;
497 typedef Eigen::Matrix<Scalar, 6, NV, Options> U_t;
498 typedef Eigen::Matrix<Scalar, NV, NV, Options> D_t;
499 typedef Eigen::Matrix<Scalar, 6, NV, Options> UD_t;
501 typedef Eigen::Matrix<Scalar, NQ, 1, Options> ConfigVector_t;
502 typedef Eigen::Matrix<Scalar, NV, 1, Options> TangentVector_t;
504 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
507 template<
typename _Scalar,
int _Options>
511 typedef _Scalar Scalar;
514 template<
typename _Scalar,
int _Options>
518 typedef _Scalar Scalar;
521 template<
typename _Scalar,
int _Options>
524 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
528 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
530 ConfigVector_t joint_q;
531 TangentVector_t joint_v;
545 :
joint_q(ConfigVector_t::Zero())
546 ,
joint_v(TangentVector_t::Zero())
547 , M(Transformation_t::Vector3::Zero())
548 , v(Motion_t::Vector3::Zero())
551 , UDinv(UD_t::Zero())
556 static std::string classname()
558 return std::string(
"JointDataTranslation");
560 std::string shortname()
const
567 template<
typename _Scalar,
int _Options>
569 :
public JointModelBase<JointModelTranslationTpl<_Scalar, _Options>>
571 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
580 using Base::setIndexes;
582 JointDataDerived createData()
const
584 return JointDataDerived();
587 const std::vector<bool> hasConfigurationLimit()
const
589 return {
true,
true,
true};
592 const std::vector<bool> hasConfigurationLimitInTangent()
const
594 return {
true,
true,
true};
597 template<
typename ConfigVector>
598 void calc(JointDataDerived & data,
const typename Eigen::MatrixBase<ConfigVector> & qs)
const
600 data.joint_q = this->jointConfigSelector(qs);
601 data.M.translation() = data.joint_q;
604 template<
typename TangentVector>
606 calc(JointDataDerived & data,
const Blank,
const typename Eigen::MatrixBase<TangentVector> & vs)
609 data.joint_v = this->jointVelocitySelector(vs);
610 data.v.linear() = data.joint_v;
613 template<
typename ConfigVector,
typename TangentVector>
615 JointDataDerived & data,
616 const typename Eigen::MatrixBase<ConfigVector> & qs,
617 const typename Eigen::MatrixBase<TangentVector> & vs)
const
619 calc(data, qs.derived());
621 data.joint_v = this->jointVelocitySelector(vs);
622 data.v.linear() = data.joint_v;
625 template<
typename VectorLike,
typename Matrix6Like>
627 JointDataDerived & data,
628 const Eigen::MatrixBase<VectorLike> & armature,
629 const Eigen::MatrixBase<Matrix6Like> & I,
630 const bool update_I)
const
632 data.U = I.template middleCols<3>(Inertia::LINEAR);
634 data.StU = data.U.template middleRows<3>(Inertia::LINEAR);
635 data.StU.diagonal() += armature;
637 internal::PerformStYSInversion<Scalar>::run(data.StU, data.Dinv);
639 data.UDinv.noalias() = data.U * data.Dinv;
642 PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like, I).noalias() -= data.UDinv * data.U.transpose();
645 static std::string classname()
647 return std::string(
"JointModelTranslation");
649 std::string shortname()
const
655 template<
typename NewScalar>
660 res.setIndexes(
id(), idx_q(), idx_v());
668 #include <boost/type_traits.hpp>
672 template<
typename Scalar,
int Options>
674 :
public integral_constant<bool, true>
678 template<
typename Scalar,
int Options>
680 :
public integral_constant<bool, true>
684 template<
typename Scalar,
int Options>
686 :
public integral_constant<bool, true>
690 template<
typename Scalar,
int Options>
692 :
public integral_constant<bool, true>
ConstLinearType linear() const
Return the linear part of the force vector.
Main pinocchio namespace.
JointDataTpl< Scalar, Options, JointCollectionTpl >::TangentVector_t joint_v(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataVariant through JointConfigVisitor to get the joint velocity vector.
JointDataTpl< Scalar, Options, JointCollectionTpl >::ConfigVector_t joint_q(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataVariant through JointConfigVisitor to get the joint configuration vector.
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....
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...
JointModelTranslationTpl< NewScalar, Options > cast() const
Return type of the ation of a Motion onto an object of type D.
Base class for rigid transformation.
Common traits structure to fully define base classes for CRTP.