6 #ifndef __pinocchio_joint_spherical_hpp__ 7 #define __pinocchio_joint_spherical_hpp__ 9 #include "pinocchio/macros.hpp" 10 #include "pinocchio/multibody/joint/joint-base.hpp" 11 #include "pinocchio/multibody/constraint.hpp" 12 #include "pinocchio/math/sincos.hpp" 13 #include "pinocchio/spatial/inertia.hpp" 14 #include "pinocchio/spatial/skew.hpp" 22 template<
typename Scalar,
int Options>
28 template<
typename Scalar,
int Options,
typename MotionDerived>
34 template<
typename _Scalar,
int _Options>
39 typedef Eigen::Matrix<Scalar,3,1,Options>
Vector3;
40 typedef Eigen::Matrix<Scalar,6,1,Options>
Vector6;
41 typedef Eigen::Matrix<Scalar,6,6,Options>
Matrix6;
57 template<
typename _Scalar,
int _Options>
59 :
MotionBase< MotionSphericalTpl<_Scalar,_Options> >
61 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
67 template<
typename Vector3Like>
72 Vector3 & operator() () {
return m_w; }
73 const Vector3 & operator() ()
const {
return m_w; }
75 inline PlainReturnType
plain()
const 77 return PlainReturnType(PlainReturnType::Vector3::Zero(), m_w);
80 template<
typename MotionDerived>
86 template<
typename Derived>
100 return m_w == other.
m_w;
103 template<
typename MotionDerived>
109 template<
typename S2,
int O2,
typename D2>
119 template<
typename S2,
int O2>
123 se3Action_impl(m,res);
127 template<
typename S2,
int O2,
typename D2>
140 template<
typename S2,
int O2>
144 se3ActionInverse_impl(m,res);
148 template<
typename M1,
typename M2>
158 template<
typename M1>
166 const Vector3 &
angular()
const {
return m_w; }
174 template<
typename S1,
int O1,
typename MotionDerived>
175 inline typename MotionDerived::MotionPlain
183 template<
typename _Scalar,
int _Options>
199 template<
typename _Scalar,
int _Options>
201 :
public ConstraintBase< ConstraintSphericalTpl<_Scalar,_Options> >
203 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
213 template<
typename Vector3Like>
214 JointMotion
__mult__(
const Eigen::MatrixBase<Vector3Like> &
w)
const 216 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3);
217 return JointMotion(w);
222 template<
typename Derived>
228 template<
typename MatrixDerived>
230 operator*(
const Eigen::MatrixBase<MatrixDerived> & F)
const 233 return F.derived().template middleRows<3>(Inertia::ANGULAR);
242 S.template block <3,3>(LINEAR,0).setZero();
243 S.template block <3,3>(ANGULAR,0).setIdentity();
247 template<
typename S1,
int O1>
250 Eigen::Matrix<S1,6,3,O1> X_subspace;
252 X_subspace.template middleRows<3>(ANGULAR) = m.
rotation();
257 template<
typename S1,
int O1>
260 Eigen::Matrix<S1,6,3,O1> X_subspace;
265 X_subspace.template middleRows<3>(LINEAR).noalias()
266 = m.
rotation().transpose() * X_subspace.template middleRows<3>(ANGULAR);
267 X_subspace.template middleRows<3>(ANGULAR) = m.
rotation().transpose();
272 template<
typename MotionDerived>
275 const typename MotionDerived::ConstLinearType
v = m.
linear();
276 const typename MotionDerived::ConstAngularType
w = m.
angular();
279 skew(v,res.template middleRows<3>(LINEAR));
280 skew(w,res.template middleRows<3>(ANGULAR));
289 template<
typename MotionDerived,
typename S2,
int O2>
290 inline typename MotionDerived::MotionPlain
298 template<
typename S1,
int O1,
typename S2,
int O2>
299 inline Eigen::Matrix<S2,6,3,O2>
305 Eigen::Matrix<S2,6,3,O2>
M;
308 M.template block<3,3>(Inertia::ANGULAR,0) = (Y.
inertia() -
typename Symmetric3::AlphaSkewSquare(Y.
mass(), Y.
lever())).matrix();
313 template<
typename M6Like,
typename S2,
int O2>
319 return Y.
derived().template middleCols<3>(Constraint::ANGULAR);
322 template<
typename S1,
int O1>
326 template<
typename S1,
int O1,
typename MotionDerived>
332 template<
typename _Scalar,
int _Options>
349 typedef Eigen::Matrix<Scalar,6,NV,Options>
U_t;
350 typedef Eigen::Matrix<Scalar,NV,NV,Options>
D_t;
351 typedef Eigen::Matrix<Scalar,6,NV,Options>
UD_t;
359 template<
typename Scalar,
int Options>
363 template<
typename Scalar,
int Options>
367 template<
typename _Scalar,
int _Options>
370 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
387 : M(Transformation_t::Identity())
388 , v(Motion_t::Vector3::Zero())
391 , UDinv(UD_t::Zero())
394 static std::string
classname() {
return std::string(
"JointDataSpherical"); }
400 template<
typename _Scalar,
int _Options>
402 :
public JointModelBase< JointModelSphericalTpl<_Scalar,_Options> >
404 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
415 JointDataDerived
createData()
const {
return JointDataDerived(); }
417 template<
typename ConfigVectorLike>
418 inline void forwardKinematics(Transformation_t & M,
const Eigen::MatrixBase<ConfigVectorLike> & q_joint)
const 421 EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(ConfigVector_t,ConfigVectorLike);
422 typedef typename Eigen::Quaternion<Scalar,PINOCCHIO_EIGEN_PLAIN_TYPE(ConfigVectorLike)::Options> Quaternion;
423 typedef Eigen::Map<const Quaternion> ConstQuaternionMap;
425 ConstQuaternionMap
quat(q_joint.derived().data());
427 assert(math::fabs(static_cast<Scalar>(
quat.coeffs().squaredNorm()-1)) <= 1e-4);
429 M.rotation(
quat.matrix());
430 M.translation().setZero();
433 template<
typename QuaternionDerived>
434 void calc(JointDataDerived & data,
435 const typename Eigen::QuaternionBase<QuaternionDerived> & quat)
const 437 data.M.rotation(quat.matrix());
440 template<
typename ConfigVector>
442 void calc(JointDataDerived & data,
443 const typename Eigen::PlainObjectBase<ConfigVector> & qs)
const 445 typedef typename Eigen::Quaternion<typename ConfigVector::Scalar,ConfigVector::Options> Quaternion;
446 typedef Eigen::Map<const Quaternion> ConstQuaternionMap;
448 ConstQuaternionMap
quat(qs.template segment<NQ>(
idx_q()).data());
452 template<
typename ConfigVector>
454 void calc(JointDataDerived & data,
455 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 457 typedef typename Eigen::Quaternion<Scalar,Options> Quaternion;
459 const Quaternion
quat(qs.template segment<NQ>(
idx_q()));
463 template<
typename ConfigVector,
typename TangentVector>
464 void calc(JointDataDerived & data,
465 const typename Eigen::MatrixBase<ConfigVector> & qs,
466 const typename Eigen::MatrixBase<TangentVector> & vs)
const 468 calc(data,qs.derived());
470 data.v.angular() = vs.template segment<NV>(
idx_v());
473 template<
typename Matrix6Like>
475 const Eigen::MatrixBase<Matrix6Like> & I,
476 const bool update_I)
const 478 data.U = I.template block<6,3>(0,Inertia::ANGULAR);
485 data.UDinv.template middleRows<3>(Inertia::ANGULAR).setIdentity();
486 data.UDinv.template middleRows<3>(Inertia::LINEAR).noalias() = data.U.template block<3,3>(Inertia::LINEAR, 0) * data.Dinv;
491 I_.template block<3,3>(Inertia::LINEAR,Inertia::LINEAR)
492 -= data.UDinv.template middleRows<3>(Inertia::LINEAR) * I_.template block<3,3> (Inertia::ANGULAR, Inertia::LINEAR);
493 I_.template block<6,3>(0,Inertia::ANGULAR).setZero();
494 I_.template block<3,3>(Inertia::ANGULAR,Inertia::LINEAR).setZero();
498 static std::string
classname() {
return std::string(
"JointModelSpherical"); }
502 template<
typename NewScalar>
515 #include <boost/type_traits.hpp> 519 template<
typename Scalar,
int Options>
521 :
public integral_constant<bool,true> {};
523 template<
typename Scalar,
int Options>
525 :
public integral_constant<bool,true> {};
527 template<
typename Scalar,
int Options>
529 :
public integral_constant<bool,true> {};
531 template<
typename Scalar,
int Options>
533 :
public integral_constant<bool,true> {};
536 #endif // ifndef __pinocchio_joint_spherical_hpp__ JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
Eigen::Matrix< S1, 6, 3, O1 > ReturnType
InertiaTpl< double, 0 > Inertia
void setTo(MotionDense< Derived > &other) const
void calc(JointDataDerived &data, const typename Eigen::QuaternionBase< QuaternionDerived > &quat) const
EIGEN_DONT_INLINE void calc(JointDataDerived &data, const typename Eigen::PlainObjectBase< ConfigVector > &qs) const
std::string shortname() const
MotionSphericalTpl< Scalar, Options > JointMotion
JointModelSphericalTpl< NewScalar, Options > cast() const
Eigen::Matrix< Scalar, 6, 1, Options > Vector6
int idx_q(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxQVisitor to get the index in the full model configuration space...
Eigen::Matrix< Scalar, NV, 1, Options > TangentVector_t
std::string shortname() const
MotionTpl< Scalar, Options > ReturnType
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...
MotionSphericalTpl(const Eigen::MatrixBase< Vector3Like > &w)
Eigen::Matrix< S1, 6, 3, O1 > ReturnType
JointModelBase< JointModelSphericalTpl > Base
Eigen::Matrix< Scalar, 6, 3, Options > DenseBase
Return type of the ation of a Motion onto an object of type D.
#define MOTION_TYPEDEF_TPL(Derived)
PINOCCHIO_EIGEN_REF_CONST_TYPE(Matrix6Like) operator*(const Eigen
bool isEqual(const ConstraintSphericalTpl &) const
EIGEN_DONT_INLINE void calc(JointDataDerived &data, const typename Eigen::MatrixBase< ConfigVector > &qs) const
const Vector3 & angular() const
JointIndex id(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdVisitor to get the index of the joint in the kinematic chain...
#define PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
JointMotion __mult__(const Eigen::MatrixBase< Vector3Like > &w) const
Eigen::Matrix< Scalar, 6, NV, Options > U_t
static std::string classname()
PlainReturnType plain() const
ConstAngularType angular() const
Return the angular part of the force vector.
void calc_aba(JointDataDerived &data, const Eigen::MatrixBase< Matrix6Like > &I, const bool update_I) const
void forwardKinematics(Transformation_t &M, const Eigen::MatrixBase< ConfigVectorLike > &q_joint) const
Eigen::Matrix< Scalar, NV, NV, Options > D_t
JointModelSphericalTpl< Scalar, Options > JointModelDerived
#define PINOCCHIO_EIGEN_CONST_CAST(TYPE, OBJ)
Macro for an automatic const_cast.
JointSphericalTpl< Scalar, Options > JointDerived
MotionDerived::MotionPlain operator+(const MotionPlanarTpl< Scalar, Options > &m1, const MotionDense< MotionDerived > &m2)
MotionPlain motionAction(const MotionDense< M1 > &v) const
MotionPlain se3ActionInverse_impl(const SE3Tpl< S2, O2 > &m) const
Eigen::Matrix< S1, 6, 3, O1 > se3ActionInverse(const SE3Tpl< S1, O1 > &m) const
#define PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
MotionSphericalTpl __plus__(const MotionSphericalTpl &other) const
const Symmetric3 & inertia() const
const Vector3 & lever() const
bool isEqual_impl(const MotionSphericalTpl &other) const
DenseBase MatrixReturnType
const SizeDepType< 3 >::RowsReturn< MatrixDerived >::ConstType operator*(const Eigen::MatrixBase< MatrixDerived > &F) const
ConstLinearType linear() const
Eigen::Matrix< Scalar, 6, NV, Options > UD_t
void cross(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3xIn > &Min, const Eigen::MatrixBase< Matrix3xOut > &Mout)
Applies the cross product onto the columns of M.
#define PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE(Joint)
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
MotionSphericalTpl< double > MotionSpherical
MotionPlain se3Action_impl(const SE3Tpl< S2, O2 > &m) const
DenseBase motionAction(const MotionDense< MotionDerived > &m) const
const DenseBase ConstMatrixReturnType
static void cross(const Eigen::MatrixBase< V3_in > &vin, const Eigen::MatrixBase< V3_out > &vout)
ConstLinearRef translation() const
MotionTpl< Scalar, Options > ReturnType
PINOCCHIO_JOINT_CAST_TYPE_SPECIALIZATION(JointModelFreeFlyerTpl)
TransposeConst transpose() const
PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE typedef Eigen::Matrix< Scalar, NQ, 1, Options > ConfigVector_t
#define PINOCCHIO_EIGEN_REF_TYPE(D)
Eigen::Matrix< Scalar, 6, 6, Options > Matrix6
PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR Constraint_t S
Main pinocchio namespace.
MotionSphericalTpl< Scalar, Options > Motion_t
void setIndexes(JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointIndex id, int q, int v)
Visit a JointModelTpl through JointSetIndexesVisitor to set the indexes of the joint in the kinematic...
Eigen::Matrix< Scalar, 3, 1, Options > JointForce
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 ( )
JointDataDerived createData() const
Common traits structure to fully define base classes for CRTP.
Symmetric3Tpl< double, 0 > Symmetric3
bool isEqual_impl(const MotionDense< MotionDerived > &other) const
void calc(JointDataDerived &data, const typename Eigen::MatrixBase< ConfigVector > &qs, const typename Eigen::MatrixBase< TangentVector > &vs) const
void motionAction(const MotionDense< M1 > &v, MotionDense< M2 > &mout) const
JointDataSphericalTpl< Scalar, Options > JointDataDerived
const Vector3 ConstAngularType
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...
DenseBase matrix_impl() const
#define PINOCCHIO_CONSTRAINT_TYPEDEF_TPL(DERIVED)
const Vector3 ConstLinearType
ConstraintSphericalTpl< Scalar, Options > Constraint_t
ConstAngularType angular() const
static void motionAction(const MotionDense< MotionDerived > &v, const Eigen::MatrixBase< Mat > &iF, Eigen::MatrixBase< MatRet > const &jF)
Action of a motion on a set of forces, represented by a 6xN matrix whose each column represent a spat...
Eigen::Matrix< S1, 6, 3, O1 > se3Action(const SE3Tpl< S1, O1 > &m) const
void se3Action_impl(const SE3Tpl< S2, O2 > &m, MotionDense< D2 > &v) const
JointSphericalTpl< Scalar, Options > JointDerived
MotionDerived::MotionPlain operator^(const MotionDense< MotionDerived > &m1, const MotionPlanarTpl< S2, O2 > &m2)
static std::string classname()
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Derived & derived()
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef JointSphericalTpl< _Scalar, _Options > JointDerived
ConstAngularRef rotation() const
SE3Tpl< Scalar, Options > Transformation_t
MultiplicationOp< InertiaTpl< Scalar, Options >, ConstraintDerived >::ReturnType operator*(const InertiaTpl< Scalar, Options > &Y, const ConstraintBase< ConstraintDerived > &constraint)
.
void se3ActionInverse_impl(const SE3Tpl< S2, O2 > &m, MotionDense< D2 > &v) const
MotionZeroTpl< Scalar, Options > Bias_t
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef JointSphericalTpl< _Scalar, _Options > JointDerived
void addTo(MotionDense< MotionDerived > &other) const
#define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint)