Robot Dynamics Library
ForceVector.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Jordan Lack <jlack1987@gmail.com>
2 // RDL - Robot Dynamics Library
3 // Licensed under the zlib license. See LICENSE for more details.
4 
5 #ifndef __RDL_FORCE_VECTOR_HPP__
6 #define __RDL_FORCE_VECTOR_HPP__
7 
13 
14 namespace RobotDynamics
15 {
16 namespace Math
17 {
23 {
24  public:
29  template <typename OtherDerived>
30  // cppcheck-suppress noExplicitConstructor
31  ForceVector(const Eigen::MatrixBase<OtherDerived>& other) : SpatialVector(other)
32  {
33  }
34 
40  template <typename OtherDerived>
41  ForceVector& operator=(const Eigen::MatrixBase<OtherDerived>& other)
42  {
44  return *this;
45  }
46 
50  EIGEN_STRONG_INLINE ForceVector() : SpatialVector(0., 0., 0., 0., 0., 0.)
51  {
52  }
53 
57  EIGEN_STRONG_INLINE SpatialVector toSpatialVector() const
58  {
59  return *this;
60  }
61 
71  ForceVector(const double mx, const double my, const double mz, const double fx, const double fy, const double fz)
72  {
73  Base::_check_template_params();
74 
75  (*this) << mx, my, mz, fx, fy, fz;
76  }
77 
82  EIGEN_STRONG_INLINE void set(const ForceVector& f)
83  {
84  (*this) << f[0], f[1], f[2], f[3], f[4], f[5];
85  }
86 
91  EIGEN_STRONG_INLINE double& mx()
92  {
93  return this->operator[](0);
94  }
95 
100  EIGEN_STRONG_INLINE double& my()
101  {
102  return this->operator[](1);
103  }
104 
109  EIGEN_STRONG_INLINE double& mz()
110  {
111  return this->operator[](2);
112  }
113 
118  EIGEN_STRONG_INLINE double mx() const
119  {
120  return this->operator[](0);
121  }
122 
127  EIGEN_STRONG_INLINE double my() const
128  {
129  return this->operator[](1);
130  }
131 
136  EIGEN_STRONG_INLINE double mz() const
137  {
138  return this->operator[](2);
139  }
140 
145  EIGEN_STRONG_INLINE double& fx()
146  {
147  return this->operator[](3);
148  }
149 
154  EIGEN_STRONG_INLINE double& fy()
155  {
156  return this->operator[](4);
157  }
158 
163  EIGEN_STRONG_INLINE double& fz()
164  {
165  return this->operator[](5);
166  }
167 
172  EIGEN_STRONG_INLINE double fx() const
173  {
174  return this->operator[](3);
175  }
176 
181  EIGEN_STRONG_INLINE double fy() const
182  {
183  return this->operator[](4);
184  }
185 
190  EIGEN_STRONG_INLINE double fz() const
191  {
192  return this->operator[](5);
193  }
194 
207  {
208  this->setAngularPart(X.E * (this->getAngularPart() - X.r.cross(this->getLinearPart())));
209  this->setLinearPart(X.E * this->getLinearPart());
210  }
211 
225  {
226  ForceVector f = *this;
227  f.transform(X);
228  return f;
229  }
230 
236  {
237  (*this) << (this->mx() += v.mx()), (this->my() += v.my()), (this->mz() += v.mz()), (this->fx() += v.fx()), (this->fy() += v.fy()), (this->fz() += v.fz());
238  return *this;
239  }
240 };
241 
249 {
250  f.transform(X);
251  return f;
252 }
253 typedef std::vector<ForceVector, Eigen::aligned_allocator<ForceVector>> ForceVectorV;
254 } // namespace Math
255 } // namespace RobotDynamics
256 
257 #endif
A ForceVector is a SpatialVector containing 3 moments and 3 linear forces.
Definition: ForceVector.hpp:23
ForceVector transform_copy(const SpatialTransform &X) const
Copy then transform a ForceVector by.
Definition: ForceVector.hpp:224
ForceVector(const double mx, const double my, const double mz, const double fx, const double fy, const double fz)
Constructor.
Definition: ForceVector.hpp:71
EIGEN_STRONG_INLINE double fx() const
Get copy of x-linear component.
Definition: ForceVector.hpp:172
EIGEN_STRONG_INLINE double mz() const
Get copy of z-angular component.
Definition: ForceVector.hpp:136
EIGEN_STRONG_INLINE double mx() const
Get copy of x-angular component.
Definition: ForceVector.hpp:118
EIGEN_STRONG_INLINE double & fx()
Get reference to x-linear component.
Definition: ForceVector.hpp:145
EIGEN_STRONG_INLINE ForceVector()
Empty constructor.
Definition: ForceVector.hpp:50
EIGEN_STRONG_INLINE double & my()
Get reference to y-angular component.
Definition: ForceVector.hpp:100
EIGEN_STRONG_INLINE double fz() const
Get copy of z-linear component.
Definition: ForceVector.hpp:190
EIGEN_STRONG_INLINE SpatialVector toSpatialVector() const
Get a copy of a ForceVector as type SpatialVector.
Definition: ForceVector.hpp:57
ForceVector & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Definition: ForceVector.hpp:41
EIGEN_STRONG_INLINE void set(const ForceVector &f)
Setter.
Definition: ForceVector.hpp:82
EIGEN_STRONG_INLINE double & fy()
Get reference to y-linear component.
Definition: ForceVector.hpp:154
EIGEN_STRONG_INLINE double & mz()
Get reference to z-angular component.
Definition: ForceVector.hpp:109
EIGEN_STRONG_INLINE double & fz()
Get reference to z-linear component.
Definition: ForceVector.hpp:163
EIGEN_STRONG_INLINE double fy() const
Get copy of y-linear component.
Definition: ForceVector.hpp:181
ForceVector(const Eigen::MatrixBase< OtherDerived > &other)
Constructor.
Definition: ForceVector.hpp:31
void transform(const SpatialTransform &X)
Performs the following in place transform.
Definition: ForceVector.hpp:206
EIGEN_STRONG_INLINE double my() const
Get copy of y-angular component.
Definition: ForceVector.hpp:127
ForceVector operator+=(const ForceVector &v)
Overloaded plus-equals operator.
Definition: ForceVector.hpp:235
EIGEN_STRONG_INLINE double & mx()
Get reference to x-angular component.
Definition: ForceVector.hpp:91
Definition: rdl_eigenmath.hpp:187
SpatialVector & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Definition: rdl_eigenmath.hpp:198
void setLinearPart(const Vector3d &v)
Definition: rdl_eigenmath.hpp:266
void setAngularPart(const Vector3d &v)
Definition: rdl_eigenmath.hpp:254
The TransformableGeometricObject class is an essential interface because it forces all geometric obje...
Definition: rdl_eigenmath.hpp:43
std::vector< ForceVector, Eigen::aligned_allocator< ForceVector > > ForceVectorV
Definition: ForceVector.hpp:253
ForceVector operator*(const SpatialTransform &X, ForceVector f)
Operator for transforming a ForceVector. Calls the ForceVector::transform method.
Definition: ForceVector.hpp:248
Namespace for all structures of the RobotDynamics library.
Definition: examples.hpp:19
Compact representation of spatial transformations.
Definition: rdl_eigenmath.hpp:412
Matrix3d E
Definition: rdl_eigenmath.hpp:595
Vector3d r
Definition: rdl_eigenmath.hpp:596