pinocchio  2.1.3
joint-revolute-unbounded.hpp
1 //
2 // Copyright (c) 2016-2018 CNRS
3 //
4 
5 #ifndef __pinocchio_joint_revolute_unbounded_hpp__
6 #define __pinocchio_joint_revolute_unbounded_hpp__
7 
8 #include "pinocchio/math/fwd.hpp"
9 #include "pinocchio/math/sincos.hpp"
10 #include "pinocchio/spatial/inertia.hpp"
11 #include "pinocchio/multibody/joint/joint-base.hpp"
12 #include "pinocchio/multibody/joint/joint-revolute.hpp"
13 
14 namespace pinocchio
15 {
16 
17  template<typename Scalar, int Options, int axis> struct JointRevoluteUnboundedTpl;
18 
19  template<typename _Scalar, int _Options, int axis>
20  struct traits< JointRevoluteUnboundedTpl<_Scalar,_Options,axis> >
21  {
22  enum {
23  NQ = 2,
24  NV = 1
25  };
26  typedef _Scalar Scalar;
27  enum { Options = _Options };
34  typedef Eigen::Matrix<Scalar,6,NV,Options> F_t;
35 
36  // [ABA]
37  typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
38  typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
39  typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
40 
41  PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
42 
43  typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
44  typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
45  };
46 
47  template<typename Scalar, int Options, int axis>
48  struct traits< JointDataRevoluteUnboundedTpl<Scalar,Options,axis> >
50 
51  template<typename Scalar, int Options, int axis>
52  struct traits< JointModelRevoluteUnboundedTpl<Scalar,Options,axis> >
54 
55  template<typename _Scalar, int _Options, int axis>
56  struct JointDataRevoluteUnboundedTpl : public JointDataBase< JointDataRevoluteUnboundedTpl<_Scalar,_Options,axis> >
57  {
58  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
60  PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE;
61  PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
62 
63  Constraint_t S;
64  Transformation_t M;
65  Motion_t v;
66  Bias_t c;
67  F_t F;
68 
69  // [ABA] specific data
70  U_t U;
71  D_t Dinv;
72  UD_t UDinv;
73 
75 
76  static std::string classname() { return std::string("JointDataRevoluteUnbounded"); }
77  std::string shortname() const { return classname(); }
78 
79  }; // struct JointDataRevoluteUnbounded
80 
81  template<typename NewScalar, typename Scalar, int Options, int axis>
82  struct CastType< NewScalar, JointModelRevoluteUnboundedTpl<Scalar,Options,axis> >
83  {
85  };
86 
87  template<typename _Scalar, int _Options, int axis>
89  : public JointModelBase< JointModelRevoluteUnboundedTpl<_Scalar,_Options,axis> >
90  {
91  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
93  PINOCCHIO_JOINT_TYPEDEF_TEMPLATE;
94  typedef JointRevoluteTpl<Scalar,_Options,axis> JointDerivedBase;
95 
97  using Base::id;
98  using Base::idx_q;
99  using Base::idx_v;
100  using Base::setIndexes;
101 
102  JointDataDerived createData() const { return JointDataDerived(); }
103 
104  template<typename ConfigVector>
105  void calc(JointDataDerived & data,
106  const typename Eigen::MatrixBase<ConfigVector> & qs) const
107  {
108  typedef typename ConfigVector::Scalar OtherScalar;
109  typename ConfigVector::template ConstFixedSegmentReturnType<NQ>::Type
110  & q = qs.template segment<NQ> (idx_q());
111 
112  const OtherScalar & ca = q(0);
113  const OtherScalar & sa = q(1);
114 
115  data.M.setValues(sa,ca);
116  }
117 
118  template<typename ConfigVector, typename TangentVector>
119  void calc(JointDataDerived & data,
120  const typename Eigen::MatrixBase<ConfigVector> & qs,
121  const typename Eigen::MatrixBase<TangentVector> & vs) const
122  {
123  calc(data,qs.derived());
124 
125  data.v.w = (Scalar)vs[idx_v()];
126  }
127 
128  template<typename Matrix6Like>
129  void calc_aba(JointDataDerived & data, const Eigen::MatrixBase<Matrix6Like> & I, const bool update_I) const
130  {
131  data.U = I.col(Inertia::ANGULAR + axis);
132  data.Dinv[0] = (Scalar)(1)/I(Inertia::ANGULAR + axis,Inertia::ANGULAR + axis);
133  data.UDinv.noalias() = data.U * data.Dinv[0];
134 
135  if (update_I)
136  PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like,I) -= data.UDinv * data.U.transpose();
137  }
138 
139  Scalar finiteDifferenceIncrement() const
140  {
141  using math::sqrt;
142  return 2.*sqrt(sqrt(Eigen::NumTraits<Scalar>::epsilon()));
143  }
144 
145  static std::string classname()
146  {
147  return std::string("JointModelRUB") + axisLabel<axis>();
148  }
149  std::string shortname() const { return classname(); }
150 
152  template<typename NewScalar>
154  {
156  ReturnType res;
157  res.setIndexes(id(),idx_q(),idx_v());
158  return res;
159  }
160 
161  }; // struct JointModelRevoluteUnboundedTpl
162 
166 
170 
174 
175 } //namespace pinocchio
176 
177 
178 #include <boost/type_traits.hpp>
179 
180 namespace boost
181 {
182  template<typename Scalar, int Options, int axis>
183  struct has_nothrow_constructor< ::pinocchio::JointModelRevoluteUnboundedTpl<Scalar,Options,axis> >
184  : public integral_constant<bool,true> {};
185 
186  template<typename Scalar, int Options, int axis>
187  struct has_nothrow_copy< ::pinocchio::JointModelRevoluteUnboundedTpl<Scalar,Options,axis> >
188  : public integral_constant<bool,true> {};
189 
190  template<typename Scalar, int Options, int axis>
191  struct has_nothrow_constructor< ::pinocchio::JointDataRevoluteUnboundedTpl<Scalar,Options,axis> >
192  : public integral_constant<bool,true> {};
193 
194  template<typename Scalar, int Options, int axis>
195  struct has_nothrow_copy< ::pinocchio::JointDataRevoluteUnboundedTpl<Scalar,Options,axis> >
196  : public integral_constant<bool,true> {};
197 }
198 
199 #endif // ifndef __pinocchio_joint_revolute_unbounded_hpp__
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...
JointDataTpl< Scalar, Options, JointCollectionTpl > createData(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through CreateData visitor to create a JointDataTpl.
ModelTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType finiteDifferenceIncrement(const ModelTpl< Scalar, Options, JointCollectionTpl > &model)
Computes the finite difference increments for each degree of freedom according to the current joint c...
std::string shortname(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointShortnameVisitor to get the shortname of the derived joint model...
JointModelRevoluteUnboundedTpl< NewScalar, Options, axis > cast() const
Main pinocchio namespace.
Definition: treeview.dox:24
Common traits structure to fully define base classes for CRTP.
Definition: spatial/fwd.hpp:29
Type of the cast of a class C templated by Scalar and Options, to a new NewScalar type...
Definition: spatial/fwd.hpp:35
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...