motion-dense.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017-2019 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_motion_dense_hpp__
6 #define __pinocchio_motion_dense_hpp__
7 
8 #include "pinocchio/spatial/skew.hpp"
9 
10 namespace pinocchio
11 {
12 
13  template<typename Derived>
14  struct SE3GroupAction< MotionDense<Derived> >
15  {
17  };
18 
19  template<typename Derived, typename MotionDerived>
20  struct MotionAlgebraAction< MotionDense<Derived>, MotionDerived >
21  {
23  };
24 
25  template<typename Derived>
26  class MotionDense : public MotionBase<Derived>
27  {
28  public:
30  MOTION_TYPEDEF_TPL(Derived);
32 
33  using Base::linear;
34  using Base::angular;
35  using Base::derived;
36  using Base::isApprox;
37  using Base::isZero;
38 
39  Derived & setZero() { linear().setZero(); angular().setZero(); return derived(); }
40  Derived & setRandom() { linear().setRandom(); angular().setRandom(); return derived(); }
41 
42  ActionMatrixType toActionMatrix_impl() const
43  {
44  ActionMatrixType X;
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();
48 
49  return X;
50  }
51 
52  ActionMatrixType toDualActionMatrix_impl() const
53  {
54  ActionMatrixType X;
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();
58 
59  return X;
60  }
61 
62  template<typename D2>
63  bool isEqual_impl(const MotionDense<D2> & other) const
64  { return linear() == other.linear() && angular() == other.angular(); }
65 
66  template<typename D2>
67  bool isEqual_impl(const MotionBase<D2> & other) const
68  { return other.derived() == derived(); }
69 
70  // Arithmetic operators
71  template<typename D2>
72  Derived & operator=(const MotionDense<D2> & other)
73  {
74  linear() = other.linear();
75  angular() = other.angular();
76  return derived();
77  }
78 
79  template<typename D2>
80  Derived & operator=(const MotionBase<D2> & other)
81  {
82  other.derived().setTo(derived());
83  return derived();
84  }
85 
86  template<typename V6>
87  Derived & operator=(const Eigen::MatrixBase<V6> & v)
88  {
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);
92  return derived();
93  }
94 
95  MotionPlain operator-() const { return derived().__opposite__(); }
96  template<typename M1>
97  MotionPlain operator+(const MotionDense<M1> & v) const { return derived().__plus__(v.derived()); }
98  template<typename M1>
99  MotionPlain operator-(const MotionDense<M1> & v) const { return derived().__minus__(v.derived()); }
100 
101  template<typename M1>
102  Derived & operator+=(const MotionDense<M1> & v) { return derived().__pequ__(v.derived()); }
103  template<typename M1>
104  Derived & operator+=(const MotionBase<M1> & v)
105  { v.derived().addTo(derived()); return derived(); }
106 
107  template<typename M1>
108  Derived & operator-=(const MotionDense<M1> & v) { return derived().__mequ__(v.derived()); }
109 
110  MotionPlain __opposite__() const { return MotionPlain(-linear(),-angular()); }
111 
112  template<typename M1>
113  MotionPlain __plus__(const MotionDense<M1> & v) const
114  { return MotionPlain(linear()+v.linear(), angular()+v.angular()); }
115 
116  template<typename M1>
117  MotionPlain __minus__(const MotionDense<M1> & v) const
118  { return MotionPlain(linear()-v.linear(), angular()-v.angular()); }
119 
120  template<typename M1>
121  Derived & __pequ__(const MotionDense<M1> & v)
122  { linear() += v.linear(); angular() += v.angular(); return derived(); }
123 
124  template<typename M1>
125  Derived & __mequ__(const MotionDense<M1> & v)
126  { linear() -= v.linear(); angular() -= v.angular(); return derived(); }
127 
128  template<typename OtherScalar>
129  MotionPlain __mult__(const OtherScalar & alpha) const
130  { return MotionPlain(alpha*linear(),alpha*angular()); }
131 
132  template<typename OtherScalar>
133  MotionPlain __div__(const OtherScalar & alpha) const
134  { return derived().__mult__((OtherScalar)(1)/alpha); }
135 
136  template<typename F1>
137  Scalar dot(const ForceBase<F1> & phi) const
138  { return phi.linear().dot(linear()) + phi.angular().dot(angular()); }
139 
140  template<typename D>
142  {
143  return d.motionAction(derived());
144  }
145 
146  template<typename M1, typename M2>
147  void motionAction(const MotionDense<M1> & v, MotionDense<M2> & mout) const
148  {
149  mout.linear() = v.linear().cross(angular())+v.angular().cross(linear());
150  mout.angular() = v.angular().cross(angular());
151  }
152 
153  template<typename M1>
154  MotionPlain motionAction(const MotionDense<M1> & v) const
155  {
156  MotionPlain res;
157  motionAction(v,res);
158  return res;
159  }
160 
161  template<typename M2>
162  bool isApprox(const MotionDense<M2> & m2, const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
163  {
164  return derived().isApprox_impl(m2, prec);
165  }
166 
167  template<typename D2>
168  bool isApprox_impl(const MotionDense<D2> & m2, const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
169  {
170  return linear().isApprox(m2.linear(), prec) && angular().isApprox(m2.angular(), prec);
171  }
172 
173  bool isZero_impl(const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
174  {
175  return linear().isZero(prec) && angular().isZero(prec);
176  }
177 
178  template<typename S2, int O2, typename D2>
180  {
181  v.angular().noalias() = m.rotation()*angular();
182  v.linear().noalias() = m.rotation()*linear() + m.translation().cross(v.angular());
183  }
184 
185  template<typename S2, int O2>
187  se3Action_impl(const SE3Tpl<S2,O2> & m) const
188  {
190  se3Action_impl(m,res);
191  return res;
192  }
193 
194  template<typename S2, int O2, typename D2>
196  {
197  v.linear().noalias() = m.rotation().transpose()*(linear()-m.translation().cross(angular()));
198  v.angular().noalias() = m.rotation().transpose()*angular();
199  }
200 
201  template<typename S2, int O2>
204  {
206  se3ActionInverse_impl(m,res);
207  return res;
208  }
209 
210  void disp_impl(std::ostream & os) const
211  {
212  os
213  << " v = " << linear().transpose () << std::endl
214  << " w = " << angular().transpose () << std::endl;
215  }
216 
218  MotionRefType ref() { return derived().ref(); }
219 
220  }; // class MotionDense
221 
223  template<typename M1, typename M2>
225  const MotionDense<M2> & v2)
226  { return v1.derived().cross(v2.derived()); }
227 
228  template<typename M1, typename F1>
230  const ForceBase<F1> & f)
231  { return v.derived().cross(f.derived()); }
232 
233  template<typename M1>
234  typename traits<M1>::MotionPlain operator*(const typename traits<M1>::Scalar alpha,
235  const MotionDense<M1> & v)
236  { return v*alpha; }
237 
238 } // namespace pinocchio
239 
240 #endif // ifndef __pinocchio_motion_dense_hpp__
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
bool isZero_impl(const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
MotionPlain __mult__(const OtherScalar &alpha) const
Derived & operator-=(const MotionDense< M1 > &v)
void se3Action_impl(const SE3Tpl< S2, O2 > &m, MotionDense< D2 > &v) const
MotionPlain motionAction(const MotionDense< M1 > &v) const
SE3GroupAction< Derived >::ReturnType se3Action_impl(const SE3Tpl< S2, O2 > &m) const
Return type of the ation of a Motion onto an object of type D.
#define MOTION_TYPEDEF_TPL(Derived)
bool isZero(const Eigen::MatrixBase< MatrixLike > &m, const typename MatrixLike::RealScalar &prec=Eigen::NumTraits< typename MatrixLike::Scalar >::dummy_precision())
Definition: math/matrix.hpp:56
bool isApprox_impl(const MotionDense< D2 > &m2, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
SE3GroupAction< Derived >::ReturnType ReturnType
MotionPlain operator-(const MotionDense< M1 > &v) const
ConstAngularType angular() const
Return the angular part of the force vector.
Definition: force-base.hpp:35
MotionAlgebraAction< Derived, MotionDerived >::ReturnType ReturnType
Derived & operator=(const Eigen::MatrixBase< V6 > &v)
Scalar dot(const ForceBase< F1 > &phi) const
SE3::Scalar Scalar
Definition: conversions.cpp:13
ConstLinearType linear() const
Return the linear part of the force vector.
Definition: force-base.hpp:42
void disp_impl(std::ostream &os) const
Derived & __mequ__(const MotionDense< M1 > &v)
bool isApprox(const MotionDense< M2 > &m2, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
ConstLinearType linear() const
Definition: motion-base.hpp:22
ActionMatrixType toDualActionMatrix_impl() const
d
Definition: ur5x4.py:45
Derived & derived()
Definition: force-base.hpp:27
MotionBase< Derived > Base
MotionPlain __div__(const OtherScalar &alpha) const
MotionPlain operator-() const
MotionAlgebraAction< D, Derived >::ReturnType cross_impl(const D &d) const
ActionMatrixType toActionMatrix_impl() const
MotionPlain operator+(const MotionDense< M1 > &v) const
MotionPlain __opposite__() const
Derived & operator=(const MotionBase< D2 > &other)
Base interface for forces representation.
Definition: force-base.hpp:22
Derived & operator=(const MotionDense< D2 > &other)
traits< Derived >::MotionRefType MotionRefType
Derived & operator+=(const MotionBase< M1 > &v)
Derived & __pequ__(const MotionDense< M1 > &v)
Main pinocchio namespace.
Definition: timings.cpp:30
SE3GroupAction< Derived >::ReturnType se3ActionInverse_impl(const SE3Tpl< S2, O2 > &m) const
Derived & operator+=(const MotionDense< M1 > &v)
void se3ActionInverse_impl(const SE3Tpl< S2, O2 > &m, MotionDense< D2 > &v) const
res
Common traits structure to fully define base classes for CRTP.
Definition: src/fwd.hpp:44
MotionPlain __minus__(const MotionDense< M1 > &v) const
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...
Definition: skew.hpp:21
ConstAngularType angular() const
Definition: motion-base.hpp:21
static void motionAction(const MotionDense< MotionDerived > &v, const Eigen::MatrixBase< Mat > &iF, Eigen::MatrixBase< MatRet > const &jF)
Action of a motion on a set of forces, represented by a 6xN matrix whose each column represent a spat...
MotionDerived::MotionPlain operator^(const MotionDense< MotionDerived > &m1, const MotionPlanarTpl< S2, O2 > &m2)
MultiplicationOp< InertiaTpl< Scalar, Options >, ConstraintDerived >::ReturnType operator*(const InertiaTpl< Scalar, Options > &Y, const ConstraintBase< ConstraintDerived > &constraint)
 .
void motionAction(const MotionDense< M1 > &v, MotionDense< M2 > &mout) const
bool isEqual_impl(const MotionBase< D2 > &other) const
bool isEqual_impl(const MotionDense< D2 > &other) const
MotionPlain __plus__(const MotionDense< M1 > &v) const


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:04