6 #ifndef __pinocchio_spatial_motion_tpl_hpp__
7 #define __pinocchio_spatial_motion_tpl_hpp__
11 template<
typename _Scalar,
int _Options>
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;
39 template<
typename _Scalar,
int _Options>
43 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
51 using Base::operator=;
56 using Base::__minus__;
58 using Base::__opposite__;
67 template<
typename V1,
typename V2>
68 MotionTpl(
const Eigen::MatrixBase<V1> & v,
const Eigen::MatrixBase<V2> & w)
70 EIGEN_STATIC_ASSERT_VECTOR_ONLY(V1);
71 EIGEN_STATIC_ASSERT_VECTOR_ONLY(V2);
77 explicit MotionTpl(
const Eigen::MatrixBase<V6> & v)
80 EIGEN_STATIC_ASSERT_VECTOR_ONLY(V6);
88 template<
typename S2,
int O2>
91 *
this = other.template cast<Scalar>();
96 : m_data(clone.toVector())
103 typename std::enable_if<!std::is_convertible<MotionDense<M2>,
MotionTpl>::value,
bool>::type =
107 linear() = clone.linear();
108 angular() = clone.angular();
117 typename std::enable_if<!std::is_convertible<MotionBase<M2>,
MotionTpl>::value,
bool>::type =
131 m_data = clone.toVector();
140 static MotionTpl Random()
142 return MotionTpl(Vector6::Random());
145 inline PlainReturnType plain()
const
150 ToVectorConstReturnType toVector_impl()
const
154 ToVectorReturnType toVector_impl()
160 ConstAngularType angular_impl()
const
162 return m_data.template segment<3>(ANGULAR);
164 ConstLinearType linear_impl()
const
166 return m_data.template segment<3>(LINEAR);
168 AngularType angular_impl()
170 return m_data.template segment<3>(ANGULAR);
172 LinearType linear_impl()
174 return m_data.template segment<3>(LINEAR);
177 template<
typename V3>
178 void angular_impl(
const Eigen::MatrixBase<V3> & w)
180 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3, 3);
183 template<
typename V3>
184 void linear_impl(
const Eigen::MatrixBase<V3> & v)
186 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3, 3);
192 MotionPlain __plus__(
const MotionTpl<Scalar, O2> & v)
const
194 return MotionPlain(m_data + v.toVector());
197 template<
typename Vector6ArgType>
198 MotionPlain __plus__(
const MotionRef<Vector6ArgType> & v)
const
200 return MotionPlain(m_data + v.toVector());
204 MotionPlain __minus__(
const MotionTpl<Scalar, O2> & v)
const
206 return MotionPlain(m_data - v.toVector());
209 template<
typename Vector6ArgType>
210 MotionPlain __minus__(
const MotionRef<Vector6ArgType> & v)
const
212 return MotionPlain(m_data - v.toVector());
216 MotionTpl & __pequ__(
const MotionTpl<Scalar, O2> & v)
218 m_data += v.toVector();
222 template<
typename Vector6ArgType>
223 MotionTpl & __pequ__(
const MotionRef<Vector6ArgType> & v)
225 m_data += v.toVector();
230 MotionTpl & __mequ__(
const MotionTpl<Scalar, O2> & v)
232 m_data -= v.toVector();
236 template<
typename Vector6ArgType>
237 MotionTpl & __mequ__(
const MotionRef<Vector6ArgType> & v)
239 m_data -= v.toVector();
243 template<
typename OtherScalar>
244 MotionPlain __mult__(
const OtherScalar & alpha)
const
246 return MotionPlain(alpha * m_data);
249 MotionRef<Vector6> ref()
251 return MotionRef<Vector6>(m_data);
255 template<
typename NewScalar>
259 ReturnType res(linear().
template cast<NewScalar>(), angular().
template cast<NewScalar>());
MotionTpl & operator=(const MotionTpl &clone)
Copy assignment operator.
MotionTpl< NewScalar, Options > cast() const
Main pinocchio namespace.
Common traits structure to fully define base classes for CRTP.