motion-tpl.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2018 CNRS
3 // Copyright (c) 2015-2016 Wandercraft, 86 rue de Paris 91400 Orsay, France.
4 //
5 
6 #ifndef __pinocchio_motion_tpl_hpp__
7 #define __pinocchio_motion_tpl_hpp__
8 
9 namespace pinocchio
10 {
11  template<typename _Scalar, int _Options>
12  struct traits< MotionTpl<_Scalar, _Options> >
13  {
14  typedef _Scalar Scalar;
15  typedef Eigen::Matrix<Scalar,3,1,_Options> Vector3;
16  typedef Eigen::Matrix<Scalar,6,1,_Options> Vector6;
17  typedef Eigen::Matrix<Scalar,4,4,_Options> Matrix4;
18  typedef Eigen::Matrix<Scalar,6,6,_Options> Matrix6;
19  typedef Matrix6 ActionMatrixType;
20  typedef Matrix4 HomogeneousMatrixType;
21  typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6) ToVectorConstReturnType;
22  typedef typename PINOCCHIO_EIGEN_REF_TYPE(Vector6) ToVectorReturnType;
23  typedef typename Vector6::template FixedSegmentReturnType<3>::Type LinearType;
24  typedef typename Vector6::template FixedSegmentReturnType<3>::Type AngularType;
25  typedef typename Vector6::template ConstFixedSegmentReturnType<3>::Type ConstLinearType;
26  typedef typename Vector6::template ConstFixedSegmentReturnType<3>::Type ConstAngularType;
28  typedef const MotionPlain & PlainReturnType;
29  enum {
30  LINEAR = 0,
31  ANGULAR = 3,
32  Options = _Options
33  };
34 
36  }; // traits MotionTpl
37 
38  template<typename _Scalar, int _Options>
39  class MotionTpl : public MotionDense< MotionTpl< _Scalar, _Options > >
40  {
41  public:
42  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
45  enum { Options = _Options };
46 
47  using Base::operator=;
48  using Base::linear;
49  using Base::angular;
50 
51  using Base::__plus__;
52  using Base::__opposite__;
53  using Base::__minus__;
54  using Base::__pequ__;
55  using Base::__mequ__;
56  using Base::__mult__;
57 
58  // Constructors
59  MotionTpl() : m_data() {}
60 
61  template<typename V1,typename V2>
62  MotionTpl(const Eigen::MatrixBase<V1> & v, const Eigen::MatrixBase<V2> & w)
63  {
64  assert(v.size() == 3);
65  assert(w.size() == 3);
66  linear() = v; angular() = w;
67  }
68 
69  template<typename V6>
70  explicit MotionTpl(const Eigen::MatrixBase<V6> & v)
71  : m_data(v)
72  {
73  EIGEN_STATIC_ASSERT_VECTOR_ONLY(V6);
74  assert(v.size() == 6);
75  }
76 
77  template<int O2>
79  : m_data(clone.toVector())
80  {}
81 
82  template<typename M2>
83  explicit MotionTpl(const MotionDense<M2> & clone)
84  { linear() = clone.linear(); angular() = clone.angular(); }
85 
86  template<typename M2>
87  explicit MotionTpl(const MotionBase<M2> & clone)
88  { *this = clone; }
89 
90  // initializers
91  static MotionTpl Zero() { return MotionTpl(Vector6::Zero()); }
92  static MotionTpl Random() { return MotionTpl(Vector6::Random()); }
93 
94  inline PlainReturnType plain() const { return *this; }
95 
96  ToVectorConstReturnType toVector_impl() const { return m_data; }
97  ToVectorReturnType toVector_impl() { return m_data; }
98 
99  // Getters
100  ConstAngularType angular_impl() const { return m_data.template segment<3> (ANGULAR); }
101  ConstLinearType linear_impl() const { return m_data.template segment<3> (LINEAR); }
102  AngularType angular_impl() { return m_data.template segment<3> (ANGULAR); }
103  LinearType linear_impl() { return m_data.template segment<3> (LINEAR); }
104 
105  template<typename V3>
106  void angular_impl(const Eigen::MatrixBase<V3> & w)
107  {
108  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3,3);
109  angular_impl()=w;
110  }
111  template<typename V3>
112  void linear_impl(const Eigen::MatrixBase<V3> & v)
113  {
114  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3,3);
115  linear_impl()=v;
116  }
117 
118  // Specific operators for MotionTpl and MotionRef
119  template<int O2>
120  MotionPlain __plus__(const MotionTpl<Scalar,O2> & v) const
121  { return MotionPlain(m_data+v.toVector()); }
122 
123  template<typename Vector6ArgType>
124  MotionPlain __plus__(const MotionRef<Vector6ArgType> & v) const
125  { return MotionPlain(m_data+v.toVector()); }
126 
127  template<int O2>
128  MotionPlain __minus__(const MotionTpl<Scalar,O2> & v) const
129  { return MotionPlain(m_data-v.toVector()); }
130 
131  template<typename Vector6ArgType>
132  MotionPlain __minus__(const MotionRef<Vector6ArgType> & v) const
133  { return MotionPlain(m_data-v.toVector()); }
134 
135  template<int O2>
137  { m_data += v.toVector(); return *this; }
138 
139  template<typename Vector6ArgType>
141  { m_data += v.toVector(); return *this; }
142 
143  template<int O2>
145  { m_data -= v.toVector(); return *this; }
146 
147  template<typename Vector6ArgType>
149  { m_data -= v.toVector(); return *this; }
150 
151  template<typename OtherScalar>
152  MotionPlain __mult__(const OtherScalar & alpha) const
153  { return MotionPlain(alpha*m_data); }
154 
156 
158  template<typename NewScalar>
160  {
161  typedef MotionTpl<NewScalar,Options> ReturnType;
162  ReturnType res(linear().template cast<NewScalar>(),
163  angular().template cast<NewScalar>());
164  return res;
165  }
166 
167  protected:
168  Vector6 m_data;
169 
170  }; // class MotionTpl
171 
172 } // namespace pinocchio
173 
174 #endif // ifndef __pinocchio_motion_tpl_hpp__
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
MotionTpl & __pequ__(const MotionRef< Vector6ArgType > &v)
Definition: motion-tpl.hpp:140
Eigen::Matrix< Scalar, 4, 4, _Options > Matrix4
Definition: motion-tpl.hpp:17
MotionTpl(const MotionTpl< Scalar, O2 > &clone)
Definition: motion-tpl.hpp:78
MotionTpl & __mequ__(const MotionTpl< Scalar, O2 > &v)
Definition: motion-tpl.hpp:144
Eigen::Matrix< Scalar, 6, 1, _Options > Vector6
Definition: motion-tpl.hpp:16
void angular_impl(const Eigen::MatrixBase< V3 > &w)
Definition: motion-tpl.hpp:106
virtual CollisionGeometry * clone() const=0
MotionTpl(const MotionBase< M2 > &clone)
Definition: motion-tpl.hpp:87
ConstAngularType angular_impl() const
Definition: motion-tpl.hpp:100
#define MOTION_TYPEDEF_TPL(Derived)
PINOCCHIO_EIGEN_REF_CONST_TYPE(Matrix6Like) operator*(const Eigen
MotionTpl & __mequ__(const MotionRef< Vector6ArgType > &v)
Definition: motion-tpl.hpp:148
ToVectorConstReturnType toVector_impl() const
Definition: motion-tpl.hpp:96
ToVectorReturnType toVector_impl()
Definition: motion-tpl.hpp:97
ConstLinearType linear() const
Definition: motion-base.hpp:22
MotionTpl< NewScalar, Options > cast() const
Definition: motion-tpl.hpp:159
MotionPlain __plus__(const MotionTpl< Scalar, O2 > &v) const
Definition: motion-tpl.hpp:120
ConstLinearType linear_impl() const
Definition: motion-tpl.hpp:101
ConstAngularType angular() const
Definition: motion-base.hpp:21
Vector6::template ConstFixedSegmentReturnType< 3 >::Type ConstAngularType
Definition: motion-tpl.hpp:26
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef MotionDense< MotionTpl > Base
Definition: motion-tpl.hpp:43
Eigen::Matrix< Scalar, 3, 1, _Options > Vector3
Definition: motion-tpl.hpp:15
static MotionTpl Zero()
Definition: motion-tpl.hpp:91
MotionPlain __mult__(const OtherScalar &alpha) const
Definition: motion-tpl.hpp:152
Vector6::template ConstFixedSegmentReturnType< 3 >::Type ConstLinearType
Definition: motion-tpl.hpp:25
Vector6::template FixedSegmentReturnType< 3 >::Type LinearType
Definition: motion-tpl.hpp:23
Vector6::template FixedSegmentReturnType< 3 >::Type AngularType
Definition: motion-tpl.hpp:24
MotionTpl(const Eigen::MatrixBase< V1 > &v, const Eigen::MatrixBase< V2 > &w)
Definition: motion-tpl.hpp:62
LinearType linear_impl()
Definition: motion-tpl.hpp:103
#define PINOCCHIO_EIGEN_REF_TYPE(D)
PlainReturnType plain() const
Definition: motion-tpl.hpp:94
void linear_impl(const Eigen::MatrixBase< V3 > &v)
Definition: motion-tpl.hpp:112
Main pinocchio namespace.
Definition: timings.cpp:28
MotionPlain __minus__(const MotionRef< Vector6ArgType > &v) const
Definition: motion-tpl.hpp:132
MotionTpl(const Eigen::MatrixBase< V6 > &v)
Definition: motion-tpl.hpp:70
MotionRef< Vector6 > ref()
Definition: motion-tpl.hpp:155
res
Common traits structure to fully define base classes for CRTP.
Definition: src/fwd.hpp:44
MotionPlain __minus__(const MotionTpl< Scalar, O2 > &v) const
Definition: motion-tpl.hpp:128
MotionTpl & __pequ__(const MotionTpl< Scalar, O2 > &v)
Definition: motion-tpl.hpp:136
static MotionTpl Random()
Definition: motion-tpl.hpp:92
w
Definition: ur5x4.py:45
AngularType angular_impl()
Definition: motion-tpl.hpp:102
Eigen::Matrix< Scalar, 6, 6, _Options > Matrix6
Definition: motion-tpl.hpp:18
MotionPlain __plus__(const MotionRef< Vector6ArgType > &v) const
Definition: motion-tpl.hpp:124
MotionTpl(const MotionDense< M2 > &clone)
Definition: motion-tpl.hpp:83


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:32