pinocchio  2.4.4
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
force-base.hpp
1 //
2 // Copyright (c) 2015-2019 CNRS INRIA
3 // Copyright (c) 2016 Wandercraft, 86 rue de Paris 91400 Orsay, France.
4 //
5 
6 #ifndef __pinocchio_force_base_hpp__
7 #define __pinocchio_force_base_hpp__
8 
9 namespace pinocchio
10 {
21  template< class Derived>
22  class ForceBase
23  {
24  public:
25  FORCE_TYPEDEF_TPL(Derived);
26 
27  Derived & derived() { return *static_cast<Derived*>(this); }
28  const Derived& derived() const { return *static_cast<const Derived*>(this); }
29 
35  ConstAngularType angular() const { return derived().angular_impl(); }
36 
42  ConstLinearType linear() const { return derived().linear_impl(); }
43 
45  AngularType angular() { return derived().angular_impl(); }
46 
48  LinearType linear() { return derived().linear_impl(); }
49 
50 
58  template<typename V3Like>
59  void angular(const Eigen::MatrixBase<V3Like> & n)
60  { derived().angular_impl(n.derived()); }
61 
69  template<typename V3Like>
70  void linear(const Eigen::MatrixBase<V3Like> & f)
71  { derived().linear_impl(f.derived()); }
72 
81  ToVectorConstReturnType toVector() const { return derived().toVector_impl(); }
82 
84  ToVectorReturnType toVector() { return derived().toVector_impl(); }
85 
86  /*
87  * @brief C-style cast operator
88  * \copydoc ForceBase::toVector
89  */
90  operator Vector6() const { return toVector(); }
91 
96  template<typename F2>
97  bool operator==(const ForceBase<F2> & other) const {return derived().isEqual_impl(other.derived());}
98 
101  template<typename F2>
102  bool operator!=(const ForceBase<F2> & other) const { return !(derived() == other.derived()); }
103 
106  bool isApprox(const Derived & other, const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
107  { return derived().isApprox_impl(other, prec); }
108 
111  bool isZero(const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
112  { return derived().isZero_impl(prec); }
113 
117  Derived & operator=(const ForceBase<Derived> & other)
118  { return derived().setFrom(other.derived()); }
119 
124  Derived & operator+= (const ForceBase<Derived> & phi) { return derived().__pequ__(phi.derived()); }
125 
130  Derived & operator-= (const ForceBase<Derived> & phi) { return derived().__mequ__(phi.derived()); }
131 
134  Derived operator+(const ForceBase<Derived> & phi) const { return derived().__plus__(phi.derived()); }
135 
138  template<typename OtherScalar>
139  ForcePlain operator*(const OtherScalar & alpha) const { return derived().__mult__(alpha); }
140 
143  template<typename OtherScalar>
144  ForcePlain operator/(const OtherScalar & alpha) const { return derived().__div__(alpha); }
145 
148  Derived operator-() const { return derived().__opposite__(); }
149 
152  Derived operator-(const ForceBase<Derived> & phi) const { return derived().__minus__(phi.derived()); }
153 
156  template<typename MotionDerived>
157  Scalar dot(const MotionDense<MotionDerived> & m) const { return derived().dot(m.derived()); }
158 
159 
171  template<typename S2, int O2>
173  se3Action(const SE3Tpl<S2,O2> & m) const
174  { return derived().se3Action_impl(m); }
175 
187  template<typename S2, int O2>
190  { return derived().se3ActionInverse_impl(m); }
191 
192  template<typename M1>
194  motionAction(const MotionDense<M1> & v) const
195  {
196  return derived().motionAction(v.derived());
197  }
198 
199  void disp(std::ostream & os) const { derived().disp_impl(os); }
200  friend std::ostream & operator << (std::ostream & os, const ForceBase<Derived> & X)
201  {
202  X.disp(os);
203  return os;
204  }
205 
206  }; // class ForceBase
207 
208 } // namespace pinocchio
209 
210 #endif // ifndef __pinocchio_force_base_hpp__
Derived & operator=(const ForceBase< Derived > &other)
Copies the Derived Force into *this.
Definition: force-base.hpp:117
Derived & operator-=(const ForceBase< Derived > &phi)
Replaces *this by *this - other.
Definition: force-base.hpp:130
SE3GroupAction< Derived >::ReturnType se3Action(const SE3Tpl< S2, O2 > &m) const
Transform from A to B coordinates the Force represented by *this such that .
Definition: force-base.hpp:173
LinearType linear()
Return the linear part of the force vector.
Definition: force-base.hpp:48
Derived & operator+=(const ForceBase< Derived > &phi)
Replaces *this by *this + other.
Definition: force-base.hpp:124
Scalar dot(const MotionDense< MotionDerived > &m) const
Definition: force-base.hpp:157
ToVectorConstReturnType toVector() const
Return the force as an Eigen vector.
Definition: force-base.hpp:81
SE3GroupAction< Derived >::ReturnType se3ActionInverse(const SE3Tpl< S2, O2 > &m) const
Transform from B to A coordinates the Force represented by *this such that .
Definition: force-base.hpp:189
ConstAngularType angular() const
Return the angular part of the force vector.
Definition: force-base.hpp:35
ForcePlain operator/(const OtherScalar &alpha) const
Definition: force-base.hpp:144
bool isApprox(const Derived &other, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
Definition: force-base.hpp:106
void angular(const Eigen::MatrixBase< V3Like > &n)
Set the angular part of the force vector.
Definition: force-base.hpp:59
ToVectorReturnType toVector()
Return the force as an Eigen vector.
Definition: force-base.hpp:84
Base interface for forces representation.
Definition: force-base.hpp:22
Derived operator-(const ForceBase< Derived > &phi) const
Definition: force-base.hpp:152
Main pinocchio namespace.
Definition: treeview.dox:24
bool operator!=(const ForceBase< F2 > &other) const
Definition: force-base.hpp:102
bool operator==(const ForceBase< F2 > &other) const
Definition: force-base.hpp:97
AngularType angular()
Return the angular part of the force vector.
Definition: force-base.hpp:45
ForcePlain operator*(const OtherScalar &alpha) const
Definition: force-base.hpp:139
bool isZero(const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
Definition: force-base.hpp:111
ConstLinearType linear() const
Return the linear part of the force vector.
Definition: force-base.hpp:42
Derived operator-() const
Definition: force-base.hpp:148
Derived operator+(const ForceBase< Derived > &phi) const
Definition: force-base.hpp:134
void linear(const Eigen::MatrixBase< V3Like > &f)
Set the linear part of the force vector.
Definition: force-base.hpp:70