SpatialForce.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_SPATIAL_FORCE_HPP__
9 #define __RDL_SPATIAL_FORCE_HPP__
10 
21 
22 namespace RobotDynamics
23 {
24 namespace Math
25 {
32 class SpatialForce : public ForceVector, public FrameObject
33 {
34  public:
39  {
40  }
41 
47  {
48  }
49 
60  SpatialForce(ReferenceFramePtr referenceFrame, const double mx, const double my, const double mz, const double fx, const double fy, const double fz)
61  : ForceVector(mx, my, mz, fx, fy, fz), FrameObject(referenceFrame)
62  {
63  }
64 
72  : ForceVector(m.x(), m.y(), m.z(), f.x(), f.y(), f.z()), FrameObject(referenceFrame)
73  {
74  }
75 
77  {
78  return this;
79  }
80 
87  {
88  SpatialForce ret = *this;
89  ret.changeFrame(referenceFrame);
90  return ret;
91  }
92 
98  {
99  return FrameVector(this->referenceFrame, this->getLinearPart());
100  }
101 
107  {
108  return FrameVector(this->referenceFrame, this->getAngularPart());
109  }
110 
115  SpatialForce(const SpatialForce& spatialForce) : ForceVector(spatialForce), FrameObject(spatialForce.referenceFrame)
116  {
117  }
118 
124  SpatialForce(ReferenceFramePtr referenceFrame, const SpatialVector& spatialVector) : ForceVector(spatialVector), FrameObject(referenceFrame)
125  {
126  }
127 
132  inline ForceVector toForceVector() const
133  {
134  return ForceVector(this->mx(), this->my(), this->mz(), this->fx(), this->fy(), this->fz());
135  }
136 
138  {
139  this->set(v);
140  this->referenceFrame = referenceFrame;
141  }
142 
143  void setIncludingFrame(ReferenceFramePtr referenceFrame, double wx, double wy, double wz, double vx, double vy, double vz)
144  {
145  this->SpatialVector::set(wx, wy, wz, vx, vy, vz);
146  this->referenceFrame = referenceFrame;
147  }
148 
150  {
151  this->SpatialVector::set(m.x(), m.y(), m.z(), f.x(), f.y(), f.z());
152  this->referenceFrame = referenceFrame;
153  }
154 
160  inline SpatialForce operator*=(double scale)
161  {
162  mx() *= scale;
163  my() *= scale;
164  mz() *= scale;
165 
166  fx() *= scale;
167  fy() *= scale;
168  fz() *= scale;
169 
170  return *this;
171  }
172 
179  {
180  this->checkReferenceFramesMatch(&f);
181 
182  this->mx() += f.mx();
183  this->my() += f.my();
184  this->mz() += f.mz();
185 
186  this->fx() += f.fx();
187  this->fy() += f.fy();
188  this->fz() += f.fz();
189 
190  return *this;
191  }
192 
199  {
200  this->checkReferenceFramesMatch(&f);
201 
202  this->mx() -= f.mx();
203  this->my() -= f.my();
204  this->mz() -= f.mz();
205 
206  this->fx() -= f.fx();
207  this->fy() -= f.fy();
208  this->fz() -= f.fz();
209 
210  return *this;
211  }
212 };
213 
222 {
223  return f1 += f2;
224 }
225 
234 {
235  return f1 -= f2;
236 }
237 
244 inline SpatialForce operator*(SpatialForce f1, double scale)
245 {
246  return f1 *= scale;
247 }
248 typedef std::vector<SpatialForce, Eigen::aligned_allocator<SpatialForce>> SpatialForceV;
249 } // namespace Math
250 } // namespace RobotDynamics
251 
252 #endif // ifndef __RDL_SPATIAL_FORCE_HPP__
Math::TransformableGeometricObject * getTransformableGeometricObject()
Pure virtual method that FrameObjects are required to implement so the FrameObject::changeFrame metho...
SpatialForce()
Constructor. RobotDynamics::FrameObject::referenceFrame is initialized to nullptr.
SpatialForce(ReferenceFramePtr referenceFrame, const double mx, const double my, const double mz, const double fx, const double fy, const double fz)
Constructor.
EIGEN_STRONG_INLINE void set(const double &v0, const double &v1, const double &v2, const double &v3, const double &v4, const double &v5)
std::vector< SpatialForce, Eigen::aligned_allocator< SpatialForce > > SpatialForceV
SpatialForce(const SpatialForce &spatialForce)
Copy constructor.
void setIncludingFrame(ReferenceFramePtr referenceFrame, const SpatialVector &v)
ForceVector operator*(const SpatialTransform &X, ForceVector f)
Operator for transforming a ForceVector. Calls the ForceVector::transform method. ...
SpatialForce(ReferenceFramePtr referenceFrame, const SpatialVector &spatialVector)
Constructor.
FrameVector getFramedLinearPart() const
Get linear part of spatial force as a frame vector.
void setIncludingFrame(ReferenceFramePtr referenceFrame, const Vector3d &m, const Vector3d &f)
ReferenceFramePtr referenceFrame
Definition: FrameObject.hpp:81
A ForceVector is a SpatialVector containing 3 moments and 3 linear forces.
Definition: ForceVector.hpp:27
SpatialForce(ReferenceFramePtr referenceFrame)
Constructor. Force vector elements will be zero.
EIGEN_STRONG_INLINE ForceVector()
Empty constructor.
Definition: ForceVector.hpp:55
EIGEN_STRONG_INLINE double & fy()
Get reference to y-linear component.
FramePoint operator+(FramePoint p, const FrameVector &v)
Definition: FramePoint.hpp:295
void checkReferenceFramesMatch(const FrameObject *frameObject) const
Check if two ReferenceFrameHolders hold the same ReferenceFrame.
Definition: FrameObject.hpp:70
EIGEN_STRONG_INLINE double & fx()
Get reference to x-linear component.
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.
SpatialForce(ReferenceFramePtr referenceFrame, const Vector3d &m, const Vector3d f)
Constructor.
SpatialForce operator-=(const SpatialForce &f)
Overloaded -= operator. Frame checks are performed.
FrameVector getFramedAngularPart() const
Get angular part of spatial force as a frame vector.
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
EIGEN_STRONG_INLINE double & my()
Get reference to y-angular component.
virtual void changeFrame(ReferenceFramePtr desiredFrame)
Change the ReferenceFrame this FrameObject is expressed in.
Definition: FrameObject.cpp:12
A FrameVector is a 3D vector with a ReferenceFrame, and all operations between FrameVectors and other...
Definition: FrameVector.hpp:33
EIGEN_STRONG_INLINE double & mz()
Get reference to z-angular component.
void setIncludingFrame(ReferenceFramePtr referenceFrame, double wx, double wy, double wz, double vx, double vy, double vz)
EIGEN_STRONG_INLINE Vector3d getAngularPart() const
FramePoint operator-(FramePoint p, const FrameVector &v)
Definition: FramePoint.hpp:301
A SpatialForce is a spatial vector with the angular part being three moments and the linear part bein...
SpatialForce operator*=(double scale)
Operator for scaling a spatial force vector.
EIGEN_STRONG_INLINE double & mx()
Get reference to x-angular component.
Definition: ForceVector.hpp:96
EIGEN_STRONG_INLINE Vector3d getLinearPart() const
SpatialForce operator+=(const SpatialForce &f)
Overloaded += operator. Frame checks are performed.
SpatialForce changeFrameAndCopy(ReferenceFramePtr referenceFrame) const
Copy and change frame.
ForceVector toForceVector() const
Get copy of this SpatialForce as type ForceVector.
An interface that objects with a ReferenceFrame extend to inherit the FrameObject::changeFrame method...
Definition: FrameObject.hpp:28
Namespace for all structures of the RobotDynamics library.
Definition: Body.h:21


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