5 #ifndef __pinocchio_motion_dense_hpp__ 6 #define __pinocchio_motion_dense_hpp__ 8 #include "pinocchio/spatial/skew.hpp" 15 template<
typename Derived>
16 struct SE3GroupAction< MotionDense<Derived> >
18 typedef typename SE3GroupAction< Derived >::ReturnType ReturnType;
21 template<
typename Derived,
typename MotionDerived>
22 struct MotionAlgebraAction< MotionDense<Derived>, MotionDerived >
24 typedef typename MotionAlgebraAction< Derived, MotionDerived >::ReturnType ReturnType;
28 template<
typename Derived>
29 class MotionDense :
public MotionBase<Derived>
32 typedef MotionBase<Derived> Base;
33 MOTION_TYPEDEF_TPL(Derived);
34 typedef typename traits<Derived>::MotionRefType MotionRefType;
41 Derived & setZero() { linear().setZero(); angular().setZero();
return derived(); }
42 Derived & setRandom() { linear().setRandom(); angular().setRandom();
return derived(); }
44 ActionMatrixType toActionMatrix_impl()
const 47 X.template block <3,3> (ANGULAR, ANGULAR) = X.template block <3,3> (LINEAR, LINEAR) =
skew(angular());
48 X.template block <3,3> (LINEAR, ANGULAR) =
skew(linear());
49 X.template block <3,3> (ANGULAR, LINEAR).setZero();
54 ActionMatrixType toDualActionMatrix_impl()
const 57 X.template block <3,3> (ANGULAR, ANGULAR) = X.template block <3,3> (LINEAR, LINEAR) =
skew(angular());
58 X.template block <3,3> (ANGULAR, LINEAR) =
skew(linear());
59 X.template block <3,3> (LINEAR, ANGULAR).setZero();
65 bool isEqual_impl(
const MotionDense<D2> & other)
const 66 {
return linear() == other.linear() && angular() == other.angular(); }
69 bool isEqual_impl(
const MotionBase<D2> & other)
const 70 {
return other.derived() == derived(); }
74 Derived & operator=(
const MotionDense<D2> & other)
76 linear() = other.linear();
77 angular() = other.angular();
82 Derived & operator=(
const MotionBase<D2> & other)
84 other.derived().setTo(derived());
89 Derived & operator=(
const Eigen::MatrixBase<V6> & v)
91 EIGEN_STATIC_ASSERT_VECTOR_ONLY(V6); assert(v.size() == 6);
92 linear() = v.template segment<3>(LINEAR);
93 angular() = v.template segment<3>(ANGULAR);
97 MotionPlain operator-()
const {
return derived().__opposite__(); }
99 MotionPlain operator+(
const MotionDense<M1> & v)
const {
return derived().__plus__(v.derived()); }
100 template<
typename M1>
101 MotionPlain operator-(
const MotionDense<M1> & v)
const {
return derived().__minus__(v.derived()); }
103 template<
typename M1>
104 Derived & operator+=(
const MotionDense<M1> & v) {
return derived().__pequ__(v.derived()); }
105 template<
typename M1>
106 Derived & operator+=(
const MotionBase<M1> & v)
107 { v.derived().addTo(derived());
return derived(); }
109 template<
typename M1>
110 Derived & operator-=(
const MotionDense<M1> & v) {
return derived().__mequ__(v.derived()); }
112 MotionPlain __opposite__()
const {
return MotionPlain(-linear(),-angular()); }
114 template<
typename M1>
115 MotionPlain __plus__(
const MotionDense<M1> & v)
const 116 {
return MotionPlain(linear()+v.linear(), angular()+v.angular()); }
118 template<
typename M1>
119 MotionPlain __minus__(
const MotionDense<M1> & v)
const 120 {
return MotionPlain(linear()-v.linear(), angular()-v.angular()); }
122 template<
typename M1>
123 Derived & __pequ__(
const MotionDense<M1> & v)
124 { linear() += v.linear(); angular() += v.angular();
return derived(); }
126 template<
typename M1>
127 Derived & __mequ__(
const MotionDense<M1> & v)
128 { linear() -= v.linear(); angular() -= v.angular();
return derived(); }
130 template<
typename OtherScalar>
131 MotionPlain __mult__(
const OtherScalar & alpha)
const 132 {
return MotionPlain(alpha*linear(),alpha*angular()); }
134 template<
typename OtherScalar>
135 MotionPlain __div__(
const OtherScalar & alpha)
const 136 {
return derived().__mult__((OtherScalar)(1)/alpha); }
138 template<
typename F1>
139 Scalar dot(
const ForceBase<F1> & phi)
const 140 {
return phi.linear().dot(linear()) + phi.angular().dot(angular()); }
143 typename internal::MotionAlgebraAction<D,Derived>::ReturnType cross_impl(
const D & d)
const 145 return d.motionAction(derived());
148 template<
typename M1,
typename M2>
149 void motionAction(
const MotionDense<M1> & v, MotionDense<M2> & mout)
const 151 mout.linear() = v.linear().cross(angular())+v.angular().cross(linear());
152 mout.angular() = v.angular().cross(angular());
155 template<
typename M1>
156 MotionPlain motionAction(
const MotionDense<M1> & v)
const 163 template<
typename M2>
164 bool isApprox(
const MotionDense<M2> & m2,
const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
const 165 {
return derived().isApprox_impl(m2, prec);}
167 template<
typename D2>
168 bool isApprox_impl(
const MotionDense<D2> & m2,
const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
const 170 return linear().isApprox(m2.linear(), prec) && angular().isApprox(m2.angular(), prec);
173 template<
typename S2,
int O2,
typename D2>
174 void se3Action_impl(
const SE3Tpl<S2,O2> & m, MotionDense<D2> & v)
const 176 v.angular().noalias() = m.rotation()*angular();
177 v.linear().noalias() = m.rotation()*linear() + m.translation().cross(v.angular());
180 template<
typename S2,
int O2>
181 MotionPlain se3Action_impl(
const SE3Tpl<S2,O2> & m)
const 184 se3Action_impl(m,res);
188 template<
typename S2,
int O2,
typename D2>
190 void se3ActionInverse_impl(
const SE3Tpl<S2,O2> & m, MotionDense<D2> & v)
const 192 v.linear().noalias() = m.rotation().transpose()*(linear()-m.translation().cross(angular()));
193 v.angular().noalias() = m.rotation().transpose()*angular();
196 template<
typename S2,
int O2>
197 MotionPlain se3ActionInverse_impl(
const SE3Tpl<S2,O2> & m)
const 200 se3ActionInverse_impl(m,res);
204 void disp_impl(std::ostream & os)
const 207 <<
" v = " << linear().transpose () << std::endl
208 <<
" w = " << angular().transpose () << std::endl;
212 MotionRefType
ref() {
return derived().ref(); }
217 template<
typename M1,
typename M2>
220 {
return v1.derived().cross(v2.derived()); }
222 template<
typename M1,
typename F1>
225 {
return v.derived().cross(f.derived()); }
227 template<
typename M1>
234 #endif // ifndef __pinocchio_motion_dense_hpp__
Base interface for forces representation.
Main pinocchio namespace.
Common traits structure to fully define base classes for CRTP.
void skew(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
Computes the skew representation of a given 3d vector, i.e. the antisymmetric matrix representation o...