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


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