FrameVectorPair.hpp
Go to the documentation of this file.
1 /*
2  * RDL - Robot Dynamics Library
3  * Copyright (c) 2018 Jordan Lack <jlack1987@gmail.com>
4  *
5  * Licensed under the zlib license. See LICENSE for more details.
6  */
7 
8 #ifndef __RDL_FRAME_VECTOR_PAIR_HPP__
9 #define __RDL_FRAME_VECTOR_PAIR_HPP__
10 
23 
24 namespace RobotDynamics
25 {
26 namespace Math
27 {
34 {
35  public:
39  FrameVectorPair() : lin(nullptr, 0., 0., 0.), ang(nullptr, 0., 0., 0.)
40  {
41  }
42 
43  /*
44  * @brief constructor
45  * @param linear Linear part
46  * @param angular Angular part
47  */
48  FrameVectorPair(const FrameVector& linear, const FrameVector& angular) : lin(linear), ang(angular)
49  {
50  linear.checkReferenceFramesMatch(&angular);
51  }
52 
53  /*
54  * @brief constructor
55  * @param referenceFrame pointer to a reference frame
56  */
57  explicit FrameVectorPair(ReferenceFramePtr referenceFrame) : lin(referenceFrame), ang(referenceFrame)
58  {
59  }
60 
65  explicit FrameVectorPair(const SpatialMotion& v)
66  {
69  }
70 
77  FrameVectorPair(ReferenceFramePtr referenceFrame, const Vector3d& linear, const Vector3d& angular) : lin(referenceFrame, linear), ang(referenceFrame, angular)
78  {
79  }
80 
86  FrameVectorPair(ReferenceFramePtr referenceFrame, const SpatialVector& v) : lin(referenceFrame, v.getLinearPart()), ang(referenceFrame, v.getAngularPart())
87  {
88  }
89 
93  virtual ~FrameVectorPair()
94  {
95  }
96 
112  void changeFrame(ReferenceFramePtr referenceFrame)
113  {
114  assert(referenceFrame);
115  lin.changeFrame(referenceFrame);
116  ang.changeFrame(referenceFrame);
117  }
118 
125  {
126  FrameVectorPair p = *this;
127  p.changeFrame(referenceFrame);
128  return p;
129  }
130 
134  inline void setToZero()
135  {
136  lin.setZero();
137  ang.setZero();
138  }
139 
145  {
146  lin.setReferenceFrame(referenceFrame);
147  ang.setReferenceFrame(referenceFrame);
148  }
149 
156  inline void setIncludingFrame(ReferenceFramePtr referenceFrame, const Vector3d& linear, const Vector3d& angular)
157  {
158  assert(referenceFrame);
159 
160  lin.setIncludingFrame(linear, referenceFrame);
161  ang.setIncludingFrame(angular, referenceFrame);
162  }
163 
169  inline void setIncludingFrame(ReferenceFramePtr referenceFrame, const SpatialVector& v)
170  {
171  assert(referenceFrame);
172 
173  lin.setIncludingFrame(v.getLinearPart(), referenceFrame);
174  ang.setIncludingFrame(v.getAngularPart(), referenceFrame);
175  }
176 
182  inline void setIncludingFrame(ReferenceFramePtr referenceFrame, const MotionVector& v)
183  {
184  assert(referenceFrame);
185 
186  lin.setIncludingFrame(v.getLinearPart(), referenceFrame);
187  ang.setIncludingFrame(v.getAngularPart(), referenceFrame);
188  }
189 
194  inline void setIncludingFrame(const SpatialMotion& v)
195  {
198  }
199 
204  inline void setLinearPart(const Vector3d& v)
205  {
206  lin.set(v);
207  }
208 
213  inline void setAngularPart(const Vector3d& v)
214  {
215  ang.set(v);
216  }
217 
222  inline FrameVector linear() const
223  {
224  return lin;
225  }
226 
231  inline FrameVector angular() const
232  {
233  return ang;
234  }
235 
236  template <typename T>
237  void operator*=(const T scale)
238  {
239  lin *= scale;
240  ang *= scale;
241  }
242 
244  {
245  lin += v.linear();
246  ang += v.angular();
247  }
248 
250  {
251  lin -= v.linear();
252  ang -= v.angular();
253  }
254 
260  {
261  return &lin;
262  }
263 
269  {
270  return &ang;
271  }
272 
273  protected:
276 };
277 
278 template <typename T>
279 inline FrameVectorPair operator*(FrameVectorPair pair, const T scalar)
280 {
281  pair *= scalar;
282  return pair;
283 }
284 
285 template <typename T>
286 inline FrameVectorPair operator*(const T scalar, FrameVectorPair pair)
287 {
288  pair *= scalar;
289  return pair;
290 }
291 
292 // cppcheck-suppress passedByValue
294 {
295  v1 += v2;
296  return v1;
297 }
298 
299 // cppcheck-suppress passedByValue
301 {
302  v1 -= v2;
303  return v1;
304 }
305 } // namespace Math
306 } // namespace RobotDynamics
307 
308 #endif // ifndef __RDL_FRAME_VECTOR_HPP__
ReferenceFramePtr getReferenceFrame() const
Get a pointer to the reference frame this FrameObject is expressed in.
Definition: FrameObject.hpp:52
ForceVector operator*(const SpatialTransform &X, ForceVector f)
Operator for transforming a ForceVector. Calls the ForceVector::transform method. ...
FrameVectorPair(ReferenceFramePtr referenceFrame)
FrameVector linear() const
Get copy of linear component.
void setAngularPart(const Vector3d &v)
Set the angular vector.
void setIncludingFrame(const SpatialMotion &v)
Set the components and the ReferenceFrame these components are expressed in.
FrameVector angular() const
Get copy of angular component.
void setReferenceFrame(ReferenceFramePtr frame)
Set frame objects internal reference frame.
Definition: FrameObject.hpp:61
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
void operator+=(const FrameVectorPair &v)
void setIncludingFrame(ReferenceFramePtr referenceFrame, const MotionVector &v)
Set the components and the ReferenceFrame these components are expressed in.
FrameVectorPair(ReferenceFramePtr referenceFrame, const SpatialVector &v)
Constructor.
std::shared_ptr< ReferenceFrame > ReferenceFramePtr
FrameVectorPair()
Default constructor. Initializes its ReferenceFrame to nullptr.
virtual void changeFrame(ReferenceFramePtr desiredFrame)
Change the ReferenceFrame this FrameObject is expressed in.
Definition: FrameObject.cpp:12
void setIncludingFrame(const double x, const double y, const double z, ReferenceFramePtr referenceFrame)
Set the x, y, and z components and the ReferenceFrame these components are expressed in...
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...
void changeFrame(ReferenceFramePtr referenceFrame)
Change the frame of the two 3d vectors. Equivalent to the following math expression ...
void operator-=(const FrameVectorPair &v)
FrameVectorPair(const SpatialMotion &v)
Constructor.
FrameVectorPair(const FrameVector &linear, const FrameVector &angular)
EIGEN_STRONG_INLINE Vector3d getAngularPart() const
void setLinearPart(const Vector3d &v)
Set the linear vector.
FramePoint operator-(FramePoint p, const FrameVector &v)
Definition: FramePoint.hpp:301
void setToZero()
Set x, y, and z components of linear and angular to 0.
FrameVector * angularPtr()
Get pointer to angular vector.
void set(const Eigen::Vector3d &v)
Definition: rdl_eigenmath.h:83
FrameVectorPair changeFrameAndCopy(ReferenceFramePtr referenceFrame) const
copy into new frame vector and change the frame of that
FrameVectorPair(ReferenceFramePtr referenceFrame, const Vector3d &linear, const Vector3d &angular)
Constructor.
A FrameVector is a pair of 3D vector with a ReferenceFrame.
EIGEN_STRONG_INLINE Vector3d getLinearPart() const
void setIncludingFrame(ReferenceFramePtr referenceFrame, const SpatialVector &v)
Set the components and the ReferenceFrame these components are expressed in.
void setReferenceFrame(ReferenceFramePtr referenceFrame)
Set the reference frame.
void setIncludingFrame(ReferenceFramePtr referenceFrame, const Vector3d &linear, const Vector3d &angular)
Set the components and the ReferenceFrame these components are expressed in.
Namespace for all structures of the RobotDynamics library.
Definition: Body.h:21
FrameVector * linearPtr()
Get pointer to linear vector.


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