Robot Dynamics Library
SpatialMotion.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_SPATIAL_MOTION_HPP__
6 #define __RDL_SPATIAL_MOTION_HPP__
7 
18 
19 namespace RobotDynamics
20 {
21 namespace Math
22 {
32 class SpatialMotion : public MotionVector, public FrameObject
33 {
34  public:
40  {
41  bodyFrame = nullptr;
42  baseFrame = nullptr;
43  }
44 
57  SpatialMotion(ReferenceFramePtr bodyFrame, ReferenceFramePtr baseFrame, ReferenceFramePtr expressedInFrame, const double wx, const double wy, const double wz,
58  const double vx, const double vy, const double vz)
59  : MotionVector(wx, wy, wz, vx, vy, vz), FrameObject(expressedInFrame)
60  {
61  this->bodyFrame = bodyFrame;
62  this->baseFrame = baseFrame;
63  }
64 
74  : MotionVector(w.x(), w.y(), w.z(), v.x(), v.y(), v.z()), FrameObject(expressedInFrame)
75  {
76  this->bodyFrame = bodyFrame;
77  this->baseFrame = baseFrame;
78  }
79 
88  : MotionVector(v), FrameObject(expressedInFrame)
89  {
90  this->bodyFrame = bodyFrame;
91  this->baseFrame = baseFrame;
92  }
93 
98  SpatialMotion(const SpatialMotion& spatialMotion) : MotionVector(spatialMotion), FrameObject(spatialMotion.referenceFrame)
99  {
100  this->bodyFrame = spatialMotion.bodyFrame;
101  this->baseFrame = spatialMotion.baseFrame;
102  }
103 
109  {
110  return FrameVector(this->referenceFrame, this->getLinearPart());
111  }
112 
118  {
119  return FrameVector(this->referenceFrame, this->getAngularPart());
120  }
121 
123  {
124  return this;
125  }
126 
133  {
134  SpatialMotion ret = *this;
136  return ret;
137  }
138 
144  {
145  return bodyFrame;
146  }
147 
153  {
154  return baseFrame;
155  }
156 
162  {
163  return *this;
164  }
165 
167  {
168  this->set(v);
169  this->referenceFrame = referenceFrame;
170  }
171 
172  void setIncludingFrame(ReferenceFramePtr referenceFrame, double wx, double wy, double wz, double vx, double vy, double vz)
173  {
174  this->SpatialVector::set(wx, wy, wz, vx, vy, vz);
175  this->referenceFrame = referenceFrame;
176  }
177 
179  {
180  this->SpatialVector::set(angularPart, linearPart);
181  this->referenceFrame = referenceFrame;
182  }
183 
185  {
187  this->referenceFrame = v.getReferenceFrame();
188  this->bodyFrame = v.getBodyFrame();
189  this->baseFrame = v.getBaseFrame();
190  return *this;
191  }
192 
197  void operator+=(const SpatialMotion& v);
198 
203  void operator-=(const SpatialMotion& v);
204 
220  void operator%=(const SpatialMotion& v);
221 
228  {
229  this->bodyFrame = referenceFrame;
230  }
231 
237  {
238  this->baseFrame = referenceFrame;
239  }
240 
241  protected:
244 };
245 
246 EIGEN_STRONG_INLINE SpatialMotion operator+(SpatialMotion v1, const SpatialMotion& v2)
247 {
248  v1 += v2;
249  return v1;
250 }
251 
252 EIGEN_STRONG_INLINE SpatialMotion operator-(SpatialMotion v1, const SpatialMotion& v2)
253 {
254  v1 -= v2;
255  return v1;
256 }
257 
258 EIGEN_STRONG_INLINE SpatialMotion operator%(SpatialMotion v1, const SpatialMotion& v2)
259 {
260  v1.SpatialMotion::operator%=(v2);
261  return v1;
262 }
263 typedef std::vector<SpatialMotion, Eigen::aligned_allocator<SpatialMotion>> SpatialMotionV;
264 } // namespace Math
265 } // namespace RobotDynamics
266 
267 #endif //__RDL_SPATIAL_MOTION_HPP__
Contains various geometric objects that have methods for transforming themselves into different frame...
An interface that objects with a ReferenceFrame extend to inherit the FrameObject::changeFrame method...
Definition: FrameObject.hpp:26
virtual void changeFrame(ReferenceFramePtr desiredFrame)
Change the ReferenceFrame this FrameObject is expressed in.
Definition: FrameObject.cpp:9
ReferenceFramePtr getReferenceFrame() const
Get a pointer to the reference frame this FrameObject is expressed in.
Definition: FrameObject.hpp:49
ReferenceFramePtr referenceFrame
Definition: FrameObject.hpp:78
A FrameVector is a 3D vector with a ReferenceFrame, and all operations between FrameVectors and other...
Definition: FrameVector.hpp:31
Definition: MotionVector.hpp:21
EIGEN_STRONG_INLINE double & vy()
Get a reference to the linear-y component.
Definition: MotionVector.hpp:156
EIGEN_STRONG_INLINE double & wy()
Get a reference to the angular-y component.
Definition: MotionVector.hpp:102
EIGEN_STRONG_INLINE double & vx()
Get a reference to the linear-x component.
Definition: MotionVector.hpp:147
EIGEN_STRONG_INLINE double & vz()
Get a reference to the linear-z component.
Definition: MotionVector.hpp:165
EIGEN_STRONG_INLINE void set(const MotionVector &v)
Setter.
Definition: MotionVector.hpp:84
EIGEN_STRONG_INLINE double & wz()
Get a reference to the angular-z component.
Definition: MotionVector.hpp:111
EIGEN_STRONG_INLINE double & wx()
Get a reference to the angular-x component.
Definition: MotionVector.hpp:93
A SpatialMotion vector is a MotionVector with a RobotDynamics::ReferenceFrame it is expressed in....
Definition: SpatialMotion.hpp:33
SpatialMotion(ReferenceFramePtr bodyFrame, ReferenceFramePtr baseFrame, ReferenceFramePtr expressedInFrame, const Vector3d &w, const Vector3d v)
Constructor.
Definition: SpatialMotion.hpp:73
SpatialMotion()
Constructor. SpatialMotion::bodyFrame, SpatialMotion::baseFrame, and RobotDynamics::FrameObject::refe...
Definition: SpatialMotion.hpp:39
void setIncludingFrame(ReferenceFramePtr referenceFrame, const SpatialVector &v)
Definition: SpatialMotion.hpp:166
void setIncludingFrame(ReferenceFramePtr referenceFrame, Vector3d angularPart, Vector3d linearPart)
Definition: SpatialMotion.hpp:178
void setBaseFrame(ReferenceFramePtr referenceFrame)
Sets the base frame of a spatial motion.
Definition: SpatialMotion.hpp:236
FrameVector getFramedLinearPart() const
Get linear part of spatial motion as a frame vector.
Definition: SpatialMotion.hpp:108
void setIncludingFrame(ReferenceFramePtr referenceFrame, double wx, double wy, double wz, double vx, double vy, double vz)
Definition: SpatialMotion.hpp:172
SpatialMotion changeFrameAndCopy(ReferenceFramePtr referenceFrame) const
Copy and change frame.
Definition: SpatialMotion.hpp:132
ReferenceFramePtr baseFrame
Definition: SpatialMotion.hpp:243
void operator%=(const SpatialMotion &v)
This is an operator for performing what is referred to in Featherstone as the spatial vector cross( )...
Definition: SpatialMotion.cpp:53
ReferenceFramePtr getBaseFrame() const
Get a SpatialMotions SpatialMotion::baseFrame.
Definition: SpatialMotion.hpp:152
SpatialMotion(const SpatialMotion &spatialMotion)
Copy constructor.
Definition: SpatialMotion.hpp:98
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.
Definition: SpatialMotion.hpp:57
FrameVector getFramedAngularPart() const
Get angular part of spatial motion as a frame vector.
Definition: SpatialMotion.hpp:117
ReferenceFramePtr bodyFrame
Definition: SpatialMotion.hpp:242
SpatialMotion(ReferenceFramePtr bodyFrame, ReferenceFramePtr baseFrame, ReferenceFramePtr expressedInFrame, const SpatialVector &v)
Constructor.
Definition: SpatialMotion.hpp:87
MotionVector toMotionVector() const
Get a copy of this SpatialMotion as type MotionVector.
Definition: SpatialMotion.hpp:161
SpatialMotion & operator=(const SpatialMotion &v)
Definition: SpatialMotion.hpp:184
void setBodyFrame(ReferenceFramePtr referenceFrame)
Sets the body frame of a spatial motion.
Definition: SpatialMotion.hpp:227
void operator+=(const SpatialMotion &v)
Overloaded += operator. Frame checks are performed.
Definition: SpatialMotion.cpp:11
Math::TransformableGeometricObject * getTransformableGeometricObject()
Pure virtual method that FrameObjects are required to implement so the FrameObject::changeFrame metho...
Definition: SpatialMotion.hpp:122
ReferenceFramePtr getBodyFrame() const
Get a SpatialMotions SpatialMotion::bodyFrame.
Definition: SpatialMotion.hpp:143
void operator-=(const SpatialMotion &v)
Overloaded -= operator. Frame checks are performed.
Definition: SpatialMotion.cpp:27
Definition: rdl_eigenmath.hpp:187
SpatialVector & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Definition: rdl_eigenmath.hpp:198
EIGEN_STRONG_INLINE void set(const double &v0, const double &v1, const double &v2, const double &v3, const double &v4, const double &v5)
Definition: rdl_eigenmath.hpp:223
EIGEN_STRONG_INLINE Vector3d getLinearPart() const
Definition: rdl_eigenmath.hpp:235
EIGEN_STRONG_INLINE Vector3d getAngularPart() const
Definition: rdl_eigenmath.hpp:230
The TransformableGeometricObject class is an essential interface because it forces all geometric obje...
Definition: rdl_eigenmath.hpp:43
Definition: rdl_eigenmath.hpp:54
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
Definition: ReferenceFrame.hpp:68
std::vector< SpatialMotion, Eigen::aligned_allocator< SpatialMotion > > SpatialMotionV
Definition: SpatialMotion.hpp:263
FramePoint operator-(FramePoint p, const FrameVector &v)
Definition: FramePoint.hpp:410
FramePoint operator+(FramePoint p, const FrameVector &v)
Definition: FramePoint.hpp:404
MotionVector operator%(MotionVector v, const MotionVector &v2)
Definition: MotionVector.hpp:332
Namespace for all structures of the RobotDynamics library.
Definition: examples.hpp:19