6 #ifndef __pinocchio_multibody_joint_model_base_hpp__ 7 #define __pinocchio_multibody_joint_model_base_hpp__ 9 #include "pinocchio/multibody/joint/joint-base.hpp" 10 #include "pinocchio/multibody/joint/joint-common-operations.hpp" 12 #include "pinocchio/math/matrix-block.hpp" 16 #define PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint,TYPENAME) \ 17 typedef Eigen::DenseIndex Index; \ 18 typedef TYPENAME traits<Joint>::Scalar Scalar; \ 19 typedef TYPENAME traits<Joint>::JointDataDerived JointDataDerived; \ 20 typedef TYPENAME traits<Joint>::JointModelDerived JointModelDerived; \ 21 typedef TYPENAME traits<Joint>::Constraint_t Constraint_t; \ 22 typedef TYPENAME traits<Joint>::Transformation_t Transformation_t; \ 23 typedef TYPENAME traits<Joint>::Motion_t Motion_t; \ 24 typedef TYPENAME traits<Joint>::Bias_t Bias_t; \ 25 typedef TYPENAME traits<Joint>::U_t U_t; \ 26 typedef TYPENAME traits<Joint>::D_t D_t; \ 27 typedef TYPENAME traits<Joint>::UD_t UD_t; \ 29 Options = traits<Joint>::Options, \ 30 NQ = traits<Joint>::NQ, \ 31 NV = traits<Joint>::NV \ 33 typedef TYPENAME traits<Joint>::ConfigVector_t ConfigVector_t; \ 34 typedef TYPENAME traits<Joint>::TangentVector_t TangentVector_t 38 #define PINOCCHIO_JOINT_TYPEDEF(Joint) PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint,PINOCCHIO_EMPTY_ARG) 39 #define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint) PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint,typename) 41 #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4) && (__GNUC_PATCHLEVEL__ == 2) 43 #define PINOCCHIO_JOINT_TYPEDEF(Joint) PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint,PINOCCHIO_EMPTY_ARG) 44 #define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint) PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint,typename) 48 #define PINOCCHIO_JOINT_TYPEDEF(Joint) PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint,typename) 49 #define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint) PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint,typename) 53 #define PINOCCHIO_JOINT_USE_INDEXES(Joint) \ 54 typedef JointModelBase<Joint> Base; \ 58 #define PINOCCHIO_JOINT_CAST_TYPE_SPECIALIZATION(JointModelTpl) \ 59 template<typename Scalar, int Options, typename NewScalar> \ 60 struct CastType< NewScalar, JointModelTpl<Scalar,Options> > \ 61 { typedef JointModelTpl<NewScalar,Options> type; } 66 template<
typename Derived>
69 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
74 JointModelDerived &
derived() {
return *
static_cast<Derived*
>(
this); }
75 const JointModelDerived &
derived()
const {
return *
static_cast<const Derived*
>(
this); }
79 template<
typename ConfigVectorType>
80 void calc(JointDataDerived & data,
81 const Eigen::MatrixBase<ConfigVectorType> & qs)
const 83 derived().calc(data,qs.derived());
86 template<
typename ConfigVectorType,
typename TangentVectorType>
87 void calc(JointDataDerived & data,
88 const Eigen::MatrixBase<ConfigVectorType> & qs,
89 const Eigen::MatrixBase<TangentVectorType> & vs)
const 91 derived().calc(data,qs.derived(),vs.derived());
94 template<
typename Matrix6Type>
96 const Eigen::MatrixBase<Matrix6Type> & I,
97 const bool update_I =
false)
const 118 {
derived().setIndexes_impl(
id, q, v); }
123 void disp(std::ostream & os)
const 128 <<
" index: " <<
id() << endl
129 <<
" index q: " <<
idx_q() << endl
130 <<
" index v: " <<
idx_v() << endl
131 <<
" nq: " <<
nq() << endl
132 <<
" nv: " <<
nv() << endl
136 friend std::ostream & operator << (std::ostream & os, const JointModelBase<Derived> & joint)
143 static std::string
classname() {
return Derived::classname(); }
145 template<
typename NewScalar>
147 {
return derived().template cast<NewScalar>(); }
149 template <
class OtherDerived>
153 template <
class OtherDerived>
157 template <
class OtherDerived>
166 template <
class OtherDerived>
169 return other.
id() ==
id()
179 {
return derived().jointConfigSelector_impl(a); }
190 {
return derived().jointConfigSelector_impl(a); }
202 {
return derived().jointVelocitySelector_impl(a.derived()); }
213 {
return derived().jointVelocitySelector_impl(a.derived()); }
225 {
return derived().jointCols_impl(A.derived()); }
236 {
return derived().jointCols_impl(A.derived()); }
248 {
return derived().jointRows_impl(A.derived()); }
259 {
return derived().jointRows_impl(A.derived()); }
271 {
return derived().jointBlock_impl(Mat.derived()); }
282 {
return derived().jointBlock_impl(Mat.derived()); }
325 #endif // ifndef __pinocchio_multibody_joint_model_base_hpp__ JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
SizeDepType< NV >::template ColsReturn< D >::Type jointCols_impl(Eigen::MatrixBase< D > &A) const
bool operator==(const JointModelBase< OtherDerived > &other) const
void calc(JointDataDerived &data, const Eigen::MatrixBase< ConfigVectorType > &qs) const
void setIndexes(JointIndex id, int q, int v)
JointIndex id_impl() const
SizeDepType< NV >::template RowsReturn< D >::Type jointRows(Eigen::MatrixBase< D > &A) const
SizeDepType< NQ >::template SegmentReturn< D >::ConstType jointConfigSelector_impl(const Eigen::MatrixBase< D > &a) const
SizeDepType< NV >::template ColsReturn< D >::ConstType jointCols_impl(const Eigen::MatrixBase< D > &A) const
SizeDepType< NV >::template RowsReturn< D >::ConstType jointRows(const Eigen::MatrixBase< D > &A) const
JointModelBase & operator=(const JointModelBase &clone)
AD< Scalar > max(const AD< Scalar > &x, const AD< Scalar > &y)
SizeDepType< NV >::template BlockReturn< D >::ConstType jointBlock_impl(const Eigen::MatrixBase< D > &Mat) const
SizeDepType< NV >::template SegmentReturn< D >::Type jointVelocitySelector_impl(Eigen::MatrixBase< D > &a) const
const JointModelDerived & derived() const
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
#define PINOCCHIO_EIGEN_CONST_CAST(TYPE, OBJ)
Macro for an automatic const_cast.
void setIndexes_impl(JointIndex id, int q, int v)
SizeDepType< NV >::template ColsReturn< D >::Type jointCols(Eigen::MatrixBase< D > &A) const
void disp(std::ostream &os) const
SizeDepType< NQ >::template SegmentReturn< D >::ConstType jointConfigSelector(const Eigen::MatrixBase< D > &a) const
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)
bool isEqual(const JointModelBase< Derived > &other) const
JointDataDerived createData() const
SizeDepType< NQ >::template SegmentReturn< D >::Type jointConfigSelector(Eigen::MatrixBase< D > &a) const
SizeDepType< NV >::template BlockReturn< D >::ConstType jointBlock(const Eigen::MatrixBase< D > &Mat) const
Returns a block of dimension nv()xnv() located at position idx_v(),idx_v() in the matrix Mat...
bool operator!=(const JointModelBase< OtherDerived > &other) const
SizeDepType< NV >::template SegmentReturn< D >::ConstType jointVelocitySelector_impl(const Eigen::MatrixBase< D > &a) const
SizeDepType< NV >::template SegmentReturn< D >::Type jointVelocitySelector(Eigen::MatrixBase< D > &a) const
bool isEqual(const JointModelBase< OtherDerived > &) const
JointModelDerived & derived()
SizeDepType< NV >::template RowsReturn< D >::ConstType jointRows_impl(const Eigen::MatrixBase< D > &A) const
CastType< NewScalar, Derived >::type cast() const
static ColsReturn< D >::ConstType middleCols(const Eigen::MatrixBase< D > &mat, typename Eigen::DenseBase< D >::Index start, typename Eigen::DenseBase< D >::Index size=NV)
static std::string classname()
Main pinocchio namespace.
SizeDepType< NV >::template ColsReturn< D >::ConstType jointCols(const Eigen::MatrixBase< D > &A) const
SizeDepType< NV >::template RowsReturn< D >::Type jointRows_impl(Eigen::MatrixBase< D > &A) const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef traits< Derived >::JointDerived JointDerived
PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(JointDerived)
JointModelBase(const JointModelBase &clone)
Common traits structure to fully define base classes for CRTP.
SizeDepType< NV >::template BlockReturn< D >::Type jointBlock_impl(Eigen::MatrixBase< D > &Mat) const
SizeDepType< NV >::template SegmentReturn< D >::ConstType jointVelocitySelector(const Eigen::MatrixBase< D > &a) const
static RowsReturn< D >::ConstType middleRows(const Eigen::MatrixBase< D > &mat, typename Eigen::DenseBase< D >::Index start, typename Eigen::DenseBase< D >::Index size=NV)
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...
void calc_aba(JointDataDerived &data, const Eigen::MatrixBase< Matrix6Type > &I, const bool update_I=false) const
SizeDepType< NV >::template BlockReturn< D >::Type jointBlock(Eigen::MatrixBase< D > &Mat) const
bool hasSameIndexes(const JointModelBase< OtherDerived > &other) const
std::string shortname() const
void calc(JointDataDerived &data, const Eigen::MatrixBase< ConfigVectorType > &qs, const Eigen::MatrixBase< TangentVectorType > &vs) const
SizeDepType< NQ >::template SegmentReturn< D >::Type jointConfigSelector_impl(Eigen::MatrixBase< D > &a) const