joint-generic.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_joint_generic_hpp__
6 #define __pinocchio_joint_generic_hpp__
7 
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"
12 
13 #include <boost/mpl/contains.hpp>
14 
15 namespace pinocchio
16 {
17 
18  template<typename Scalar, int Options = 0, template<typename S, int O> class JointCollectionTpl = JointCollectionDefaultTpl>
19  struct JointTpl;
20  typedef JointTpl<double> Joint;
21 
22  template<typename _Scalar, int _Options, template<typename S, int O> class JointCollectionTpl>
23  struct traits< JointTpl<_Scalar,_Options,JointCollectionTpl> >
24  {
25  enum {
26  Options = _Options,
27  NQ = Eigen::Dynamic, // Dynamic because unknown at compile time
28  NV = Eigen::Dynamic
29  };
30 
31  typedef _Scalar Scalar;
32  typedef JointCollectionTpl<Scalar,Options> JointCollection;
35 
40 
41  // [ABA]
42  typedef Eigen::Matrix<Scalar,6,Eigen::Dynamic,Options> U_t;
43  typedef Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic,Options> D_t;
44  typedef Eigen::Matrix<Scalar,6,Eigen::Dynamic,Options> UD_t;
45 
46  typedef Constraint_t ConstraintTypeConstRef;
47  typedef Constraint_t ConstraintTypeRef;
48  typedef Transformation_t TansformTypeConstRef;
49  typedef Transformation_t TansformTypeRef;
50  typedef Motion_t MotionTypeConstRef;
51  typedef Motion_t MotionTypeRef;
52  typedef Bias_t BiasTypeConstRef;
53  typedef Bias_t BiasTypeRef;
54  typedef U_t UTypeConstRef;
55  typedef U_t UTypeRef;
56  typedef D_t DTypeConstRef;
57  typedef D_t DTypeRef;
58  typedef UD_t UDTypeConstRef;
59  typedef UD_t UDTypeRef;
60 
61  typedef Eigen::Matrix<Scalar,Eigen::Dynamic,1,Options> ConfigVector_t;
62  typedef Eigen::Matrix<Scalar,Eigen::Dynamic,1,Options> TangentVector_t;
63  };
64 
65  template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl>
66  struct traits< JointDataTpl<Scalar,Options,JointCollectionTpl> >
68 
69  template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl>
70  struct traits< JointModelTpl<Scalar,Options,JointCollectionTpl> >
72 
73  template<typename _Scalar, int _Options, template<typename S, int O> class JointCollectionTpl>
74  struct JointDataTpl
75  : public JointDataBase< JointDataTpl<_Scalar,_Options,JointCollectionTpl> >
76  , JointCollectionTpl<_Scalar,_Options>::JointDataVariant
77  {
78  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
79 
82 
84 
85  typedef JointCollectionTpl<_Scalar,_Options> JointCollection;
87 
88  using Base::operator==;
89  using Base::operator!=;
90 
91  JointDataVariant & toVariant() { return *static_cast<JointDataVariant*>(this); }
92  const JointDataVariant & toVariant() const { return *static_cast<const JointDataVariant*>(this); }
93 
94  Constraint_t S() const { return constraint_xd(*this); }
95  Transformation_t M() const { return joint_transform(*this); }
96  Motion_t v() const { return motion(*this); }
97  Bias_t c() const { return bias(*this); }
98 
99  // [ABA CCRBA]
100  U_t U() const { return u_inertia(*this); }
101  D_t Dinv() const { return dinv_inertia(*this); }
102  UD_t UDinv() const { return udinv_inertia(*this); }
103 
105  : JointDataVariant()
106  {}
107 
108  JointDataTpl(const JointDataVariant & jdata_variant)
109  : JointDataVariant(jdata_variant)
110  {}
111 
112  template<typename JointDataDerived>
114  : JointCollection::JointDataVariant((JointDataVariant)jdata.derived())
115  {
116  BOOST_MPL_ASSERT((boost::mpl::contains<typename JointDataVariant::types,JointDataDerived>));
117  }
118 
119  // Define all the standard accessors
120  Constraint_t S_accessor() const { return S(); }
121  Transformation_t M_accessor() const { return M(); }
122  Motion_t v_accessor() const { return v(); }
123  Bias_t c_accessor() const { return c(); }
124  U_t U_accessor() const { return U(); }
125  D_t Dinv_accessor() const { return Dinv(); }
126  UD_t UDinv_accessor() const { return UDinv(); }
127 
128  static std::string classname() { return "JointData"; }
129  std::string shortname() const { return ::pinocchio::shortname(*this); }
130 
131  template<typename JointDataDerived>
132  bool isEqual(const JointDataBase<JointDataDerived> & other) const
133  {
134  return ::pinocchio::isEqual(*this,other.derived());
135  }
136 
137  bool isEqual(const JointDataTpl & other) const
138  {
139  return Base::isEqual(other) && toVariant() == other.toVariant();
140  }
141 
142  bool operator==(const JointDataTpl & other) const
143  {
144  return isEqual(other);
145  }
146 
147  bool operator!=(const JointDataTpl & other) const
148  {
149  return !(*this == other);
150  }
151 
152  };
153 
154  template<typename NewScalar, typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl>
155  struct CastType< NewScalar, JointModelTpl<Scalar,Options,JointCollectionTpl> >
156  {
158  };
159 
160  template<typename _Scalar, int _Options, template<typename S, int O> class JointCollectionTpl>
161  struct JointModelTpl
162  : JointModelBase< JointModelTpl<_Scalar,_Options,JointCollectionTpl> >
163  , JointCollectionTpl<_Scalar,_Options>::JointModelVariant
164  {
165  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
166 
168 
169  PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(JointDerived);
171 
172  typedef JointCollectionTpl<Scalar,Options> JointCollection;
175 
176  using Base::id;
177  using Base::setIndexes;
178  using Base::operator==;
179  using Base::operator!=;
180 
181  JointModelTpl() : JointModelVariant() {}
182 
183  JointModelTpl(const JointModelVariant & jmodel_variant)
184  : JointCollection::JointModelVariant(jmodel_variant)
185  {
186  }
187 
188  template<typename JointModelDerived>
190  : JointModelVariant((JointModelVariant)jmodel.derived())
191  {
192  BOOST_MPL_ASSERT((boost::mpl::contains<typename JointModelVariant::types,JointModelDerived>));
193  }
194 
195  JointModelVariant & toVariant()
196  { return *static_cast<JointModelVariant*>(this); }
197 
198  const JointModelVariant & toVariant() const
199  { return *static_cast<const JointModelVariant*>(this); }
200 
201  JointDataDerived createData() const
202  { return ::pinocchio::createData<Scalar,Options,JointCollectionTpl>(*this); }
203 
204  template<typename JointModelDerived>
205  bool isEqual(const JointModelBase<JointModelDerived> & other) const
206  {
207  return ::pinocchio::isEqual(*this,other.derived());;
208  }
209 
210  template<typename JointModelDerived>
212  {
214  }
215 
216  bool isEqual(const JointModelTpl & other) const
217  {
218  return Base::isEqual(other) && toVariant() == other.toVariant();
219  }
220 
221  bool operator==(const JointModelTpl & other) const
222  {
223  return isEqual(other);
224  }
225 
226  bool operator!=(const JointModelTpl & other) const
227  {
228  return !(*this == other);
229  }
230 
231  template<typename ConfigVector>
232  void calc(JointDataDerived & data,
233  const Eigen::MatrixBase<ConfigVector> & q) const
234  { calc_zero_order(*this,data,q); }
235 
236  template<typename ConfigVector, typename TangentVector>
237  void calc(JointDataDerived & data,
238  const Eigen::MatrixBase<ConfigVector> & q,
239  const Eigen::MatrixBase<TangentVector> & v) const
240  { calc_first_order(*this,data,q,v); }
241 
242  template<typename Matrix6Like>
243  void calc_aba(JointDataDerived & data, const Eigen::MatrixBase<Matrix6Like> & I, const bool update_I) const
244  { ::pinocchio::calc_aba(*this,data,PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like,I),update_I); }
245 
246  std::string shortname() const { return ::pinocchio::shortname(*this); }
247  static std::string classname() { return "JointModel"; }
248 
249  int nq_impl() const { return ::pinocchio::nq(*this); }
250  int nv_impl() const { return ::pinocchio::nv(*this); }
251 
252  int idx_q_impl() const { return ::pinocchio::idx_q(*this); }
253  int idx_v_impl() const { return ::pinocchio::idx_v(*this); }
254 
256 
257  void setIndexes(JointIndex id, int nq, int nv)
258  {
259  ::pinocchio::setIndexes(*this, id, nq, nv);
260  }
261 
263  template<typename NewScalar>
265  {
266  return cast_joint<NewScalar,Scalar,Options,JointCollectionTpl>(*this);
267  }
268  };
269 
270  typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector;
271  typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointModel) JointModelVector;
272 
273 
274  template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl, typename JointDataDerived>
276  const JointDataTpl<Scalar,Options,JointCollectionTpl> & joint_data_generic)
277  {
278  return joint_data_generic == joint_data.derived();
279  }
280 
281 
282  template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl, typename JointDataDerived>
284  const JointDataTpl<Scalar,Options,JointCollectionTpl> & joint_data_generic)
285  {
286  return joint_data_generic != joint_data.derived();
287  }
288 
289  template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl, typename JointModelDerived>
291  const JointModelTpl<Scalar,Options,JointCollectionTpl> & joint_model_generic)
292  {
293  return joint_model_generic == joint_model.derived();
294  }
295 
296  template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl, typename JointModelDerived>
298  const JointModelTpl<Scalar,Options,JointCollectionTpl> & joint_model_generic)
299  {
300  return joint_model_generic != joint_model.derived();
301  }
302 
303 } // namespace pinocchio
304 
305 #endif // ifndef __pinocchio_joint_generic_hpp__
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
Constraint_t S() const
bool operator==(const JointModelTpl &other) const
c
Definition: ocp.py:61
int nv(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNvVisitor to get the dimension of the joint tangent space...
std::string shortname() const
bool operator!=(const JointModelTpl &other) const
static std::string classname()
JointDataDerived createData() const
int NQ
Definition: dpendulum.py:8
bool isEqual(const JointDataBase< JointDataDerived > &other) const
JointCollection::JointModelVariant JointModelVariant
JointCollection::JointDataVariant JointDataVariant
typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector
bool isEqual(const JointModelBase< JointModelDerived > &other) const
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...
int idx_q(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxQVisitor to get the index in the full model configuration space...
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 nq(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNqVisitor to get the dimension of the joint configuration space...
ConstraintTpl< Eigen::Dynamic, Scalar, Options > Constraint_t
SE3Tpl< Scalar, Options > joint_transform(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointTransformVisitor to get the joint internal transform (transform bet...
JointIndex id(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdVisitor to get the index of the joint in the kinematic chain...
JointDataTpl(const JointDataVariant &jdata_variant)
Motion_t v_accessor() const
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...
bool isEqual(const JointModelTpl &other) const
JointCollection::JointDataVariant JointDataVariant
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef JointTpl< _Scalar, _Options, JointCollectionTpl > JointDerived
JointDataTpl(const JointDataBase< JointDataDerived > &jdata)
bool hasSameIndexes(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel_generic, const JointModelBase< JointModelDerived > &jmodel)
Check whether JointModelTpl<Scalar,...> has the indexes than another JointModelDerived.
JointIndex id_impl() const
bool isEqual(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel_generic, const JointModelBase< JointModelDerived > &jmodel)
Visit a JointModelTpl<Scalar,...> to compare it to JointModelDerived.
Bias_t c_accessor() const
Constraint_t S_accessor() const
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
#define PINOCCHIO_EIGEN_CONST_CAST(TYPE, OBJ)
Macro for an automatic const_cast.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef JointTpl< _Scalar, _Options, JointCollectionTpl > JointDerived
void calc_aba(JointDataDerived &data, const Eigen::MatrixBase< Matrix6Like > &I, const bool update_I) const
bool operator==(const JointDataBase< JointDataDerived > &joint_data, const JointDataTpl< Scalar, Options, JointCollectionTpl > &joint_data_generic)
JointCollectionTpl< _Scalar, _Options > JointCollection
SE3::Scalar Scalar
Definition: conversions.cpp:13
JointCollectionTpl< Scalar, Options > JointCollection
std::string shortname(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointShortnameVisitor to get the shortname of the derived joint model...
#define PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE(Joint)
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Options > D_t
const JointDataVariant & toVariant() const
#define PINOCCHIO_JOINT_USE_INDEXES(Joint)
JointModelTpl(const JointModelBase< JointModelDerived > &jmodel)
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > UD_t
bool operator!=(const JointDataBase< JointDataDerived > &joint_data, const JointDataTpl< Scalar, Options, JointCollectionTpl > &joint_data_generic)
U
Definition: ocp.py:61
JointDataTpl< Scalar, Options, JointCollectionTpl > JointDataDerived
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...
static std::string classname()
JointModelDerived & derived()
JointDataBase< JointDataTpl > Base
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > U_t
std::string shortname() const
Transformation_t M() const
void calc(JointDataDerived &data, const Eigen::MatrixBase< ConfigVector > &q) const
void setIndexes(JointIndex id, int nq, int nv)
JointModelTpl< NewScalar, Options, JointCollectionTpl > cast() const
Main pinocchio namespace.
Definition: timings.cpp:30
bool operator!=(const JointDataTpl &other) const
JointCollectionDefault::JointDataVariant JointDataVariant
JointTpl< Scalar, Options, JointCollectionTpl > JointDerived
Motion_t v() 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...
JointDataVariant & toVariant()
void calc(JointDataDerived &data, const Eigen::MatrixBase< ConfigVector > &q, const Eigen::MatrixBase< TangentVector > &v) const
MotionTpl< Scalar, Options > bias(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataTpl through JointBiasVisitor to get the joint bias as a dense motion.
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...
bool hasSameIndexes(const JointModelBase< JointModelDerived > &other) const
Common traits structure to fully define base classes for CRTP.
Definition: src/fwd.hpp:44
JointTpl< double > Joint
Eigen::Matrix< Scalar, Eigen::Dynamic, 1, Options > TangentVector_t
JointModelVariant & toVariant()
Transformation_t M_accessor() const
JointModelTpl< Scalar, Options, JointCollectionTpl > JointModelDerived
const JointModelVariant & toVariant() const
UD_t UDinv_accessor() const
JointCollectionDefault::JointModelVariant JointModelVariant
M
NV
Definition: dcrba.py:444
Type of the cast of a class C templated by Scalar and Options, to a new NewScalar type...
Definition: src/fwd.hpp:55
JointTpl< Scalar, Options, JointCollectionTpl > JointDerived
JointModelTpl(const JointModelVariant &jmodel_variant)
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...
ConstraintTpl< Eigen::Dynamic, Scalar, Options > constraint_xd(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataVariant through JointConstraintVisitor to get the joint constraint as a dense constr...
bool isEqual(const JointDataTpl &other) const
void calc_aba(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata, const Eigen::MatrixBase< Matrix6Type > &I, const bool update_I)
Visit a JointModelTpl and the corresponding JointDataTpl through JointCalcAbaVisitor to...
Eigen::Matrix< Scalar, Eigen::Dynamic, 1, Options > ConfigVector_t
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...
bool operator==(const JointDataTpl &other) const
#define PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(Joint)


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:03