5 #ifndef __pinocchio_multibody_joint_generic_hpp__
6 #define __pinocchio_multibody_joint_generic_hpp__
8 #include "pinocchio/multibody/joint/joint-collection.hpp"
9 #include "pinocchio/multibody/joint/joint-composite.hpp"
10 #include "pinocchio/multibody/joint/joint-basic-visitors.hxx"
11 #include "pinocchio/container/aligned-vector.hpp"
13 #include <boost/mpl/contains.hpp>
20 int Options = context::Options,
21 template<
typename S,
int O>
class JointCollectionTpl = JointCollectionDefaultTpl>
25 template<
typename _Scalar,
int _Options,
template<
typename S,
int O>
class JointCollectionTpl>
35 typedef _Scalar Scalar;
36 typedef JointCollectionTpl<Scalar, Options> JointCollection;
46 typedef Eigen::Matrix<Scalar, 6, Eigen::Dynamic, Options> U_t;
47 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Options> D_t;
48 typedef Eigen::Matrix<Scalar, 6, Eigen::Dynamic, Options> UD_t;
58 typedef U_t UTypeConstRef;
60 typedef D_t DTypeConstRef;
62 typedef UD_t UDTypeConstRef;
63 typedef UD_t UDTypeRef;
65 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options> ConfigVector_t;
66 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options> TangentVector_t;
68 typedef ConfigVector_t ConfigVectorTypeConstRef;
69 typedef ConfigVector_t ConfigVectorTypeRef;
70 typedef TangentVector_t TangentVectorTypeConstRef;
71 typedef TangentVector_t TangentVectorTypeRef;
74 template<
typename _Scalar,
int _Options,
template<
typename S,
int O>
class JointCollectionTpl>
81 template<
typename _Scalar,
int _Options,
template<
typename S,
int O>
class JointCollectionTpl>
88 template<
typename _Scalar,
int _Options,
template<
typename S,
int O>
class JointCollectionTpl>
90 :
public JointDataBase<JointDataTpl<_Scalar, _Options, JointCollectionTpl>>
91 , JointCollectionTpl<_Scalar, _Options>::JointDataVariant
93 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
100 typedef JointCollectionTpl<_Scalar, _Options> JointCollection;
101 typedef typename JointCollection::JointDataVariant JointDataVariant;
103 using Base::operator==;
104 using Base::operator!=;
106 JointDataVariant & toVariant()
108 return *
static_cast<JointDataVariant *
>(
this);
110 const JointDataVariant & toVariant()
const
112 return *
static_cast<const JointDataVariant *
>(
this);
115 ConfigVector_t joint_q()
const
119 TangentVector_t joint_v()
const
123 Constraint_t S()
const
127 Transformation_t M()
const
164 : JointDataVariant(jdata_variant)
168 template<
typename Jo
intDataDerived>
170 : JointCollection::JointDataVariant((JointDataVariant)jdata.derived())
172 BOOST_MPL_ASSERT((boost::mpl::contains<typename JointDataVariant::types, JointDataDerived>));
176 ConfigVector_t joint_q_accessor()
const
180 TangentVector_t joint_v_accessor()
const
184 Constraint_t S_accessor()
const
188 Transformation_t M_accessor()
const
192 Motion_t v_accessor()
const
196 Bias_t c_accessor()
const
200 U_t U_accessor()
const
204 D_t Dinv_accessor()
const
208 UD_t UDinv_accessor()
const
212 D_t StU_accessor()
const
217 static std::string classname()
221 std::string shortname()
const
223 return ::pinocchio::shortname(*
this);
226 template<
typename Jo
intDataDerived>
229 return ::pinocchio::isEqual(*
this, other.derived());
234 return Base::isEqual(other) && toVariant() == other.toVariant();
239 return isEqual(other);
244 return !(*
this == other);
252 template<
typename S,
int O>
class JointCollectionTpl>
258 template<
typename _Scalar,
int _Options,
template<
typename S,
int O>
class JointCollectionTpl>
260 :
JointModelBase<JointModelTpl<_Scalar, _Options, JointCollectionTpl>>
261 , JointCollectionTpl<_Scalar, _Options>::JointModelVariant
263 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
270 typedef JointCollectionTpl<Scalar, Options> JointCollection;
271 typedef typename JointCollection::JointDataVariant JointDataVariant;
272 typedef typename JointCollection::JointModelVariant JointModelVariant;
275 using Base::setIndexes;
276 using Base::operator==;
277 using Base::operator!=;
280 : JointModelVariant()
285 : JointCollection::JointModelVariant(jmodel_variant)
289 const std::vector<bool> hasConfigurationLimit()
const
291 return ::pinocchio::hasConfigurationLimit(*
this);
294 const std::vector<bool> hasConfigurationLimitInTangent()
const
296 return ::pinocchio::hasConfigurationLimitInTangent(*
this);
299 template<
typename Jo
intModelDerived>
301 : JointModelVariant((JointModelVariant)jmodel.derived())
304 (boost::mpl::contains<typename JointModelVariant::types, JointModelDerived>));
307 JointModelVariant & toVariant()
309 return *
static_cast<JointModelVariant *
>(
this);
312 const JointModelVariant & toVariant()
const
314 return *
static_cast<const JointModelVariant *
>(
this);
317 JointDataDerived createData()
const
319 return ::pinocchio::createData<Scalar, Options, JointCollectionTpl>(*
this);
322 template<
typename Jo
intModelDerived>
325 return ::pinocchio::isEqual(*
this, other.derived());
328 template<
typename Jo
intModelDerived>
331 return ::pinocchio::hasSameIndexes(*
this, other.derived());
336 return Base::isEqual(other) && toVariant() == other.toVariant();
341 return isEqual(other);
346 return !(*
this == other);
349 template<
typename ConfigVector>
350 void calc(JointDataDerived & data,
const Eigen::MatrixBase<ConfigVector> & q)
const
355 template<
typename TangentVector>
357 JointDataDerived & data,
const Blank blank,
const Eigen::MatrixBase<TangentVector> & v)
const
362 template<
typename ConfigVector,
typename TangentVector>
364 JointDataDerived & data,
365 const Eigen::MatrixBase<ConfigVector> & q,
366 const Eigen::MatrixBase<TangentVector> & v)
const
371 template<
typename VectorLike,
typename Matrix6Like>
373 JointDataDerived & data,
374 const Eigen::MatrixBase<VectorLike> & armature,
375 const Eigen::MatrixBase<Matrix6Like> & I,
376 const bool update_I)
const
378 ::pinocchio::calc_aba(
379 *
this, data, armature.derived(), PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like, I), update_I);
382 std::string shortname()
const
384 return ::pinocchio::shortname(*
this);
386 static std::string classname()
393 return ::pinocchio::nq(*
this);
397 return ::pinocchio::nv(*
this);
400 int idx_q_impl()
const
402 return ::pinocchio::idx_q(*
this);
404 int idx_v_impl()
const
406 return ::pinocchio::idx_v(*
this);
409 JointIndex id_impl()
const
411 return ::pinocchio::id(*
this);
414 void setIndexes(JointIndex
id,
int nq,
int nv)
416 ::pinocchio::setIndexes(*
this,
id,
nq,
nv);
420 template<
typename NewScalar>
423 return cast_joint<NewScalar, Scalar, Options, JointCollectionTpl>(*
this);
427 typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector;
428 typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointModel) JointModelVector;
433 template<
typename S,
int O>
class JointCollectionTpl,
434 typename JointDataDerived>
436 const JointDataBase<JointDataDerived> & joint_data,
437 const JointDataTpl<Scalar, Options, JointCollectionTpl> & joint_data_generic)
439 return joint_data_generic == joint_data.derived();
445 template<
typename S,
int O>
class JointCollectionTpl,
446 typename JointDataDerived>
448 const JointDataBase<JointDataDerived> & joint_data,
449 const JointDataTpl<Scalar, Options, JointCollectionTpl> & joint_data_generic)
451 return joint_data_generic != joint_data.derived();
457 template<
typename S,
int O>
class JointCollectionTpl,
458 typename JointModelDerived>
460 const JointModelBase<JointModelDerived> & joint_model,
461 const JointModelTpl<Scalar, Options, JointCollectionTpl> & joint_model_generic)
463 return joint_model_generic == joint_model.derived();
469 template<
typename S,
int O>
class JointCollectionTpl,
470 typename JointModelDerived>
472 const JointModelBase<JointModelDerived> & joint_model,
473 const JointModelTpl<Scalar, Options, JointCollectionTpl> & joint_model_generic)
475 return joint_model_generic != joint_model.derived();
Main pinocchio namespace.
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > u_inertia(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointUInertiaVisitor to get the U matrix of the inertia matrix decomposi...
MotionTpl< Scalar, Options > motion(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointMotionVisitor to get the joint internal motion as a dense motion.
MotionTpl< Scalar, Options > bias(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointBiasVisitor to get the joint bias as a dense motion.
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Options > stu_inertia(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointStUInertiaVisitor to get St*I*S matrix of the inertia matrix decomp...
JointMotionSubspaceTpl< Eigen::Dynamic, Scalar, Options > joint_motin_subspace_xd(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataVariant through JointConstraintVisitor to get the joint constraint as a dense constr...
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Options > dinv_inertia(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointDInvInertiaVisitor to get the D^{-1} matrix of the inertia matrix d...
SE3Tpl< Scalar, Options > joint_transform(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointTransformVisitor to get the joint internal transform (transform bet...
void calc_first_order(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v)
Visit a JointModelTpl and the corresponding JointDataTpl through JointCalcFirstOrderVisitor to comput...
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > udinv_inertia(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointUDInvInertiaVisitor to get U*D^{-1} matrix of the inertia matrix de...
JointDataTpl< Scalar, Options, JointCollectionTpl >::TangentVector_t joint_v(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataVariant through JointConfigVisitor to get the joint velocity vector.
void calc_zero_order(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata, const Eigen::MatrixBase< ConfigVectorType > &q)
Visit a JointModelTpl and the corresponding JointDataTpl through JointCalcZeroOrderVisitor to compute...
int nv(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNvVisitor to get the dimension of the joint tangent space.
JointDataTpl< Scalar, Options, JointCollectionTpl >::ConfigVector_t joint_q(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataVariant through JointConfigVisitor to get the joint configuration vector.
int nq(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNqVisitor to get the dimension of the joint configuration space.
Type of the cast of a class C templated by Scalar and Options, to a new NewScalar type....
bool isEqual(const JointDataBase< Derived > &other) const
 
JointModelTpl< NewScalar, Options, JointCollectionTpl > cast() const
Common traits structure to fully define base classes for CRTP.