ForceVector.hpp
Go to the documentation of this file.
1 /*
2  * RDL - Robot Dynamics Library
3  * Copyright (c) 2017 Jordan Lack <jlack1987@gmail.com>
4  *
5  * Licensed under the zlib license. See LICENSE for more details.
6  */
7 
8 #ifndef __RDL_FORCE_VECTOR_HPP__
9 #define __RDL_FORCE_VECTOR_HPP__
10 
18 
19 namespace RobotDynamics
20 {
21 namespace Math
22 {
28 {
29  public:
34  template <typename OtherDerived>
35  // cppcheck-suppress noExplicitConstructor
36  ForceVector(const Eigen::MatrixBase<OtherDerived>& other) : SpatialVector(other)
37  {
38  }
39 
45  template <typename OtherDerived>
46  ForceVector& operator=(const Eigen::MatrixBase<OtherDerived>& other)
47  {
49  return *this;
50  }
51 
55  EIGEN_STRONG_INLINE ForceVector() : SpatialVector(0., 0., 0., 0., 0., 0.)
56  {
57  }
58 
62  EIGEN_STRONG_INLINE SpatialVector toSpatialVector() const
63  {
64  return *this;
65  }
66 
76  ForceVector(const double mx, const double my, const double mz, const double fx, const double fy, const double fz)
77  {
78  Base::_check_template_params();
79 
80  (*this) << mx, my, mz, fx, fy, fz;
81  }
82 
87  EIGEN_STRONG_INLINE void set(const ForceVector& f)
88  {
89  (*this) << f.data()[0], f.data()[1], f.data()[2], f.data()[3], f.data()[4], f.data()[5];
90  }
91 
96  EIGEN_STRONG_INLINE double& mx()
97  {
98  return this->data()[0];
99  }
100 
105  EIGEN_STRONG_INLINE double& my()
106  {
107  return this->data()[1];
108  }
109 
114  EIGEN_STRONG_INLINE double& mz()
115  {
116  return this->data()[2];
117  }
118 
123  EIGEN_STRONG_INLINE double mx() const
124  {
125  return this->data()[0];
126  }
127 
132  EIGEN_STRONG_INLINE double my() const
133  {
134  return this->data()[1];
135  }
136 
141  EIGEN_STRONG_INLINE double mz() const
142  {
143  return this->data()[2];
144  }
145 
150  EIGEN_STRONG_INLINE double& fx()
151  {
152  return this->data()[3];
153  }
154 
159  EIGEN_STRONG_INLINE double& fy()
160  {
161  return this->data()[4];
162  }
163 
168  EIGEN_STRONG_INLINE double& fz()
169  {
170  return this->data()[5];
171  }
172 
177  EIGEN_STRONG_INLINE double fx() const
178  {
179  return this->data()[3];
180  }
181 
186  EIGEN_STRONG_INLINE double fy() const
187  {
188  return this->data()[4];
189  }
190 
195  EIGEN_STRONG_INLINE double fz() const
196  {
197  return this->data()[5];
198  }
199 
212  {
213  Vector3d En_rxf = X.E * (this->getAngularPart() - X.r.cross(this->getLinearPart()));
214 
215  *this << En_rxf[0], En_rxf[1], En_rxf[2], X.E(0, 0) * this->data()[3] + X.E(0, 1) * this->data()[4] + X.E(0, 2) * this->data()[5],
216  X.E(1, 0) * this->data()[3] + X.E(1, 1) * this->data()[4] + X.E(1, 2) * this->data()[5],
217  X.E(2, 0) * this->data()[3] + X.E(2, 1) * this->data()[4] + X.E(2, 2) * this->data()[5];
218  }
219 
233  {
234  ForceVector f = *this;
235  f.transform(X);
236  return f;
237  }
238 
244  {
245  (*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());
246  return *this;
247  }
248 };
249 
257 {
258  f.transform(X);
259  return f;
260 }
261 typedef std::vector<ForceVector, Eigen::aligned_allocator<ForceVector>> ForceVectorV;
262 } // namespace Math
263 } // namespace RobotDynamics
264 
265 #endif
EIGEN_STRONG_INLINE double my() const
Get copy of y-angular component.
std::vector< ForceVector, Eigen::aligned_allocator< ForceVector > > ForceVectorV
EIGEN_STRONG_INLINE double fx() const
Get copy of x-linear component.
EIGEN_STRONG_INLINE double fz() const
Get copy of z-linear component.
ForceVector operator*(const SpatialTransform &X, ForceVector f)
Operator for transforming a ForceVector. Calls the ForceVector::transform method. ...
EIGEN_STRONG_INLINE double mz() const
Get copy of z-angular component.
A ForceVector is a SpatialVector containing 3 moments and 3 linear forces.
Definition: ForceVector.hpp:27
EIGEN_STRONG_INLINE ForceVector()
Empty constructor.
Definition: ForceVector.hpp:55
ForceVector & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Definition: ForceVector.hpp:46
EIGEN_STRONG_INLINE double & fy()
Get reference to y-linear component.
void transform(const SpatialTransform &X)
Performs the following in place transform .
EIGEN_STRONG_INLINE double & fx()
Get reference to x-linear component.
ForceVector(const double mx, const double my, const double mz, const double fx, const double fy, const double fz)
Constructor.
Definition: ForceVector.hpp:76
The TransformableGeometricObject class is an essential interface because it forces all geometric obje...
Definition: rdl_eigenmath.h:43
EIGEN_STRONG_INLINE double & fz()
Get reference to z-linear component.
EIGEN_STRONG_INLINE double & my()
Get reference to y-angular component.
Compact representation of spatial transformations.
SpatialVector & operator=(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE double & mz()
Get reference to z-angular component.
EIGEN_STRONG_INLINE Vector3d getAngularPart() const
EIGEN_STRONG_INLINE SpatialVector toSpatialVector() const
Get a copy of a ForceVector as type SpatialVector.
Definition: ForceVector.hpp:62
ForceVector(const Eigen::MatrixBase< OtherDerived > &other)
Constructor.
Definition: ForceVector.hpp:36
EIGEN_STRONG_INLINE double & mx()
Get reference to x-angular component.
Definition: ForceVector.hpp:96
EIGEN_STRONG_INLINE Vector3d getLinearPart() const
ForceVector operator+=(const ForceVector &v)
Overloaded plus-equals operator.
EIGEN_STRONG_INLINE double fy() const
Get copy of y-linear component.
EIGEN_STRONG_INLINE double mx() const
Get copy of x-angular component.
ForceVector transform_copy(const SpatialTransform &X) const
Copy then transform a ForceVector by .
Namespace for all structures of the RobotDynamics library.
Definition: Body.h:21


rdl_dynamics
Author(s):
autogenerated on Tue Apr 20 2021 02:25:27