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_spatial_motion_tpl_hpp__
7 #define __pinocchio_spatial_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;
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  {
31  LINEAR = 0,
32  ANGULAR = 3,
33  Options = _Options
34  };
35 
37  }; // traits MotionTpl
38 
39  template<typename _Scalar, int _Options>
40  class MotionTpl : public MotionDense<MotionTpl<_Scalar, _Options>>
41  {
42  public:
43  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
46  enum
47  {
48  Options = _Options
49  };
50 
51  using Base::operator=;
52  using Base::angular;
53  using Base::linear;
54 
55  using Base::__mequ__;
56  using Base::__minus__;
57  using Base::__mult__;
58  using Base::__opposite__;
59  using Base::__pequ__;
60  using Base::__plus__;
61 
62  // Constructors
64  {
65  }
66 
67  template<typename V1, typename V2>
68  MotionTpl(const Eigen::MatrixBase<V1> & v, const Eigen::MatrixBase<V2> & w)
69  {
70  EIGEN_STATIC_ASSERT_VECTOR_ONLY(V1);
71  EIGEN_STATIC_ASSERT_VECTOR_ONLY(V2);
72  linear() = v;
73  angular() = w;
74  }
75 
76  template<typename V6>
77  explicit MotionTpl(const Eigen::MatrixBase<V6> & v)
78  : m_data(v)
79  {
80  EIGEN_STATIC_ASSERT_VECTOR_ONLY(V6);
81  }
82 
83  MotionTpl(const MotionTpl & other)
84  {
85  *this = other;
86  }
87 
88  template<typename S2, int O2>
89  explicit MotionTpl(const MotionTpl<S2, O2> & other)
90  {
91  *this = other.template cast<Scalar>();
92  }
93 
94  template<int O2>
96  : m_data(clone.toVector())
97  {
98  }
99 
100  // Same explanation as converting constructor from MotionBase
101  template<
102  typename M2,
103  typename std::enable_if<!std::is_convertible<MotionDense<M2>, MotionTpl>::value, bool>::type =
104  true>
105  explicit MotionTpl(const MotionDense<M2> & clone)
106  {
107  linear() = clone.linear();
108  angular() = clone.angular();
109  }
110 
111  // MotionBase implement a conversion function to PlainReturnType.
112  // Usually, PlainReturnType is defined as MotionTpl.
113  // In this case, this converting constructor is redundant and
114  // create a warning with -Wconversion
115  template<
116  typename M2,
117  typename std::enable_if<!std::is_convertible<MotionBase<M2>, MotionTpl>::value, bool>::type =
118  true>
119  explicit MotionTpl(const MotionBase<M2> & clone)
120  {
121  *this = clone;
122  }
123 
129  MotionTpl & operator=(const MotionTpl & clone) // Copy assignment operator
130  {
131  m_data = clone.toVector();
132  return *this;
133  }
134 
135  // initializers
136  static MotionTpl Zero()
137  {
138  return MotionTpl(Vector6::Zero());
139  }
140  static MotionTpl Random()
141  {
142  return MotionTpl(Vector6::Random());
143  }
144 
145  inline PlainReturnType plain() const
146  {
147  return *this;
148  }
149 
150  ToVectorConstReturnType toVector_impl() const
151  {
152  return m_data;
153  }
154  ToVectorReturnType toVector_impl()
155  {
156  return m_data;
157  }
158 
159  // Getters
160  ConstAngularType angular_impl() const
161  {
162  return m_data.template segment<3>(ANGULAR);
163  }
164  ConstLinearType linear_impl() const
165  {
166  return m_data.template segment<3>(LINEAR);
167  }
168  AngularType angular_impl()
169  {
170  return m_data.template segment<3>(ANGULAR);
171  }
172  LinearType linear_impl()
173  {
174  return m_data.template segment<3>(LINEAR);
175  }
176 
177  template<typename V3>
178  void angular_impl(const Eigen::MatrixBase<V3> & w)
179  {
180  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3, 3);
181  angular_impl() = w;
182  }
183  template<typename V3>
184  void linear_impl(const Eigen::MatrixBase<V3> & v)
185  {
186  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3, 3);
187  linear_impl() = v;
188  }
189 
190  // Specific operators for MotionTpl and MotionRef
191  template<int O2>
192  MotionPlain __plus__(const MotionTpl<Scalar, O2> & v) const
193  {
194  return MotionPlain(m_data + v.toVector());
195  }
196 
197  template<typename Vector6ArgType>
198  MotionPlain __plus__(const MotionRef<Vector6ArgType> & v) const
199  {
200  return MotionPlain(m_data + v.toVector());
201  }
202 
203  template<int O2>
204  MotionPlain __minus__(const MotionTpl<Scalar, O2> & v) const
205  {
206  return MotionPlain(m_data - v.toVector());
207  }
208 
209  template<typename Vector6ArgType>
210  MotionPlain __minus__(const MotionRef<Vector6ArgType> & v) const
211  {
212  return MotionPlain(m_data - v.toVector());
213  }
214 
215  template<int O2>
217  {
218  m_data += v.toVector();
219  return *this;
220  }
221 
222  template<typename Vector6ArgType>
224  {
225  m_data += v.toVector();
226  return *this;
227  }
228 
229  template<int O2>
231  {
232  m_data -= v.toVector();
233  return *this;
234  }
235 
236  template<typename Vector6ArgType>
238  {
239  m_data -= v.toVector();
240  return *this;
241  }
242 
243  template<typename OtherScalar>
244  MotionPlain __mult__(const OtherScalar & alpha) const
245  {
246  return MotionPlain(alpha * m_data);
247  }
248 
250  {
251  return MotionRef<Vector6>(m_data);
252  }
253 
255  template<typename NewScalar>
257  {
258  typedef MotionTpl<NewScalar, Options> ReturnType;
259  ReturnType res(linear().template cast<NewScalar>(), angular().template cast<NewScalar>());
260  return res;
261  }
262 
263  protected:
264  Vector6 m_data;
265 
266  }; // class MotionTpl
267 
268 } // namespace pinocchio
269 
270 #endif // ifndef __pinocchio_spatial_motion_tpl_hpp__
pinocchio::MotionTpl::linear_impl
ConstLinearType linear_impl() const
Definition: motion-tpl.hpp:164
pinocchio::traits< MotionTpl< _Scalar, _Options > >::Matrix4
Eigen::Matrix< Scalar, 4, 4, _Options > Matrix4
Definition: motion-tpl.hpp:17
pinocchio::traits< MotionTpl< _Scalar, _Options > >::LinearType
Vector6::template FixedSegmentReturnType< 3 >::Type LinearType
Definition: motion-tpl.hpp:23
pinocchio::MotionTpl::MotionTpl
MotionTpl(const MotionTpl< S2, O2 > &other)
Definition: motion-tpl.hpp:89
pinocchio::MotionTpl::cast
MotionTpl< NewScalar, Options > cast() const
Definition: motion-tpl.hpp:256
pinocchio::MotionTpl::__pequ__
MotionTpl & __pequ__(const MotionTpl< Scalar, O2 > &v)
Definition: motion-tpl.hpp:216
pinocchio::Options
Options
Definition: joint-configuration.hpp:1116
pinocchio::MotionTpl::operator=
MotionTpl & operator=(const MotionTpl &clone)
Copy assignment operator.
Definition: motion-tpl.hpp:129
pinocchio::MotionTpl::__mult__
MotionPlain __mult__(const OtherScalar &alpha) const
Definition: motion-tpl.hpp:244
pinocchio::PINOCCHIO_EIGEN_REF_CONST_TYPE
PINOCCHIO_EIGEN_REF_CONST_TYPE(Matrix6Like) operator*(const Eigen
Definition: joint-free-flyer.hpp:144
pinocchio::traits< MotionTpl< _Scalar, _Options > >::ConstLinearType
Vector6::template ConstFixedSegmentReturnType< 3 >::Type ConstLinearType
Definition: motion-tpl.hpp:25
pinocchio::traits< MotionTpl< _Scalar, _Options > >::HomogeneousMatrixType
Matrix4 HomogeneousMatrixType
Definition: motion-tpl.hpp:20
pinocchio::MotionDense
Definition: context/casadi.hpp:36
pinocchio::res
ReturnType res
Definition: spatial/classic-acceleration.hpp:57
pinocchio::traits< MotionTpl< _Scalar, _Options > >::MotionRefType
MotionRef< Vector6 > MotionRefType
Definition: motion-tpl.hpp:36
pinocchio::MotionTpl::linear_impl
LinearType linear_impl()
Definition: motion-tpl.hpp:172
pinocchio::MotionBase
Definition: spatial/fwd.hpp:42
pinocchio::MotionTpl::m_data
Vector6 m_data
Definition: motion-tpl.hpp:264
simulation-pendulum.type
type
Definition: simulation-pendulum.py:18
pinocchio::MotionTpl::__pequ__
MotionTpl & __pequ__(const MotionRef< Vector6ArgType > &v)
Definition: motion-tpl.hpp:223
pinocchio::traits< MotionTpl< _Scalar, _Options > >::MotionPlain
MotionTpl< Scalar, _Options > MotionPlain
Definition: motion-tpl.hpp:27
pinocchio::MotionTpl::angular_impl
ConstAngularType angular_impl() const
Definition: motion-tpl.hpp:160
pinocchio::traits< MotionTpl< _Scalar, _Options > >::ConstAngularType
Vector6::template ConstFixedSegmentReturnType< 3 >::Type ConstAngularType
Definition: motion-tpl.hpp:26
pinocchio::MotionTpl::__minus__
MotionPlain __minus__(const MotionTpl< Scalar, O2 > &v) const
Definition: motion-tpl.hpp:204
pinocchio::traits< MotionTpl< _Scalar, _Options > >::Vector6
Eigen::Matrix< Scalar, 6, 1, _Options > Vector6
Definition: motion-tpl.hpp:16
pinocchio::MotionTpl::plain
PlainReturnType plain() const
Definition: motion-tpl.hpp:145
pinocchio::MotionTpl::linear_impl
void linear_impl(const Eigen::MatrixBase< V3 > &v)
Definition: motion-tpl.hpp:184
reachable-workspace-with-collisions.alpha
float alpha
Definition: reachable-workspace-with-collisions.py:159
pinocchio::MotionTpl::MotionTpl
MotionTpl(const Eigen::MatrixBase< V6 > &v)
Definition: motion-tpl.hpp:77
pinocchio::MotionTpl::ref
MotionRef< Vector6 > ref()
Definition: motion-tpl.hpp:249
pinocchio::traits< MotionTpl< _Scalar, _Options > >::Matrix6
Eigen::Matrix< Scalar, 6, 6, _Options > Matrix6
Definition: motion-tpl.hpp:18
pinocchio::MotionTpl::MotionTpl
MotionTpl(const MotionTpl &other)
Definition: motion-tpl.hpp:83
pinocchio::traits< MotionTpl< _Scalar, _Options > >::Vector3
Eigen::Matrix< Scalar, 3, 1, _Options > Vector3
Definition: motion-tpl.hpp:15
pinocchio::MotionTpl::MotionTpl
MotionTpl(const MotionDense< M2 > &clone)
Definition: motion-tpl.hpp:105
pinocchio::traits< MotionTpl< _Scalar, _Options > >::AngularType
Vector6::template FixedSegmentReturnType< 3 >::Type AngularType
Definition: motion-tpl.hpp:24
pinocchio::traits< MotionTpl< _Scalar, _Options > >::Scalar
_Scalar Scalar
Definition: motion-tpl.hpp:14
pinocchio::MotionTpl::toVector_impl
ToVectorReturnType toVector_impl()
Definition: motion-tpl.hpp:154
ur5x4.w
w
Definition: ur5x4.py:45
pinocchio::MotionTpl::angular_impl
AngularType angular_impl()
Definition: motion-tpl.hpp:168
pinocchio::MotionTpl::Random
static MotionTpl Random()
Definition: motion-tpl.hpp:140
clone
virtual CollisionGeometry * clone() const=0
pinocchio::v
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
Definition: joint-configuration.hpp:1118
pinocchio::MotionTpl::MotionTpl
MotionTpl(const MotionTpl< Scalar, O2 > &clone)
Definition: motion-tpl.hpp:95
pinocchio::MotionTpl::__plus__
MotionPlain __plus__(const MotionRef< Vector6ArgType > &v) const
Definition: motion-tpl.hpp:198
pinocchio::MotionTpl::MotionTpl
MotionTpl()
Definition: motion-tpl.hpp:63
pinocchio::MotionTpl::Zero
static MotionTpl Zero()
Definition: motion-tpl.hpp:136
pinocchio::MotionTpl::Base
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef MotionDense< MotionTpl > Base
Definition: motion-tpl.hpp:44
pinocchio::MotionTpl::__mequ__
MotionTpl & __mequ__(const MotionTpl< Scalar, O2 > &v)
Definition: motion-tpl.hpp:230
pinocchio::traits< MotionTpl< _Scalar, _Options > >::ActionMatrixType
Matrix6 ActionMatrixType
Definition: motion-tpl.hpp:19
pinocchio::MotionTpl::angular_impl
void angular_impl(const Eigen::MatrixBase< V3 > &w)
Definition: motion-tpl.hpp:178
pinocchio::traits
Common traits structure to fully define base classes for CRTP.
Definition: fwd.hpp:71
PINOCCHIO_EIGEN_REF_TYPE
#define PINOCCHIO_EIGEN_REF_TYPE(D)
Definition: eigen-macros.hpp:32
pinocchio::MotionTpl
Definition: context/casadi.hpp:27
pinocchio::MotionTpl::MotionTpl
MotionTpl(const Eigen::MatrixBase< V1 > &v, const Eigen::MatrixBase< V2 > &w)
Definition: motion-tpl.hpp:68
pinocchio::MotionRef
Definition: context/casadi.hpp:38
pinocchio::MotionTpl::__mequ__
MotionTpl & __mequ__(const MotionRef< Vector6ArgType > &v)
Definition: motion-tpl.hpp:237
pinocchio::traits< MotionTpl< _Scalar, _Options > >::PlainReturnType
const typedef MotionPlain & PlainReturnType
Definition: motion-tpl.hpp:28
pinocchio::MotionTpl::MotionTpl
MotionTpl(const MotionBase< M2 > &clone)
Definition: motion-tpl.hpp:119
pinocchio::MotionTpl::MOTION_TYPEDEF_TPL
MOTION_TYPEDEF_TPL(MotionTpl)
pinocchio::MotionTpl::toVector_impl
ToVectorConstReturnType toVector_impl() const
Definition: motion-tpl.hpp:150
pinocchio::MotionTpl::__minus__
MotionPlain __minus__(const MotionRef< Vector6ArgType > &v) const
Definition: motion-tpl.hpp:210
pinocchio::MotionTpl::Options
@ Options
Definition: motion-tpl.hpp:48
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::MotionTpl::__plus__
MotionPlain __plus__(const MotionTpl< Scalar, O2 > &v) const
Definition: motion-tpl.hpp:192


pinocchio
Author(s):
autogenerated on Sat Jun 1 2024 02:40:37