pinocchio  UNKNOWN
force-base.hpp
1 //
2 // Copyright (c) 2015-2018 CNRS
3 // Copyright (c) 2016 Wandercraft, 86 rue de Paris 91400 Orsay, France.
4 //
5 // This file is part of Pinocchio
6 // Pinocchio is free software: you can redistribute it
7 // and/or modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation, either version
9 // 3 of the License, or (at your option) any later version.
10 //
11 // Pinocchio is distributed in the hope that it will be
12 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Lesser Public License for more details. You should have
15 // received a copy of the GNU Lesser General Public License along with
16 // Pinocchio If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef __se3_force_base_hpp__
20 #define __se3_force_base_hpp__
21 
30 namespace se3
31 {
39  template< class Derived>
40  class ForceBase
41  {
42  public:
43  FORCE_TYPEDEF_TPL(Derived);
44 
45  Derived & derived() { return *static_cast<Derived*>(this); }
46  const Derived& derived() const { return *static_cast<const Derived*>(this); }
47 
53  ConstAngularType angular() const { return derived().angular_impl(); }
54 
60  ConstLinearType linear() const { return derived().linear_impl(); }
61 
63  AngularType angular() { return derived().angular_impl(); }
64 
66  LinearType linear() { return derived().linear_impl(); }
67 
68 
76  template<typename V3Like>
77  void angular(const Eigen::MatrixBase<V3Like> & n)
78  { derived().angular_impl(n.derived()); }
79 
87  template<typename V3Like>
88  void linear(const Eigen::MatrixBase<V3Like> & f)
89  { derived().linear_impl(f.derived()); }
90 
99  ToVectorConstReturnType toVector() const { return derived().toVector_impl(); }
100 
102  ToVectorReturnType toVector() { return derived().toVector_impl(); }
103 
104  /*
105  * @brief C-style cast operator
106  * \copydoc ForceBase::toVector
107  */
108  operator Vector6() const { return toVector(); }
109 
114  template<typename F2>
115  bool operator==(const ForceBase<F2> & other) const {return derived().isEqual_impl(other.derived());}
116 
119  template<typename F2>
120  bool operator!=(const ForceBase<F2> & other) const { return !(derived() == other.derived()); }
121 
124  bool isApprox(const Derived & other, const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
125  { return derived().isApprox_impl(other, prec); }
126 
130  Derived & operator= (const Derived & other) { return derived().__equl__(other); }
131 
136  Derived & operator+= (const Derived & phi) { return derived().__pequ__(phi); }
137 
142  Derived & operator-= (const Derived & phi) { return derived().__mequ__(phi); }
143 
146  Derived operator+(const Derived & phi) const { return derived().__plus__(phi); }
147 
150  template<typename OtherScalar>
151  ForcePlain operator*(const OtherScalar & alpha) const { return derived().__mult__(alpha); }
152 
155  template<typename OtherScalar>
156  ForcePlain operator/(const OtherScalar & alpha) const { return derived().__div__(alpha); }
157 
160  Derived operator-() const { return derived().__opposite__(); }
161 
164  Derived operator-(const Derived & phi) const { return derived().__minus__(phi); }
165 
168  Scalar dot(const Motion & m) const { return derived().dot(m); }
169 
170 
182  template<typename S2, int O2>
183  typename internal::SE3GroupAction<Derived>::ReturnType
184  se3Action(const SE3Tpl<S2,O2> & m) const
185  { return derived().se3Action_impl(m); }
186 
198  template<typename S2, int O2>
199  typename internal::SE3GroupAction<Derived>::ReturnType
201  { return derived().se3ActionInverse_impl(m); }
202 
203  template<typename M1>
204  typename internal::MotionAlgebraAction<Derived,M1>::ReturnType
205  motionAction(const MotionDense<M1> & v) const
206  {
207  return derived().motionAction(v.derived());
208  }
209 
210  void disp(std::ostream & os) const { derived().disp_impl(os); }
211  friend std::ostream & operator << (std::ostream & os, const ForceBase<Derived> & X)
212  {
213  X.disp(os);
214  return os;
215  }
216 
217  }; // class ForceBase
218 
219 } // namespace se3
220 
221 #endif // ifndef __se3_force_base_hpp__
ForcePlain operator/(const OtherScalar &alpha) const
Definition: force-base.hpp:156
bool operator!=(const ForceBase< F2 > &other) const
Definition: force-base.hpp:120
AngularType angular()
Return the angular part of the force vector.
Definition: force-base.hpp:63
Derived operator+(const Derived &phi) const
Definition: force-base.hpp:146
void linear(const Eigen::MatrixBase< V3Like > &f)
Set the linear part of the force vector.
Definition: force-base.hpp:88
Derived operator-(const Derived &phi) const
Definition: force-base.hpp:164
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:184
Derived & operator+=(const Derived &phi)
Replaces *this by *this + other.
Definition: force-base.hpp:136
ConstAngularType angular() const
Return the angular part of the force vector.
Definition: force-base.hpp:53
Derived & operator-=(const Derived &phi)
Replaces *this by *this - other.
Definition: force-base.hpp:142
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:200
bool operator==(const ForceBase< F2 > &other) const
Definition: force-base.hpp:115
ConstLinearType linear() const
Return the linear part of the force vector.
Definition: force-base.hpp:60
bool isApprox(const Derived &other, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
Definition: force-base.hpp:124
void angular(const Eigen::MatrixBase< V3Like > &n)
Set the angular part of the force vector.
Definition: force-base.hpp:77
Base interface for forces representation.
Definition: force-base.hpp:40
Scalar dot(const Motion &m) const
Definition: force-base.hpp:168
ForcePlain operator*(const OtherScalar &alpha) const
Definition: force-base.hpp:151
ToVectorConstReturnType toVector() const
Return the force as an Eigen vector.
Definition: force-base.hpp:99
Derived & operator=(const Derived &other)
Copies the Derived Force into *this.
Definition: force-base.hpp:130
Derived operator-() const
Definition: force-base.hpp:160
LinearType linear()
Return the linear part of the force vector.
Definition: force-base.hpp:66
ToVectorReturnType toVector()
Return the force as an Eigen vector.
Definition: force-base.hpp:102