5 #ifndef __pinocchio_multibody_joint_mimic_hpp__ 6 #define __pinocchio_multibody_joint_mimic_hpp__ 8 #include "pinocchio/macros.hpp" 9 #include "pinocchio/multibody/joint/joint-base.hpp" 16 template<
class Constra
int>
32 template<
class Constra
int>
36 template<
class Constra
int,
typename MotionDerived>
40 template<
class Constra
int,
typename ForceDerived>
47 typedef Eigen::Matrix<Scalar,IdealReturnType::RowsAtCompileTime,IdealReturnType::ColsAtCompileTime,Constraint::Options>
ReturnType;
50 template<
class Constra
int,
typename ForceSet>
56 typedef Eigen::Matrix<Scalar,Constraint::NV,ForceSet::ColsAtCompileTime,Constraint::Options | Eigen::RowMajor>
ReturnType;
59 template<
class Constra
int>
63 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
75 : m_scaling_factor(scaling_factor)
79 const Scalar & scaling_factor)
80 : m_constraint(constraint)
81 , m_scaling_factor(scaling_factor)
85 : m_constraint(other.m_constraint)
86 , m_scaling_factor(other.m_scaling_factor)
96 template<
typename VectorLike>
97 JointMotion
__mult__(
const Eigen::MatrixBase<VectorLike> &
v)
const 99 assert(v.size() ==
nv());
100 JointMotion jm = m_constraint *
v;
101 return jm * m_scaling_factor;
104 template<
typename S1,
int O1>
108 SE3ActionReturnType
res = m_constraint.se3Action(m);
109 return m_scaling_factor * res;
112 template<
typename S1,
int O1>
116 SE3ActionReturnType
res = m_constraint.se3ActionInverse(m);
117 return m_scaling_factor * res;
120 int nv_impl()
const {
return m_constraint.nv(); }
127 template<
typename Derived>
137 template<
typename Derived>
151 DenseBase S = m_scaling_factor * m_constraint.matrix();
155 template<
typename MotionDerived>
160 ReturnType
res = m_scaling_factor * m_constraint.motionAction(m);
167 inline const Constraint &
constraint()
const {
return m_constraint; }
182 template<
typename S1,
int O1,
typename _Constra
int>
197 template<
typename S1,
int O1,
typename _Constra
int>
204 static inline ReturnType
run(
const Inertia &
Y,
205 const Constraint & scaled_constraint)
212 template<
typename M6Like,
typename _Constra
int>
222 template<
typename M6Like,
typename _Constra
int>
228 static inline ReturnType
run(
const Eigen::MatrixBase<M6Like> &
Y,
229 const Constraint & scaled_constraint)
231 return scaled_constraint.
scaling() * (Y.derived() * scaled_constraint.
constraint());
240 template<
class Jo
int>
273 template<
class Jo
int>
277 template<
class Jo
int>
281 template<
class Jo
intData>
285 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
294 , m_q_transform(ConfigVector_t::Zero())
295 , m_v_transform(TangentVector_t::Zero())
304 : m_jdata_ref(jdata.derived())
306 , S(m_jdata_ref.S,scaling)
315 S = Constraint_t(m_jdata_ref.S,other.
m_scaling);
337 return std::string(
"JointDataMimic<") + m_jdata_ref.shortname() + std::string(
">");
344 TansformTypeConstRef
M_accessor()
const {
return m_jdata_ref.M; }
347 MotionTypeConstRef
v_accessor()
const {
return m_jdata_ref.v; }
350 BiasTypeConstRef
c_accessor()
const {
return m_jdata_ref.c; }
362 template<
class Jo
intModel>
394 template<
typename NewScalar,
typename Jo
intModel>
401 template<
class Jo
intModel>
405 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
425 : m_jmodel_ref(jmodel.derived())
430 Base &
base() {
return *
static_cast<Base*
>(
this); }
431 const Base &
base()
const {
return *
static_cast<const Base*
>(
this); }
436 inline int idx_q_impl()
const {
return m_jmodel_ref.idx_q(); }
437 inline int idx_v_impl()
const {
return m_jmodel_ref.idx_v(); }
442 Base::i_q = m_jmodel_ref.idx_q();
443 Base::i_v = m_jmodel_ref.idx_v();
448 return JointDataDerived(m_jmodel_ref.createData(),scaling());
453 return m_jmodel_ref.hasConfigurationLimit();
458 return m_jmodel_ref.hasConfigurationLimitInTangent();
461 template<
typename ConfigVector>
463 void calc(JointDataDerived & jdata,
464 const typename Eigen::MatrixBase<ConfigVector> &
qs)
const 469 m_scaling,m_offset,jdata.m_q_transform);
470 m_jmodel_ref.calc(jdata.m_jdata_ref,jdata.m_q_transform);
473 template<
typename ConfigVector,
typename TangentVector>
475 void calc(JointDataDerived & jdata,
476 const typename Eigen::MatrixBase<ConfigVector> &
qs,
477 const typename Eigen::MatrixBase<TangentVector> & vs)
const 482 m_scaling,m_offset,jdata.m_q_transform);
483 jdata.m_v_transform = m_scaling * vs.head(m_jmodel_ref.nv());
484 m_jmodel_ref.calc(jdata.m_jdata_ref,
486 jdata.m_v_transform);
489 template<
typename Matrix6Like>
491 const Eigen::MatrixBase<Matrix6Like> & I,
492 const bool update_I)
const 495 m_jmodel_ref.calc_aba(data.m_jdata_ref,
507 return std::string(
"JointModelMimic<") + m_jmodel_ref.shortname() + std::string(
">");
511 template<
typename NewScalar>
516 ReturnType
res(m_jmodel_ref.template cast<NewScalar>(),
517 (NewScalar)m_scaling,
518 (NewScalar)m_offset);
547 m_jmodel_ref.
idx_q(),
557 m_jmodel_ref.
idx_q(),
568 m_jmodel_ref.
idx_v(),
578 m_jmodel_ref.
idx_v(),
589 m_jmodel_ref.
idx_v(),
599 m_jmodel_ref.
idx_v(),
610 m_jmodel_ref.
idx_v(),
620 m_jmodel_ref.
idx_v(),
632 m_jmodel_ref.
nv(),m_jmodel_ref.
nv());
642 m_jmodel_ref.
nv(),m_jmodel_ref.
nv());
649 #endif // ifndef __pinocchio_multibody_joint_mimic_hpp__ JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
traits< Joint >::Motion_t Motion_t
int nv(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNvVisitor to get the dimension of the joint tangent space...
Forward declaration of the multiplication operation return type. Should be overloaded, otherwise it will procude a compilation error.
static std::string classname()
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef traits< JointModelMimic >::JointDerived JointDerived
JointModelBase< JointModelMimic > Base
SizeDepType< NV >::template BlockReturn< D >::ConstType jointBlock_impl(const Eigen::MatrixBase< D > &Mat) const
Returns a block of dimension nv()xnv() located at position idx_v(),idx_v() in the matrix Mat...
InertiaTpl< S1, O1 > Inertia
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, Constraint::NV, ForceSet::ColsAtCompileTime, Constraint::Options|Eigen::RowMajor > ReturnType
ConfigVector_t m_q_transform
Transform configuration vector.
SE3GroupAction< Constraint >::ReturnType SE3ActionReturnType
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...
SizeDepType< NV >::template RowsReturn< D >::ConstType jointRows_impl(const Eigen::MatrixBase< D > &A) const
traits< Joint >::UD_t UD_t
UDTypeConstRef UDinv_accessor() const
Return type of the Constraint::Transpose * ForceSet operation.
TansformTypeConstRef M_accessor() const
TangentVector_t m_v_transform
Transform velocity vector.
int nq(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNqVisitor to get the dimension of the joint configuration space...
traits< Joint >::Scalar Scalar
Return type of the ation of a Motion onto an object of type D.
Constraint::Scalar Scalar
MultiplicationOp< Eigen::MatrixBase< M6Like >, Constraint >::ReturnType ReturnType
ConstraintForceSetOp< Constraint, ForceSet >::ReturnType OriginalReturnType
const std::vector< bool > hasConfigurationLimitInTangent() const
ConfigVector_t & jointConfiguration()
JointModelMimic< JointModelNewType > type
Constraint::Scalar Scalar
DTypeConstRef Dinv_accessor() const
MotionAlgebraAction< ScaledConstraint, MotionDerived >::ReturnType motionAction(const MotionDense< MotionDerived > &m) const
const Base & base() const
TangentVector_t & jointVelocity()
JointIndex id(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdVisitor to get the index of the joint in the kinematic chain...
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef traits< JointDataMimic >::JointDerived JointDerived
CastType< NewScalar, JointModelMimic >::type cast() const
DenseBase matrix_impl() const
traits< Constraint >::ConstMatrixReturnType ConstMatrixReturnType
ScaledConstraint< _Constraint > Constraint
void setIndexes_impl(JointIndex id, int, int)
SizeDepType< NQ >::template SegmentReturn< D >::ConstType jointConfigSelector_impl(const Eigen::MatrixBase< D > &a) const
ScaledConstraint< typename traits< Joint >::Constraint_t > Constraint_t
CastType< NewScalar, JointModel >::type JointModelNewType
EIGEN_DONT_INLINE void calc(JointDataDerived &jdata, const typename Eigen::MatrixBase< ConfigVector > &qs, const typename Eigen::MatrixBase< TangentVector > &vs) const
JointMimic< typename traits< Joint >::JointDerived > JointDerived
PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE typedef traits< Joint >::ConfigVector_t ConfigVector_t
#define PINOCCHIO_EIGEN_CONST_CAST(TYPE, OBJ)
Macro for an automatic const_cast.
ConstraintForceOp< Constraint, ForceDerived >::ReturnType OriginalReturnType
std::string shortname() const
const JointData & jdata() const
JointDataMimic(const JointDataMimic &other)
UDTypeRef UDinv_accessor()
JointModelMimic< JointModelBase > JointModelDerived
static BlockReturn< D >::ConstType block(const Eigen::MatrixBase< D > &mat, typename Eigen::DenseBase< D >::Index row_id, typename Eigen::DenseBase< D >::Index col_id, typename Eigen::DenseBase< D >::Index row_size_block=NV, typename Eigen::DenseBase< D >::Index col_size_block=NV)
MultiplicationOp< Inertia, _Constraint >::ReturnType OriginalReturnType
SizeDepType< NV >::template RowsReturn< D >::Type jointRows_impl(Eigen::MatrixBase< D > &A) const
virtual bool isEqual(const CollisionGeometry &other) const=0
SizeDepType< NV >::template SegmentReturn< D >::Type jointVelocitySelector_impl(Eigen::MatrixBase< D > &a) const
#define PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
const Scalar & offset() const
static ReturnType run(const Inertia &Y, const Constraint &scaled_constraint)
SizeDepType< NV >::template ColsReturn< D >::ConstType jointCols_impl(const Eigen::MatrixBase< D > &A) const
JointMotion __mult__(const Eigen::MatrixBase< VectorLike > &v) const
traits< Joint >::JointModelDerived JointModelBase
const TangentVector_t & jointVelocity() const
ConstraintTypeRef S_accessor()
ScaledConstraint(const ScaledConstraint &other)
SizeDepType< NV >::template SegmentReturn< D >::ConstType jointVelocitySelector_impl(const Eigen::MatrixBase< D > &a) const
#define PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE(Joint)
SizeDepType< NQ >::template SegmentReturn< D >::Type jointConfigSelector_impl(Eigen::MatrixBase< D > &a) const
Constraint & constraint()
InertiaTpl< S1, O1 > Inertia
ConstraintForceSetOp< ScaledConstraint, Derived >::ReturnType operator*(const Eigen::MatrixBase< Derived > &F) const
[CRBA] MatrixBase operator* (Constraint::Transpose S, ForceSet::Block)
traits< Joint >::Bias_t Bias_t
MultiplicationOp< Inertia, Constraint >::ReturnType ReturnType
JointMimic< typename traits< Joint >::JointDerived > JointDerived
ScaledConstraint & operator=(const ScaledConstraint &other)
ConstraintForceOp< ScaledConstraint, Derived >::ReturnType operator*(const ForceDense< Derived > &f) const
traits< Joint >::JointDataDerived JointDataBase
MotionTypeRef v_accessor()
Eigen::Matrix< Scalar, IdealReturnType::RowsAtCompileTime, IdealReturnType::ColsAtCompileTime, Constraint::Options > ReturnType
TransposeConst transpose() const
JointDataMimic(const JointDataBase< JointData > &jdata, const Scalar &scaling)
traits< Constraint >::JointForce JointForce
ScaledConstraint(const Constraint &constraint, const Scalar &scaling_factor)
std::string shortname() const
static std::string classname()
MotionTypeConstRef v_accessor() const
void calc_aba(JointDataDerived &data, const Eigen::MatrixBase< Matrix6Like > &I, const bool update_I) const
MultiplicationOp< Inertia, _Constraint >::ReturnType OriginalReturnType
JointDataMimic< JointDataBase > JointDataDerived
const ConfigVector_t & jointConfiguration() const
OriginalReturnType ReturnType
static ReturnType run(const Eigen::MatrixBase< M6Like > &Y, const Constraint &scaled_constraint)
ConstraintTypeConstRef S_accessor() const
static ColsReturn< D >::ConstType middleCols(const Eigen::MatrixBase< D > &mat, typename Eigen::DenseBase< D >::Index start, typename Eigen::DenseBase< D >::Index size=NV)
bool isEqual(const JointDataMimic &other) const
SE3ActionReturnType se3Action(const SE3Tpl< S1, O1 > &m) const
Main pinocchio namespace.
ReturnTypeNotDefined ReturnType
JointDataMimic & operator=(const JointDataMimic &other)
ScalarMatrixProduct< Scalar, OriginalReturnType >::type IdealReturnType
static std::string classname()
traits< Constraint >::JointMotion JointMotion
SE3ActionReturnType se3ActionInverse(const SE3Tpl< S1, O1 > &m) const
traits< Constraint >::MatrixReturnType MatrixReturnType
traits< Joint >::TangentVector_t TangentVector_t
PINOCCHIO_EIGEN_PLAIN_TYPE(ConfigVectorType) integrate(const ModelTpl< Scalar
Integrate a configuration vector for the specified model for a tangent vector during one unit time...
ScaledConstraint< _Constraint > Constraint
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...
ScaledConstraint(const Scalar &scaling_factor)
EIGEN_DONT_INLINE void calc(JointDataDerived &jdata, const typename Eigen::MatrixBase< ConfigVector > &qs) const
bool isEqual(const ScaledConstraint &other) const
const ScaledConstraint & ref
UTypeConstRef U_accessor() const
Common traits structure to fully define base classes for CRTP.
ScalarMatrixProduct< Scalar, OriginalReturnType >::type IdealReturnType
traits< Joint >::Transformation_t Transformation_t
ScaledConstraint< _Constraint > Constraint
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_multiple_op< Scalar >, const Matrix > type
#define PINOCCHIO_CONSTRAINT_TYPEDEF_TPL(DERIVED)
static std::string classname()
MotionAlgebraAction< Constraint, MotionDerived >::ReturnType ReturnType
const JointModel & jmodel() const
static RowsReturn< D >::ConstType middleRows(const Eigen::MatrixBase< D > &mat, typename Eigen::DenseBase< D >::Index start, typename Eigen::DenseBase< D >::Index size=NV)
SizeDepType< NV >::template ColsReturn< D >::Type jointCols_impl(Eigen::MatrixBase< D > &A) const
JointModelMimic(const JointModelBase< JointModel > &jmodel, const Scalar &scaling, const Scalar &offset)
const Scalar & scaling() const
traits< Constraint >::DenseBase DenseBase
static SegmentReturn< D >::ConstType segment(const Eigen::MatrixBase< D > &mat, typename Eigen::DenseBase< D >::Index start, typename Eigen::DenseBase< D >::Index size=NV)
Type of the cast of a class C templated by Scalar and Options, to a new NewScalar type...
JointDataBase< JointDataMimic< JointData > > Base
TansformTypeRef M_accessor()
const Constraint & constraint() const
Constraint::Scalar Scalar
Return type of the Constraint::Transpose * Force operation.
const std::vector< bool > hasConfigurationLimit() const
TransposeConst(const ScaledConstraint &ref)
traits< Constraint >::Scalar Scalar
JointDataDerived createData() const
BiasTypeConstRef c_accessor() const
ReturnTypeNotDefined ReturnType
const Scalar & scaling() const
SizeDepType< NV >::template BlockReturn< D >::Type jointBlock_impl(Eigen::MatrixBase< D > &Mat) const
ConstraintBase< ScaledConstraint > Base
const Scalar & scaling() const
SE3GroupAction< Constraint >::ReturnType ReturnType
#define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint)