SpatialMotion.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_MOTION_HPP__
9 #define __RDL_SPATIAL_MOTION_HPP__
10 
21 
22 namespace RobotDynamics
23 {
24 namespace Math
25 {
35 class SpatialMotion : public MotionVector, public FrameObject
36 {
37  public:
43  {
44  bodyFrame = nullptr;
45  baseFrame = nullptr;
46  }
47 
60  SpatialMotion(ReferenceFramePtr bodyFrame, ReferenceFramePtr baseFrame, ReferenceFramePtr expressedInFrame, const double wx, const double wy, const double wz,
61  const double vx, const double vy, const double vz)
62  : MotionVector(wx, wy, wz, vx, vy, vz), FrameObject(expressedInFrame)
63  {
64  this->bodyFrame = bodyFrame;
65  this->baseFrame = baseFrame;
66  }
67 
77  : MotionVector(w.x(), w.y(), w.z(), v.x(), v.y(), v.z()), FrameObject(expressedInFrame)
78  {
79  this->bodyFrame = bodyFrame;
80  this->baseFrame = baseFrame;
81  }
82 
91  : MotionVector(v), FrameObject(expressedInFrame)
92  {
93  this->bodyFrame = bodyFrame;
94  this->baseFrame = baseFrame;
95  }
96 
101  SpatialMotion(const SpatialMotion& spatialMotion) : MotionVector(spatialMotion), FrameObject(spatialMotion.referenceFrame)
102  {
103  this->bodyFrame = spatialMotion.bodyFrame;
104  this->baseFrame = spatialMotion.baseFrame;
105  }
106 
112  {
113  return FrameVector(this->referenceFrame, this->getLinearPart());
114  }
115 
121  {
122  return FrameVector(this->referenceFrame, this->getAngularPart());
123  }
124 
126  {
127  return this;
128  }
129 
136  {
137  SpatialMotion ret = *this;
138  ret.changeFrame(referenceFrame);
139  return ret;
140  }
141 
147  {
148  return bodyFrame;
149  }
150 
156  {
157  return baseFrame;
158  }
159 
165  {
166  return *this;
167  }
168 
170  {
171  this->set(v);
172  this->referenceFrame = referenceFrame;
173  }
174 
175  void setIncludingFrame(ReferenceFramePtr referenceFrame, double wx, double wy, double wz, double vx, double vy, double vz)
176  {
177  this->SpatialVector::set(wx, wy, wz, vx, vy, vz);
178  this->referenceFrame = referenceFrame;
179  }
180 
182  {
184  this->referenceFrame = other.getReferenceFrame();
185  this->bodyFrame = other.getBodyFrame();
186  this->baseFrame = other.getBaseFrame();
187  return *this;
188  }
189 
194  void operator+=(const SpatialMotion& v);
195 
200  void operator-=(const SpatialMotion& v);
201 
217  void operator%=(const SpatialMotion& v);
218 
225  {
226  this->bodyFrame = referenceFrame;
227  }
228 
234  {
235  this->baseFrame = referenceFrame;
236  }
237 
238  protected:
241 };
242 
243 EIGEN_STRONG_INLINE SpatialMotion operator+(SpatialMotion v1, const SpatialMotion& v2)
244 {
245  v1 += v2;
246  return v1;
247 }
248 
249 EIGEN_STRONG_INLINE SpatialMotion operator-(SpatialMotion v1, const SpatialMotion& v2)
250 {
251  v1 -= v2;
252  return v1;
253 }
254 
255 EIGEN_STRONG_INLINE SpatialMotion operator%(SpatialMotion v1, const SpatialMotion& v2)
256 {
257  v1.SpatialMotion::operator%=(v2);
258  return v1;
259 }
260 typedef std::vector<SpatialMotion, Eigen::aligned_allocator<SpatialMotion>> SpatialMotionV;
261 } // namespace Math
262 } // namespace RobotDynamics
263 
264 #endif //__RDL_SPATIAL_MOTION_HPP__
EIGEN_STRONG_INLINE void set(const double &v0, const double &v1, const double &v2, const double &v3, const double &v4, const double &v5)
ReferenceFramePtr getReferenceFrame() const
Get a pointer to the reference frame this FrameObject is expressed in.
Definition: FrameObject.hpp:52
SpatialMotion(ReferenceFramePtr bodyFrame, ReferenceFramePtr baseFrame, ReferenceFramePtr expressedInFrame, const Vector3d &w, const Vector3d v)
Constructor.
void setIncludingFrame(ReferenceFramePtr referenceFrame, const SpatialVector &v)
void operator-=(const SpatialMotion &v)
Overloaded -= operator. Frame checks are performed.
MotionVector toMotionVector() const
Get a copy of this SpatialMotion as type MotionVector.
void operator%=(const SpatialMotion &v)
This is an operator for performing what is referred to in Featherstone as the spatial vector cross( )...
EIGEN_STRONG_INLINE double & vz()
Get a reference to the linear-z component.
ReferenceFramePtr referenceFrame
Definition: FrameObject.hpp:81
SpatialMotion(ReferenceFramePtr bodyFrame, ReferenceFramePtr baseFrame, ReferenceFramePtr expressedInFrame, const SpatialVector &v)
Constructor.
FramePoint operator+(FramePoint p, const FrameVector &v)
Definition: FramePoint.hpp:295
FrameVector getFramedAngularPart() const
Get angular part of spatial motion as a frame vector.
MotionVector & operator=(const MotionVector &other)
Overload equal operator.
MotionVector operator%(MotionVector v, const MotionVector &v2)
EIGEN_STRONG_INLINE double & wx()
Get a reference to the angular-x component.
EIGEN_STRONG_INLINE double & wy()
Get a reference to the angular-y component.
SpatialMotion(ReferenceFramePtr bodyFrame, ReferenceFramePtr baseFrame, ReferenceFramePtr expressedInFrame, const double wx, const double wy, const double wz, const double vx, const double vy, const double vz)
Constructor.
FrameVector getFramedLinearPart() const
Get linear part of spatial motion as a frame vector.
void operator+=(const SpatialMotion &v)
Overloaded += operator. Frame checks are performed.
SpatialMotion(const SpatialMotion &spatialMotion)
Copy constructor.
EIGEN_STRONG_INLINE double & vx()
Get a reference to the linear-x component.
SpatialMotion & operator=(const SpatialMotion &other)
The TransformableGeometricObject class is an essential interface because it forces all geometric obje...
Definition: rdl_eigenmath.h:43
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
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
A SpatialMotion vector is a MotionVector with a RobotDynamics::ReferenceFrame it is expressed in...
ReferenceFramePtr getBaseFrame() const
Get a SpatialMotions SpatialMotion::baseFrame.
EIGEN_STRONG_INLINE double & wz()
Get a reference to the angular-z component.
EIGEN_STRONG_INLINE double & vy()
Get a reference to the linear-y component.
std::vector< SpatialMotion, Eigen::aligned_allocator< SpatialMotion > > SpatialMotionV
ReferenceFramePtr getBodyFrame() const
Get a SpatialMotions SpatialMotion::bodyFrame.
EIGEN_STRONG_INLINE Vector3d getAngularPart() const
SpatialMotion()
Constructor. SpatialMotion::bodyFrame, SpatialMotion::baseFrame, and RobotDynamics::FrameObject::refe...
FramePoint operator-(FramePoint p, const FrameVector &v)
Definition: FramePoint.hpp:301
SpatialMotion changeFrameAndCopy(ReferenceFramePtr referenceFrame) const
Copy and change frame.
EIGEN_STRONG_INLINE Vector3d getLinearPart() const
void setIncludingFrame(ReferenceFramePtr referenceFrame, double wx, double wy, double wz, double vx, double vy, double vz)
Math::TransformableGeometricObject * getTransformableGeometricObject()
Pure virtual method that FrameObjects are required to implement so the FrameObject::changeFrame metho...
void setBaseFrame(ReferenceFramePtr referenceFrame)
Sets the base frame of a spatial motion.
void setBodyFrame(ReferenceFramePtr referenceFrame)
Sets the body frame of a spatial motion.
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