5 #ifndef __pinocchio_motion_dense_hpp__ 6 #define __pinocchio_motion_dense_hpp__ 8 #include "pinocchio/spatial/skew.hpp" 13 template<
typename Derived>
19 template<
typename Derived,
typename MotionDerived>
25 template<
typename Derived>
30 MOTION_TYPEDEF_TPL(Derived);
39 Derived & setZero() { linear().setZero(); angular().setZero();
return derived(); }
40 Derived & setRandom() { linear().setRandom(); angular().setRandom();
return derived(); }
42 ActionMatrixType toActionMatrix_impl()
const 45 X.template block <3,3> (ANGULAR, ANGULAR) = X.template block <3,3> (LINEAR, LINEAR) =
skew(angular());
46 X.template block <3,3> (LINEAR, ANGULAR) =
skew(linear());
47 X.template block <3,3> (ANGULAR, LINEAR).setZero();
52 ActionMatrixType toDualActionMatrix_impl()
const 55 X.template block <3,3> (ANGULAR, ANGULAR) = X.template block <3,3> (LINEAR, LINEAR) =
skew(angular());
56 X.template block <3,3> (ANGULAR, LINEAR) =
skew(linear());
57 X.template block <3,3> (LINEAR, ANGULAR).setZero();
64 {
return linear() == other.linear() && angular() == other.angular(); }
68 {
return other.derived() == derived(); }
74 linear() = other.linear();
75 angular() = other.angular();
82 other.derived().setTo(derived());
87 Derived & operator=(
const Eigen::MatrixBase<V6> & v)
89 EIGEN_STATIC_ASSERT_VECTOR_ONLY(V6); assert(v.size() == 6);
90 linear() = v.template segment<3>(LINEAR);
91 angular() = v.template segment<3>(ANGULAR);
95 MotionPlain operator-()
const {
return derived().__opposite__(); }
97 MotionPlain operator+(
const MotionDense<M1> & v)
const {
return derived().__plus__(v.derived()); }
99 MotionPlain operator-(
const MotionDense<M1> & v)
const {
return derived().__minus__(v.derived()); }
101 template<
typename M1>
102 Derived & operator+=(
const MotionDense<M1> & v) {
return derived().__pequ__(v.derived()); }
103 template<
typename M1>
105 { v.derived().addTo(derived());
return derived(); }
107 template<
typename M1>
108 Derived & operator-=(
const MotionDense<M1> & v) {
return derived().__mequ__(v.derived()); }
110 MotionPlain __opposite__()
const {
return MotionPlain(-linear(),-angular()); }
112 template<
typename M1>
114 {
return MotionPlain(linear()+v.linear(), angular()+v.angular()); }
116 template<
typename M1>
118 {
return MotionPlain(linear()-v.linear(), angular()-v.angular()); }
120 template<
typename M1>
122 { linear() += v.linear(); angular() += v.angular();
return derived(); }
124 template<
typename M1>
126 { linear() -= v.linear(); angular() -= v.angular();
return derived(); }
128 template<
typename OtherScalar>
129 MotionPlain __mult__(
const OtherScalar & alpha)
const 130 {
return MotionPlain(alpha*linear(),alpha*angular()); }
132 template<
typename OtherScalar>
133 MotionPlain __div__(
const OtherScalar & alpha)
const 134 {
return derived().__mult__((OtherScalar)(1)/alpha); }
136 template<
typename F1>
138 {
return phi.
linear().dot(linear()) + phi.
angular().dot(angular()); }
143 return d.motionAction(derived());
146 template<
typename M1,
typename M2>
149 mout.linear() = v.linear().cross(angular())+v.angular().cross(linear());
150 mout.angular() = v.angular().cross(angular());
153 template<
typename M1>
161 template<
typename M2>
162 bool isApprox(
const MotionDense<M2> & m2,
const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
const 164 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 bool isZero_impl(
const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
const 175 return linear().isZero(prec) && angular().isZero(prec);
178 template<
typename S2,
int O2,
typename D2>
181 v.angular().noalias() = m.rotation()*angular();
182 v.linear().noalias() = m.rotation()*linear() + m.translation().cross(v.angular());
185 template<
typename S2,
int O2>
190 se3Action_impl(m,res);
194 template<
typename S2,
int O2,
typename D2>
197 v.linear().noalias() = m.rotation().transpose()*(linear()-m.translation().cross(angular()));
198 v.angular().noalias() = m.rotation().transpose()*angular();
201 template<
typename S2,
int O2>
206 se3ActionInverse_impl(m,res);
210 void disp_impl(std::ostream & os)
const 213 <<
" v = " << linear().transpose () << std::endl
214 <<
" w = " << angular().transpose () << std::endl;
218 MotionRefType
ref() {
return derived().ref(); }
223 template<
typename M1,
typename M2>
226 {
return v1.derived().cross(v2.derived()); }
228 template<
typename M1,
typename F1>
231 {
return v.derived().cross(f.derived()); }
233 template<
typename M1>
240 #endif // ifndef __pinocchio_motion_dense_hpp__
Return type of the ation of a Motion onto an object of type D.
ConstAngularType angular() const
Return the angular part of the force vector.
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...
ConstLinearType linear() const
Return the linear part of the force vector.
MultiplicationOp< InertiaTpl< Scalar, Options >, ConstraintDerived >::ReturnType operator*(const InertiaTpl< Scalar, Options > &Y, const ConstraintBase< ConstraintDerived > &constraint)
.