pinocchio  2.1.3
force-base.hpp
1 //
2 // Copyright (c) 2015-2018 CNRS
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 
17 namespace pinocchio
18 {
26  template< class Derived>
27  class ForceBase
28  {
29  public:
30  FORCE_TYPEDEF_TPL(Derived);
31 
32  Derived & derived() { return *static_cast<Derived*>(this); }
33  const Derived& derived() const { return *static_cast<const Derived*>(this); }
34 
40  ConstAngularType angular() const { return derived().angular_impl(); }
41 
47  ConstLinearType linear() const { return derived().linear_impl(); }
48 
50  AngularType angular() { return derived().angular_impl(); }
51 
53  LinearType linear() { return derived().linear_impl(); }
54 
55 
63  template<typename V3Like>
64  void angular(const Eigen::MatrixBase<V3Like> & n)
65  { derived().angular_impl(n.derived()); }
66 
74  template<typename V3Like>
75  void linear(const Eigen::MatrixBase<V3Like> & f)
76  { derived().linear_impl(f.derived()); }
77 
86  ToVectorConstReturnType toVector() const { return derived().toVector_impl(); }
87 
89  ToVectorReturnType toVector() { return derived().toVector_impl(); }
90 
91  /*
92  * @brief C-style cast operator
93  * \copydoc ForceBase::toVector
94  */
95  operator Vector6() const { return toVector(); }
96 
101  template<typename F2>
102  bool operator==(const ForceBase<F2> & other) const {return derived().isEqual_impl(other.derived());}
103 
106  template<typename F2>
107  bool operator!=(const ForceBase<F2> & other) const { return !(derived() == other.derived()); }
108 
111  bool isApprox(const Derived & other, const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
112  { return derived().isApprox_impl(other, 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>
172  typename internal::SE3GroupAction<Derived>::ReturnType
173  se3Action(const SE3Tpl<S2,O2> & m) const
174  { return derived().se3Action_impl(m); }
175 
187  template<typename S2, int O2>
188  typename internal::SE3GroupAction<Derived>::ReturnType
190  { return derived().se3ActionInverse_impl(m); }
191 
192  template<typename M1>
193  typename internal::MotionAlgebraAction<Derived,M1>::ReturnType
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__
bool operator!=(const ForceBase< F2 > &other) const
Definition: force-base.hpp:107
Derived & operator=(const ForceBase< Derived > &other)
Copies the Derived Force into *this.
Definition: force-base.hpp:117
ForcePlain operator*(const OtherScalar &alpha) const
Definition: force-base.hpp:139
Derived & operator-=(const ForceBase< Derived > &phi)
Replaces *this by *this - other.
Definition: force-base.hpp:130
LinearType linear()
Return the linear part of the force vector.
Definition: force-base.hpp:53
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
Derived operator+(const ForceBase< Derived > &phi) const
Definition: force-base.hpp:134
bool operator==(const ForceBase< F2 > &other) const
Definition: force-base.hpp:102
ForcePlain operator/(const OtherScalar &alpha) const
Definition: force-base.hpp:144
internal::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
internal::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
Derived operator-() const
Definition: force-base.hpp:148
void angular(const Eigen::MatrixBase< V3Like > &n)
Set the angular part of the force vector.
Definition: force-base.hpp:64
ToVectorReturnType toVector()
Return the force as an Eigen vector.
Definition: force-base.hpp:89
ConstAngularType angular() const
Return the angular part of the force vector.
Definition: force-base.hpp:40
Base interface for forces representation.
Definition: force-base.hpp:27
ToVectorConstReturnType toVector() const
Return the force as an Eigen vector.
Definition: force-base.hpp:86
Main pinocchio namespace.
Definition: treeview.dox:24
AngularType angular()
Return the angular part of the force vector.
Definition: force-base.hpp:50
Derived operator-(const ForceBase< Derived > &phi) const
Definition: force-base.hpp:152
ConstLinearType linear() const
Return the linear part of the force vector.
Definition: force-base.hpp:47
void linear(const Eigen::MatrixBase< V3Like > &f)
Set the linear part of the force vector.
Definition: force-base.hpp:75
bool isApprox(const Derived &other, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
Definition: force-base.hpp:111