6 #ifndef __pinocchio_joint_revolute_hpp__ 7 #define __pinocchio_joint_revolute_hpp__ 9 #include "pinocchio/math/sincos.hpp" 10 #include "pinocchio/spatial/inertia.hpp" 11 #include "pinocchio/multibody/constraint.hpp" 12 #include "pinocchio/multibody/joint/joint-base.hpp" 13 #include "pinocchio/spatial/spatial-axis.hpp" 14 #include "pinocchio/utils/axis-label.hpp" 21 template<
typename Scalar,
int Options,
int axis>
27 template<
typename Scalar,
int Options,
int axis,
typename MotionDerived>
33 template<
typename _Scalar,
int _Options,
int axis>
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;
58 template<
typename _Scalar,
int _Options,
int _axis>
69 typedef Eigen::Matrix<Scalar,3,1,Options>
Vector3;
70 typedef Eigen::Matrix<Scalar,3,3,Options>
Matrix3;
75 typedef typename Vector3::ConstantReturnType
LinearRef;
81 template<
typename Scalar,
int Options,
int axis>
85 template<
typename _Scalar,
int _Options,
int axis>
88 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
93 : m_sin(sin), m_cos(cos)
98 PlainType
res(PlainType::Identity());
99 _setRotation (res.rotation());
103 operator PlainType()
const {
return plain(); }
105 template<
typename S2,
int O2>
115 res.rotation().col(0) = m.
rotation().col(0);
116 res.rotation().col(1).noalias() = m_cos * m.
rotation().col(1) + m_sin * m.
rotation().col(2);
117 res.rotation().col(2).noalias() = res.rotation().col(0).cross(res.rotation().col(1));
122 res.rotation().col(2).noalias() = m_cos * m.
rotation().col(2) + m_sin * m.
rotation().col(0);
123 res.rotation().col(1) = m.
rotation().col(1);
124 res.rotation().col(0).noalias() = res.rotation().col(1).cross(res.rotation().col(2));
129 res.rotation().col(0).noalias() = m_cos * m.
rotation().col(0) + m_sin * m.
rotation().col(1);
130 res.rotation().col(1).noalias() = res.rotation().col(2).cross(res.rotation().col(0));
131 res.rotation().col(2) = m.
rotation().col(2);
136 assert(
false &&
"must nerver happened");
150 template<
typename OtherScalar>
151 void setValues(
const OtherScalar & sin,
const OtherScalar & cos)
152 { m_sin = sin; m_cos = cos; }
154 LinearType
translation()
const {
return LinearType::PlainObject::Zero(3); };
156 AngularType m(AngularType::Identity(3));
163 return m_cos == other.
m_cos && m_sin == other.
m_sin;
175 rot.coeffRef(1,1) = m_cos; rot.coeffRef(1,2) = -m_sin;
176 rot.coeffRef(2,1) = m_sin; rot.coeffRef(2,2) = m_cos;
181 rot.coeffRef(0,0) = m_cos; rot.coeffRef(0,2) = m_sin;
182 rot.coeffRef(2,0) = -m_sin; rot.coeffRef(2,2) = m_cos;
187 rot.coeffRef(0,0) = m_cos; rot.coeffRef(0,1) = -m_sin;
188 rot.coeffRef(1,0) = m_sin; rot.coeffRef(1,1) = m_cos;
193 assert(
false &&
"must nerver happened");
200 template<
typename _Scalar,
int _Options,
int axis>
202 :
MotionBase< MotionRevoluteTpl<_Scalar,_Options,axis> >
204 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
214 template<
typename Vector1Like>
218 using namespace Eigen;
219 EIGEN_STATIC_ASSERT_SIZE_1x1(Vector1Like);
222 inline PlainReturnType
plain()
const {
return Axis() * m_w; }
224 template<
typename OtherScalar>
230 template<
typename MotionDerived>
234 for(Eigen::DenseIndex k = 0; k < 3; ++k)
238 template<
typename MotionDerived>
245 template<
typename S2,
int O2,
typename D2>
252 template<
typename S2,
int O2>
256 se3Action_impl(m,res);
260 template<
typename S2,
int O2,
typename D2>
272 template<
typename S2,
int O2>
276 se3ActionInverse_impl(m,res);
280 template<
typename M1,
typename M2>
285 CartesianAxis3::alphaCross(-m_w,v.
linear(),mout.
linear());
291 template<
typename M1>
304 return m_w == other.
m_w;
312 template<
typename S1,
int O1,
int axis,
typename MotionDerived>
313 typename MotionDerived::MotionPlain
317 typename MotionDerived::MotionPlain
res(m2);
322 template<
typename MotionDerived,
typename S2,
int O2,
int axis>
324 typename MotionDerived::MotionPlain
332 template<
typename Scalar,
int Options,
int axis>
336 template<
typename Scalar,
int Options,
int axis,
typename MotionDerived>
340 template<
typename Scalar,
int Options,
int axis,
typename ForceDerived>
344 template<
typename Scalar,
int Options,
int axis,
typename ForceSet>
346 {
typedef typename Eigen::MatrixBase<ForceSet>::ConstRowXpr
ReturnType; };
348 template<
typename _Scalar,
int _Options,
int axis>
364 template<
typename _Scalar,
int _Options,
int axis>
368 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
377 template<
typename Vector1Like>
378 JointMotion
__mult__(
const Eigen::MatrixBase<Vector1Like> &
v)
const 379 {
return JointMotion(v[0]); }
381 template<
typename S1,
int O1>
388 res.template segment<3>(ANGULAR) = m.
rotation().col(
axis);
392 template<
typename S1,
int O1>
400 res.template segment<3>(ANGULAR) = m.
rotation().transpose().col(
axis);
411 template<
typename ForceDerived>
417 template<
typename Derived>
422 return F.row(ANGULAR +
axis);
442 template<
typename MotionDerived>
457 template<
typename _Scalar,
int _Options,
int _axis>
469 template<
typename S1,
int O1,
typename S2,
int O2,
int axis>
478 template<
typename S1,
int O1,
typename S2,
int O2>
484 static inline ReturnType
run(
const Inertia & Y,
509 template<
typename S1,
int O1,
typename S2,
int O2>
515 static inline ReturnType
run(
const Inertia & Y,
540 template<
typename S1,
int O1,
typename S2,
int O2>
546 static inline ReturnType
run(
const Inertia & Y,
572 template<
typename M6Like,
typename S2,
int O2,
int axis>
581 template<
typename M6Like,
typename Scalar,
int Options,
int axis>
586 static inline ReturnType
run(
const Eigen::MatrixBase<M6Like> & Y,
589 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(M6Like,6,6);
590 return Y.col(Inertia::ANGULAR +
axis);
595 template<
typename _Scalar,
int _Options,
int axis>
612 typedef Eigen::Matrix<Scalar,6,NV,Options>
U_t;
613 typedef Eigen::Matrix<Scalar,NV,NV,Options>
D_t;
614 typedef Eigen::Matrix<Scalar,6,NV,Options>
UD_t;
622 template<
typename Scalar,
int Options,
int axis>
626 template<
typename Scalar,
int Options,
int axis>
630 template<
typename _Scalar,
int _Options,
int axis>
633 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
653 , UDinv(UD_t::Zero())
658 return std::string(
"JointDataR") + axisLabel<axis>();
664 template<
typename NewScalar,
typename Scalar,
int Options,
int axis>
670 template<
typename _Scalar,
int _Options,
int axis>
672 :
public JointModelBase< JointModelRevoluteTpl<_Scalar,_Options,axis> >
674 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
684 JointDataDerived
createData()
const {
return JointDataDerived(); }
688 template<
typename ConfigVector>
690 void calc(JointDataDerived & data,
691 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 695 const OtherScalar &
q = qs[
idx_q()];
696 OtherScalar ca,sa;
SINCOS(q,&sa,&ca);
697 data.M.setValues(sa,ca);
700 template<
typename ConfigVector,
typename TangentVector>
702 void calc(JointDataDerived & data,
703 const typename Eigen::MatrixBase<ConfigVector> & qs,
704 const typename Eigen::MatrixBase<TangentVector> & vs)
const 706 calc(data,qs.derived());
708 data.v.angularRate() =
static_cast<Scalar>(vs[
idx_v()]);
711 template<
typename Matrix6Like>
713 const Eigen::MatrixBase<Matrix6Like> & I,
714 const bool update_I)
const 716 data.U = I.col(Inertia::ANGULAR +
axis);
717 data.Dinv[0] =
Scalar(1)/I(Inertia::ANGULAR +
axis,Inertia::ANGULAR +
axis);
718 data.UDinv.noalias() = data.U * data.Dinv[0];
726 return std::string(
"JointModelR") + axisLabel<axis>();
731 template<
typename NewScalar>
756 #include <boost/type_traits.hpp> 760 template<
typename Scalar,
int Options,
int axis>
762 :
public integral_constant<bool,true> {};
764 template<
typename Scalar,
int Options,
int axis>
766 :
public integral_constant<bool,true> {};
768 template<
typename Scalar,
int Options,
int axis>
770 :
public integral_constant<bool,true> {};
772 template<
typename Scalar,
int Options,
int axis>
774 :
public integral_constant<bool,true> {};
777 #endif // ifndef __pinocchio_joint_revolute_hpp__ Eigen::Matrix< Scalar, 6, 1, Options > ReturnType
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
#define PINOCCHIO_SE3_TYPEDEF_TPL(Derived)
JointDataRevoluteTpl< Scalar, Options, axis > JointDataDerived
Forward declaration of the multiplication operation return type. Should be overloaded, otherwise it will procude a compilation error.
ConstraintRevoluteTpl< S2, O2, 2 > Constraint
const ConstraintRevoluteTpl & ref
JointRevoluteTpl< double, 0, 1 > JointRY
JointRevoluteTpl< Scalar, Options, axis > JointDerived
JointModelRevoluteTpl< NewScalar, Options, axis > type
static std::string classname()
static ReturnType run(const Eigen::MatrixBase< M6Like > &Y, const Constraint &)
TransformRevoluteTpl< Scalar, Options, axis > Transformation_t
int idx_q(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxQVisitor to get the index in the full model configuration space...
JointDataRevoluteTpl< double, 0, 0 > JointDataRX
MotionPlain motionAction(const MotionDense< M1 > &v) const
MotionZeroTpl< Scalar, Options > Bias_t
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...
MotionPlain se3ActionInverse_impl(const SE3Tpl< S2, O2 > &m) const
void se3ActionInverse_impl(const SE3Tpl< S2, O2 > &m, MotionDense< D2 > &v) const
InertiaTpl< S1, O1 > Inertia
Return type of the Constraint::Transpose * ForceSet operation.
static std::string classname()
Return type of the ation of a Motion onto an object of type D.
JointRevoluteTpl< Scalar, Options, axis > JointDerived
#define MOTION_TYPEDEF_TPL(Derived)
PINOCCHIO_EIGEN_REF_CONST_TYPE(Matrix6Like) operator*(const Eigen
JointModelRevoluteTpl< Scalar, Options, axis > JointModelDerived
Eigen::Matrix< Scalar, 6, NV, Options > U_t
MotionRevoluteTpl< Scalar, Options, axis > JointMotion
JointRevoluteTpl< double, 0, 2 > JointRZ
InertiaTpl< S1, O1 > Inertia
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
JointDataDerived createData() const
Axis::CartesianAxis3 CartesianAxis3
MotionAlgebraAction< OtherSpatialType, Derived >::ReturnType cross(const OtherSpatialType &d) const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef JointRevoluteTpl< _Scalar, _Options, axis > JointDerived
Eigen::Matrix< Scalar, 6, NV, Options > UD_t
bool isEqual(const ConstraintRevoluteTpl &) const
ConstAngularType angular() const
Return the angular part of the force vector.
static ReturnType run(const Inertia &Y, const Constraint &)
JointDataRevoluteTpl< double, 0, 2 > JointDataRZ
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
#define PINOCCHIO_EIGEN_CONST_CAST(TYPE, OBJ)
Macro for an automatic const_cast.
const Vector3 ConstAngularType
JointMotion __mult__(const Eigen::MatrixBase< Vector1Like > &v) const
MotionDerived::MotionPlain operator+(const MotionPlanarTpl< Scalar, Options > &m1, const MotionDense< MotionDerived > &m2)
Eigen::Matrix< S2, 6, 1, O2 > ReturnType
Eigen::Matrix< Scalar, 6, 6, Options > Matrix6
InertiaTpl< S1, O1 > Inertia
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef JointRevoluteTpl< _Scalar, _Options, axis > JointDerived
#define PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
MultiplicationOp< Inertia, Constraint >::ReturnType ReturnType
JointModelRevoluteTpl< double, 0, 1 > JointModelRY
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
const Symmetric3 & inertia() const
MultiplicationOp< Inertia, Constraint >::ReturnType ReturnType
const Vector3 & lever() const
MotionAlgebraAction< ConstraintRevoluteTpl, MotionDerived >::ReturnType motionAction(const MotionDense< MotionDerived > &m) const
Eigen::MatrixBase< ForceSet >::ConstRowXpr ReturnType
PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR Constraint_t S
DenseBase MatrixReturnType
JointDataRevoluteTpl< double, 0, 1 > JointDataRY
PlainReturnType plain() const
ConstLinearType linear() const
EIGEN_DONT_INLINE void calc(JointDataDerived &data, const typename Eigen::MatrixBase< ConfigVector > &qs, const typename Eigen::MatrixBase< TangentVector > &vs) const
#define PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE(Joint)
void calc_aba(JointDataDerived &data, const Eigen::MatrixBase< Matrix6Like > &I, const bool update_I) const
Eigen::Matrix< Scalar, 1, 1, Options > JointForce
ForceDense< ForceDerived >::ConstAngularType::template ConstFixedSegmentReturnType< 1 >::Type ReturnType
JointModelRevoluteTpl< double, 0, 2 > JointModelRZ
ConstraintForceOp< ConstraintRevoluteTpl, ForceDerived >::ReturnType operator*(const ForceDense< ForceDerived > &f) const
EIGEN_DONT_INLINE void calc(JointDataDerived &data, const typename Eigen::MatrixBase< ConfigVector > &qs) const
const Scalar & angularRate() const
ConstraintForceSetOp< ConstraintRevoluteTpl, Derived >::ReturnType operator*(const Eigen::MatrixBase< Derived > &F) const
[CRBA] MatrixBase operator* (Constraint::Transpose S, ForceSet::Block)
TransposeConst transpose() const
MultiplicationOp< Eigen::MatrixBase< M6Like >, Constraint >::ReturnType ReturnType
ConstLinearRef translation() const
MotionTpl< Scalar, Options > ReturnType
static ReturnType run(const Inertia &Y, const Constraint &)
bool isEqual_impl(const MotionRevoluteTpl &other) const
Eigen::Matrix< Scalar, NV, 1, Options > TangentVector_t
MotionRevoluteTpl< Scalar, Options, axis > Motion_t
void SINCOS(const S1 &a, S2 *sa, S3 *ca)
Computes sin/cos values of a given input scalar.
SpatialAxis< ANGULAR+axis > Axis
const Vector3 ConstLinearType
Eigen::Matrix< Scalar, 6, 1, Options > DenseBase
std::string shortname() const
SpatialAxis< axis+ANGULAR > Axis
Eigen::Matrix< Scalar, 6, 1, Options > ReturnType
PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE typedef Eigen::Matrix< Scalar, NQ, 1, Options > ConfigVector_t
EIGEN_STRONG_INLINE void motionAction(const MotionDense< M1 > &v, MotionDense< M2 > &mout) const
SE3GroupAction< ConstraintRevoluteTpl >::ReturnType se3Action(const SE3Tpl< S1, O1 > &m) const
ConstraintRevoluteTpl< S2, O2, 0 > Constraint
#define PINOCCHIO_EIGEN_REF_TYPE(D)
void setTo(MotionDense< MotionDerived > &m) const
MultiplicationOp< Inertia, Constraint >::ReturnType ReturnType
const DenseBase ConstMatrixReturnType
Main pinocchio namespace.
ReturnTypeNotDefined ReturnType
Base class for rigid transformation.
JointModelRevoluteTpl< NewScalar, Options, axis > cast() const
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...
MotionRevoluteTpl(const Eigen::MatrixBase< Vector1Like > &v)
Common traits structure to fully define base classes for CRTP.
Symmetric3Tpl< double, 0 > Symmetric3
void se3Action_impl(const SE3Tpl< S2, O2 > &m, MotionDense< D2 > &v) const
ConstraintRevoluteTpl< S2, O2, 1 > Constraint
SE3GroupAction< ConstraintRevoluteTpl >::ReturnType se3ActionInverse(const SE3Tpl< S1, O1 > &m) const
#define PINOCCHIO_CONSTRAINT_TYPEDEF_TPL(DERIVED)
ConstraintRevoluteTpl< Scalar, Options, axis > Constraint
M6Like::ConstColXpr ReturnType
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...
std::string shortname() const
Type of the cast of a class C templated by Scalar and Options, to a new NewScalar type...
MotionDerived::MotionPlain operator^(const MotionDense< MotionDerived > &m1, const MotionPlanarTpl< S2, O2 > &m2)
void addTo(MotionDense< MotionDerived > &v) const
static ReturnType run(const Inertia &Y, const Constraint &)
JointRevoluteTpl< double, 0, 0 > JointRX
Return type of the Constraint::Transpose * Force operation.
Eigen::Matrix< Scalar, NV, NV, Options > D_t
MotionRevoluteTpl __mult__(const OtherScalar &alpha) const
JointModelRevoluteTpl< double, 0, 0 > JointModelRX
Eigen::Matrix< Scalar, 6, 1, Options > Vector6
MatrixDerived plain(const Eigen::PlainObjectBase< MatrixDerived > &m)
ConstAngularRef rotation() const
ReturnTypeNotDefined ReturnType
JointModelBase< JointModelRevoluteTpl > Base
MotionPlain se3Action_impl(const SE3Tpl< S2, O2 > &m) const
ConstraintRevoluteTpl< Scalar, Options, axis > Constraint_t
DenseBase matrix_impl() const
MotionRevoluteTpl(const Scalar &w)
TransposeConst(const ConstraintRevoluteTpl &ref)
MotionTpl< Scalar, Options > ReturnType
#define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint)