5 #ifndef __pinocchio_motion_ref_hpp__
6 #define __pinocchio_motion_ref_hpp__
11 template<
typename Vector6ArgType>
14 typedef typename Vector6ArgType::Scalar Scalar;
15 typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(Vector6ArgType) Vector6;
19 Options = Vector6::Options
21 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
22 typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4;
23 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
24 typedef Matrix6 ActionMatrixType;
25 typedef Matrix4 HomogeneousMatrixType;
26 typedef typename Vector6ArgType::template FixedSegmentReturnType<3>::Type LinearType;
27 typedef typename Vector6ArgType::template FixedSegmentReturnType<3>::Type AngularType;
28 typedef typename Vector6ArgType::template ConstFixedSegmentReturnType<3>::Type ConstLinearType;
29 typedef typename Vector6ArgType::template ConstFixedSegmentReturnType<3>::Type ConstAngularType;
32 typedef typename PINOCCHIO_EIGEN_REF_TYPE(Vector6ArgType) DataRefType;
33 typedef DataRefType ToVectorReturnType;
34 typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6ArgType) ConstDataRefType;
35 typedef ConstDataRefType ToVectorConstReturnType;
40 template<
typename Vector6ArgType>
46 template<
typename Vector6ArgType,
typename MotionDerived>
54 template<
typename Vector6ArgType,
typename Scalar>
55 struct RHSScalarMultiplication<
MotionRef<Vector6ArgType>, Scalar >
60 template<
typename Vector6ArgType,
typename Scalar>
61 struct LHSScalarMultiplication< MotionRef<Vector6ArgType>, Scalar >
63 typedef typename traits< MotionRef<Vector6ArgType> >::MotionPlain ReturnType;
67 template<
typename Vector6ArgType>
68 class MotionRef :
public MotionDense< MotionRef<Vector6ArgType> >
71 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
72 typedef MotionDense<MotionRef> Base;
73 typedef typename traits<MotionRef>::DataRefType DataRefType;
76 using Base::operator=;
81 using Base::__opposite__;
82 using Base::__minus__;
88 MotionRef(
typename PINOCCHIO_EIGEN_REF_TYPE(Vector6ArgType) v_like)
91 EIGEN_STATIC_ASSERT(Vector6ArgType::ColsAtCompileTime == 1,
92 YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX);
93 assert(v_like.size() == 6);
101 ToVectorConstReturnType toVector_impl()
const {
return m_ref; }
102 ToVectorReturnType toVector_impl() {
return m_ref; }
105 ConstAngularType angular_impl()
const {
return ConstAngularType(m_ref.derived(),ANGULAR); }
106 ConstLinearType linear_impl()
const {
return ConstLinearType(m_ref.derived(),LINEAR); }
107 AngularType angular_impl() {
return m_ref.template segment<3> (ANGULAR); }
108 LinearType linear_impl() {
return m_ref.template segment<3> (LINEAR); }
110 template<
typename V3>
111 void angular_impl(
const Eigen::MatrixBase<V3> & w)
113 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3,3);
117 template<
typename V3>
118 void linear_impl(
const Eigen::MatrixBase<V3> & v)
120 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3,3);
125 template<
typename S1,
int O1>
126 MotionPlain __plus__(
const MotionTpl<S1,O1> & v)
const
127 {
return MotionPlain(m_ref+v.toVector()); }
129 template<
typename Vector6Like>
130 MotionPlain __plus__(
const MotionRef<Vector6ArgType> & v)
const
131 {
return MotionPlain(m_ref+v.toVector()); }
133 template<
typename S1,
int O1>
134 MotionPlain __minus__(
const MotionTpl<S1,O1> & v)
const
135 {
return MotionPlain(m_ref-v.toVector()); }
137 template<
typename Vector6Like>
138 MotionPlain __minus__(
const MotionRef<Vector6ArgType> & v)
const
139 {
return MotionPlain(m_ref-v.toVector()); }
141 template<
typename S1,
int O1>
142 MotionRef & __pequ__(
const MotionTpl<S1,O1> & v)
143 { m_ref += v.toVector();
return *
this; }
145 template<
typename Vector6Like>
146 MotionRef & __pequ__(
const MotionRef<Vector6ArgType> & v)
147 { m_ref += v.toVector();
return *
this; }
149 template<
typename S1,
int O1>
150 MotionRef & __mequ__(
const MotionTpl<S1,O1> & v)
151 { m_ref -= v.toVector();
return *
this; }
153 template<
typename Vector6Like>
154 MotionRef & __mequ__(
const MotionRef<Vector6ArgType> & v)
155 { m_ref -= v.toVector();
return *
this; }
157 template<
typename OtherScalar>
158 MotionPlain __mult__(
const OtherScalar & alpha)
const
159 {
return MotionPlain(alpha*m_ref); }
163 inline PlainReturnType plain()
const {
return PlainReturnType(m_ref); }
170 template<
typename Vector6ArgType>
173 typedef typename Vector6ArgType::Scalar Scalar;
174 typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(Vector6ArgType) Vector6;
178 Options = Vector6::Options
180 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
181 typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4;
182 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
183 typedef Matrix6 ActionMatrixType;
184 typedef Matrix4 HomogeneousMatrixType;
185 typedef typename Vector6ArgType::template ConstFixedSegmentReturnType<3>::Type ConstLinearType;
186 typedef typename Vector6ArgType::template ConstFixedSegmentReturnType<3>::Type ConstAngularType;
187 typedef ConstLinearType LinearType;
188 typedef ConstAngularType AngularType;
191 typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6ArgType) ConstDataRefType;
192 typedef ConstDataRefType ToVectorConstReturnType;
193 typedef ConstDataRefType DataRefType;
194 typedef DataRefType ToVectorReturnType;
199 template<
typename Vector6ArgType>
201 :
public MotionDense< MotionRef<const Vector6ArgType> >
204 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
209 using Base::operator=;
213 using Base::__plus__;
214 using Base::__opposite__;
215 using Base::__minus__;
216 using Base::__mult__;
218 MotionRef(
typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6ArgType) v_like)
221 EIGEN_STATIC_ASSERT(Vector6ArgType::ColsAtCompileTime == 1,
222 YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX);
223 assert(v_like.size() == 6);
226 ToVectorConstReturnType toVector_impl()
const {
return m_ref; }
229 ConstAngularType angular_impl()
const {
return ConstAngularType(m_ref.derived(),ANGULAR); }
230 ConstLinearType linear_impl()
const {
return ConstLinearType(m_ref.derived(),LINEAR); }
233 template<
typename S1,
int O1>
235 {
return MotionPlain(m_ref+v.toVector()); }
237 template<
typename Vector6Like>
239 {
return MotionPlain(m_ref+v.toVector()); }
241 template<
typename S1,
int O1>
243 {
return MotionPlain(m_ref-v.toVector()); }
245 template<
typename Vector6Like>
247 {
return MotionPlain(m_ref-v.toVector()); }
249 template<
typename OtherScalar>
250 MotionPlain __mult__(
const OtherScalar & alpha)
const
251 {
return MotionPlain(alpha*m_ref); }
253 const MotionRef & ref()
const {
return *
this; }
255 inline PlainReturnType plain()
const {
return PlainReturnType(m_ref); }
264 #endif // ifndef __pinocchio_motion_ref_hpp__