Wrench.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009-2013 CEA LIST (DIASI/LSI) <xde-support@saxifrage.cea.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_LGSM_LIE_WRENCH_H
11 #define EIGEN_LGSM_LIE_WRENCH_H
12 
13 /*******************************************************************************
14 * Definition/implementation of WrenchBase
15 ********************************************************************************/
16 
28 namespace internal {
29  template<class Derived>
30  struct traits<WrenchBase<Derived> > : traits<LieAlgebraDualBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived> > {
31  };
32 }
33 
34 template<class Derived>
35 class WrenchBase : public LieAlgebraDualBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>{
36 protected:
39 public:
40  // inherit MatrixBase interface
41  EIGEN_DENSE_PUBLIC_INTERFACE(WrenchBase)
42  // inherit assignement operator
43  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(WrenchBase)
44 
46  typedef typename Base::BaseType BaseType;
48  typedef typename internal::traits<Derived>::Coefficients Coefficients;
49 
51  typedef Matrix<Scalar, 3, 1> Force;
53  typedef LieAlgebraDual<Matrix<Scalar, 3, 1> > Torque;
54 
56  inline Scalar tx() const { return this->getTorque().x(); }
58  inline Scalar ty() const { return this->getTorque().y(); }
60  inline Scalar tz() const { return this->getTorque().z(); }
62  inline Scalar fx() const { return this->getForce().x(); }
64  inline Scalar fy() const { return this->getForce().y(); }
66  inline Scalar fz() const { return this->getForce().z(); }
67 
69  inline Scalar& tx() { return this->getTorque().x(); }
71  inline Scalar& ty() { return this->getTorque().y(); }
73  inline Scalar& tz() { return this->getTorque().z(); }
75  inline Scalar& fx() { return this->getForce().x(); }
77  inline Scalar& fy() { return this->getForce().y(); }
79  inline Scalar& fz() { return this->getForce().z(); }
80 
81 
83  inline Map<Torque> getTorque(){ return Map<Torque>(this->data()); }
85  inline Map<const Torque> getTorque() const {return Map<const Torque>(this->data()); }
87  inline Map<Force> getForce() { return Map<Force>(this->derived().get().template tail<3>().data()); }
89  inline Map<const Force> getForce() const { return Map<const Force>(this->derived().get().template tail<3>().data()); }
90 
91  template<class RotationDerived> inline Wrench<Scalar> changeFrame(const LieGroupBase<Quaternion<Scalar>, RotationDerived>&) const;
92 
93  template<class OtherDerived> inline Wrench<Scalar> changePoint(const MatrixBase<OtherDerived>& point) const;
94 };
95 
96 
97 template<class Derived>
98 template<class RotationDerived>
99 inline Wrench<typename internal::traits<WrenchBase<Derived> >::Scalar> WrenchBase<Derived>::changeFrame(const LieGroupBase<Quaternion<Scalar>, RotationDerived>& rot) const {
100  return Wrench<Scalar>(rot*this->getTorque(),
101  rot*this->getForce());
102 }
103 
104 
105 template<class Derived>
106 template<class OtherDerived>
107 inline Wrench<typename internal::traits<WrenchBase<Derived> >::Scalar> WrenchBase<Derived>::changePoint(const MatrixBase<OtherDerived>& point) const {
108  return Wrench<Scalar>(this->getTorque() + this->getForce.cross(point),
109  this->getForce() );
110 }
111 
112 /**************************
113  * Implementation of Wrench
114  **************************/
115 
116 namespace internal {
117  template<typename _Scalar>
118  struct traits<Wrench<_Scalar> > : traits<LieAlgebraDual<Matrix<_Scalar, 6, 1> > >
119  {
120  typedef _Scalar Scalar;
121  };
122 }
123 
134 template<typename _Scalar>
135 class Wrench : public WrenchBase<Wrench<_Scalar> >{
136 protected:
138 public:
139  // inherit MatrixBase interface
140  EIGEN_DENSE_PUBLIC_INTERFACE(Wrench)
141  // inherit assignement operator
142  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Wrench)
143 
145  typedef typename Base::BaseType BaseType;
147  typedef typename internal::traits<Wrench>::Coefficients Coefficients;
148 
149 
151  inline Wrench() : m_coeffs() {}
153  inline Wrench(const Wrench& g) : m_coeffs(g.get() ) {}
155  inline Wrench(const BaseType& g) : m_coeffs(g) {}
157  inline Wrench(const typename Base::PlainObject& g) : m_coeffs(g.get() ) {}
159  inline Wrench(Scalar tx, Scalar ty, Scalar tz, Scalar fx, Scalar fy, Scalar fz) {
160  m_coeffs << tx, ty, tz, fx, fy, fz;
161  }
163  template<typename OtherDerived>
164  EIGEN_STRONG_INLINE Wrench(const MatrixBase<OtherDerived>& other)
165  : m_coeffs(other)
166  {
167  }
169  template<typename OtherDerived>
170  EIGEN_STRONG_INLINE Wrench& operator=(const MatrixBase<OtherDerived>& other)
171  {
172  m_coeffs = other;
173  return *this;
174  }
176  inline Wrench(const typename Base::Torque& t, const typename Base::Force& f) {
177  this->getForce() = f;
178  this->getTorque() = t;
179  }
181  inline Coefficients& get() { return m_coeffs; }
183  inline const Coefficients& get() const { return m_coeffs; }
184 
185 protected:
188 };
189 
194 
195 /**************************************
196  * Implementation of Map<Wrench>
197  **************************************/
198 
199 namespace internal {
200  template<typename _Scalar, int MapOptions, typename StrideType>
201  struct traits<Map<Wrench<_Scalar>, MapOptions, StrideType> > : traits<Map<LieAlgebraDual<Matrix<_Scalar, 6, 1> >, MapOptions, StrideType> >
202  {
203  typedef _Scalar Scalar;
204  };
205 }
216 template<typename _Scalar, int MapOptions, typename StrideType>
217 class Map<Wrench<_Scalar>, MapOptions, StrideType> : public WrenchBase<Map<Wrench<_Scalar>, MapOptions, StrideType> >{
218  protected:
220  public:
221  EIGEN_DENSE_PUBLIC_INTERFACE(Map)
222  EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Map)
223 
224  typedef typename internal::traits<Map>::Coefficients Coefficients;
225 
226  inline Map(const Wrench<Scalar>& w) : m_coeffs(w.get()) {};
227  template<int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
228  inline Map(const Array<Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& g) : m_coeffs(g.data()) {};
229 
230  inline Map(Scalar* data) : m_coeffs(data) {};
231  inline Map(const Map& m) : m_coeffs(m.get()) {};
232 
233  inline Coefficients& get() { return m_coeffs; }
234  inline const Coefficients& get() const { return m_coeffs; }
235 
236  protected:
238 };
239 
240 #endif
241 
Scalar fy() const
Definition: Wrench.h:64
EIGEN_STRONG_INLINE Wrench & operator=(const MatrixBase< OtherDerived > &other)
Definition: Wrench.h:170
Wrench< double > Wrenchd
Definition: Wrench.h:191
Wrench< float > Wrenchf
Definition: Wrench.h:193
Base::BaseType BaseType
Definition: Wrench.h:145
Wrench(Scalar tx, Scalar ty, Scalar tz, Scalar fx, Scalar fy, Scalar fz)
Definition: Wrench.h:159
Wrench(const typename Base::Torque &t, const typename Base::Force &f)
Definition: Wrench.h:176
Map< const Torque > getTorque() const
Definition: Wrench.h:85
Base class describing a Wrench.
Definition: Wrench.h:35
WrenchBase< Map< Wrench< _Scalar > > > Base
Definition: Wrench.h:219
Scalar & fy()
Definition: Wrench.h:77
Scalar & tz()
Definition: Wrench.h:73
Scalar & fz()
Definition: Wrench.h:79
EIGEN_STRONG_INLINE Wrench(const MatrixBase< OtherDerived > &other)
Definition: Wrench.h:164
LieAlgebraDualBase< Matrix< typename internal::traits< Derived >::Scalar, 6, 1 >, Derived > Base
Definition: Wrench.h:38
Scalar tz() const
Definition: Wrench.h:60
Wrench(const typename Base::PlainObject &g)
Definition: Wrench.h:157
Matrix< Scalar, 3, 1 > Force
Definition: Wrench.h:51
Wrench(const BaseType &g)
Definition: Wrench.h:155
Wrench< Scalar > changeFrame(const LieGroupBase< Quaternion< Scalar >, RotationDerived > &) const
Wrench(const Wrench &g)
Definition: Wrench.h:153
WrenchBase< Wrench< _Scalar > > Base
Definition: Wrench.h:137
Map< const Force > getForce() const
Definition: Wrench.h:89
Wrench< Scalar > changePoint(const MatrixBase< OtherDerived > &point) const
Scalar & tx()
Definition: Wrench.h:69
Map< Torque > getTorque()
Definition: Wrench.h:83
Base class for all Lie Group class.
Definition: LieGroup.h:39
Scalar ty() const
Definition: Wrench.h:58
Coefficients m_coeffs
Definition: Wrench.h:187
Base class for all Lie Algebra class.
Definition: Displacement.h:139
Scalar fx() const
Definition: Wrench.h:62
Map< Force > getForce()
Definition: Wrench.h:87
internal::traits< Wrench >::Coefficients Coefficients
Definition: Wrench.h:147
Scalar & ty()
Definition: Wrench.h:71
Class describing an element of a Lie algebra dual.
Definition: LieAlgebra.h:216
Scalar fz() const
Definition: Wrench.h:66
Class describing a Wrench.
Definition: Wrench.h:135
internal::traits< Map >::Coefficients Coefficients
Definition: Wrench.h:224
Map(const Array< Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &g)
Definition: Wrench.h:228
Scalar & fx()
Definition: Wrench.h:75


lgsm
Author(s): Roberto Martín-Martín
autogenerated on Mon Jun 10 2019 14:05:58