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; \
30 Options = traits<Joint>::Options, \
31 NQ = traits<Joint>::NQ, \
32 NV = traits<Joint>::NV \
34 typedef TYPENAME traits<Joint>::ConfigVector_t ConfigVector_t; \
35 typedef TYPENAME traits<Joint>::TangentVector_t TangentVector_t
39 #define PINOCCHIO_JOINT_TYPEDEF(Joint) \
40 PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint, PINOCCHIO_EMPTY_ARG)
41 #define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint) \
42 PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint, typename)
44 #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4) && (__GNUC_PATCHLEVEL__ == 2)
46 #define PINOCCHIO_JOINT_TYPEDEF(Joint) \
47 PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint, PINOCCHIO_EMPTY_ARG)
48 #define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint) \
49 PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint, typename)
53 #define PINOCCHIO_JOINT_TYPEDEF(Joint) PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint, typename)
54 #define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint) \
55 PINOCCHIO_JOINT_MODEL_TYPEDEF_GENERIC(Joint, typename)
59 #define PINOCCHIO_JOINT_USE_INDEXES(Joint) \
60 typedef JointModelBase<Joint> Base; \
64 #define PINOCCHIO_JOINT_CAST_TYPE_SPECIALIZATION(JointModelTpl) \
65 template<typename Scalar, int Options, typename NewScalar> \
66 struct CastType<NewScalar, JointModelTpl<Scalar, Options>> \
68 typedef JointModelTpl<NewScalar, Options> type; \
74 template<
typename Derived>
77 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
80 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(JointDerived);
82 JointModelDerived & derived()
84 return *
static_cast<Derived *
>(
this);
86 const JointModelDerived & derived()
const
88 return *
static_cast<const Derived *
>(
this);
91 JointDataDerived createData()
const
93 return derived().createData();
96 const std::vector<bool> hasConfigurationLimit()
const
98 return derived().hasConfigurationLimit();
101 const std::vector<bool> hasConfigurationLimitInTangent()
const
103 return derived().hasConfigurationLimitInTangent();
106 template<
typename ConfigVectorType>
107 void calc(JointDataDerived & data,
const Eigen::MatrixBase<ConfigVectorType> & qs)
const
109 derived().calc(data, qs.derived());
112 template<
typename TangentVectorType>
114 JointDataDerived & data,
115 const Blank not_used,
116 const Eigen::MatrixBase<TangentVectorType> & vs)
const
118 derived().calc(data, not_used, vs.derived());
121 template<
typename ConfigVectorType,
typename TangentVectorType>
123 JointDataDerived & data,
124 const Eigen::MatrixBase<ConfigVectorType> & qs,
125 const Eigen::MatrixBase<TangentVectorType> & vs)
const
127 derived().calc(data, qs.derived(), vs.derived());
130 template<
typename VectorLike,
typename Matrix6Like>
132 JointDataDerived & data,
133 const Eigen::MatrixBase<VectorLike> & armature,
134 const Eigen::MatrixBase<Matrix6Like> & I,
135 const bool update_I =
false)
const
138 data, armature.derived(), PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like, I), update_I);
143 return derived().nv_impl();
147 return derived().nq_impl();
162 return derived().idx_q_impl();
166 return derived().idx_v_impl();
168 JointIndex id()
const
170 return derived().id_impl();
173 int idx_q_impl()
const
177 int idx_v_impl()
const
181 JointIndex id_impl()
const
186 void setIndexes(JointIndex
id,
int q,
int v)
188 derived().setIndexes_impl(
id, q, v);
191 void setIndexes_impl(JointIndex
id,
int q,
int v)
197 void disp(std::ostream & os)
const
201 <<
" index: " <<
id() << endl
202 <<
" index q: " <<
idx_q() << endl
203 <<
" index v: " <<
idx_v() << endl
204 <<
" nq: " <<
nq() << endl
205 <<
" nv: " <<
nv() << endl;
214 std::string shortname()
const
216 return derived().shortname();
218 static std::string classname()
220 return Derived::classname();
223 template<
typename NewScalar>
226 return derived().template cast<NewScalar>();
229 template<
class OtherDerived>
232 return derived().isEqual(other.derived());
235 template<
class OtherDerived>
238 return !(internal::comparison_eq(derived(), other.derived()));
241 template<
class OtherDerived>
249 return derived().hasSameIndexes(other.derived());
252 template<
class OtherDerived>
255 return internal::comparison_eq(other.id(),
id())
256 && internal::comparison_eq(other.idx_q(), idx_q())
257 && internal::comparison_eq(other.idx_v(), idx_v());
264 jointConfigSelector(
const Eigen::MatrixBase<D> & a)
const
266 return derived().jointConfigSelector_impl(a);
271 jointConfigSelector_impl(
const Eigen::MatrixBase<D> & a)
const
279 jointConfigSelector(Eigen::MatrixBase<D> & a)
const
281 return derived().jointConfigSelector_impl(a);
286 jointConfigSelector_impl(Eigen::MatrixBase<D> & a)
const
295 jointVelocitySelector(
const Eigen::MatrixBase<D> & a)
const
297 return derived().jointVelocitySelector_impl(a.derived());
302 jointVelocitySelector_impl(
const Eigen::MatrixBase<D> & a)
const
310 jointVelocitySelector(Eigen::MatrixBase<D> & a)
const
312 return derived().jointVelocitySelector_impl(a.derived());
317 jointVelocitySelector_impl(Eigen::MatrixBase<D> & a)
const
326 jointCols(
const Eigen::MatrixBase<D> & A)
const
328 return derived().jointCols_impl(A.derived());
333 jointCols_impl(
const Eigen::MatrixBase<D> & A)
const
342 return derived().jointCols_impl(A.derived());
347 jointCols_impl(Eigen::MatrixBase<D> & A)
const
356 jointRows(
const Eigen::MatrixBase<D> & A)
const
358 return derived().jointRows_impl(A.derived());
363 jointRows_impl(
const Eigen::MatrixBase<D> & A)
const
372 return derived().jointRows_impl(A.derived());
377 jointRows_impl(Eigen::MatrixBase<D> & A)
const
389 return derived().jointBlock_impl(Mat.derived());
394 jointBlock_impl(
const Eigen::MatrixBase<D> & Mat)
const
401 typename SizeDepType<NV>::template BlockReturn<D>::Type
404 return derived().jointBlock_impl(Mat.derived());
408 typename SizeDepType<NV>::template BlockReturn<D>::Type
409 jointBlock_impl(Eigen::MatrixBase<D> & Mat)
const
411 return SizeDepType<NV>::block(Mat.derived(), idx_v(), idx_v(), nv(), nv());
419 : i_id(std::numeric_limits<JointIndex>::max())
Main pinocchio namespace.
JointIndex id(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdVisitor to get the index of the joint in the kinematic chain.
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...
int nv(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNvVisitor to get the dimension of the joint tangent space.
int nq(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNqVisitor to get the dimension of the joint configuration space.
std::string shortname(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointShortnameVisitor to get the shortname of the derived joint model.
int idx_q(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxQVisitor to get the index in the full model configuration space...
Type of the cast of a class C templated by Scalar and Options, to a new NewScalar type....
JointModelBase(const JointModelBase &clone)
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.
JointModelBase & operator=(const JointModelBase &clone)
Common traits structure to fully define base classes for CRTP.