Robot Dynamics Library
MotionVector.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_MOTION_VECTOR_HPP__
6 #define __RDL_MOTION_VECTOR_HPP__
7 
15 
16 namespace RobotDynamics
17 {
18 namespace Math
19 {
21 {
22  public:
27  template <typename OtherDerived>
28  // cppcheck-suppress noExplicitConstructor
29  MotionVector(const Eigen::MatrixBase<OtherDerived>& other) : SpatialVector(other)
30  {
31  }
32 
34  {
35  }
36 
43  {
45  return *this;
46  }
47 
51  EIGEN_STRONG_INLINE MotionVector() : SpatialVector(0., 0., 0., 0., 0., 0.)
52  {
53  }
54 
64  MotionVector(const double v0, const double v1, const double v2, const double v3, const double v4, const double v5)
65  {
66  Base::_check_template_params();
67 
68  (*this) << v0, v1, v2, v3, v4, v5;
69  }
70 
75  EIGEN_STRONG_INLINE SpatialVector toSpatialVector() const
76  {
77  return *this;
78  }
79 
84  EIGEN_STRONG_INLINE void set(const MotionVector& v)
85  {
86  (*this) << v[0], v[1], v[2], v[3], v[4], v[5];
87  }
88 
93  EIGEN_STRONG_INLINE double& wx()
94  {
95  return this->operator[](0);
96  }
97 
102  EIGEN_STRONG_INLINE double& wy()
103  {
104  return this->operator[](1);
105  }
106 
111  EIGEN_STRONG_INLINE double& wz()
112  {
113  return this->operator[](2);
114  }
115 
120  EIGEN_STRONG_INLINE double wx() const
121  {
122  return this->operator[](0);
123  }
124 
129  EIGEN_STRONG_INLINE double wy() const
130  {
131  return this->operator[](1);
132  }
133 
138  EIGEN_STRONG_INLINE double wz() const
139  {
140  return this->operator[](2);
141  }
142 
147  EIGEN_STRONG_INLINE double& vx()
148  {
149  return this->operator[](3);
150  }
151 
156  EIGEN_STRONG_INLINE double& vy()
157  {
158  return this->operator[](4);
159  }
160 
165  EIGEN_STRONG_INLINE double& vz()
166  {
167  return this->operator[](5);
168  }
169 
174  EIGEN_STRONG_INLINE double vx() const
175  {
176  return this->operator[](3);
177  }
178 
183  EIGEN_STRONG_INLINE double vy() const
184  {
185  return this->operator[](4);
186  }
187 
192  EIGEN_STRONG_INLINE double vz() const
193  {
194  return this->operator[](5);
195  }
196 
201  inline void transform(const SpatialTransform& X)
202  {
203  this->setLinearPart(-X.E * X.r.cross(this->getAngularPart()) + X.E * this->getLinearPart());
204  this->setAngularPart(X.E * this->getAngularPart());
205  }
206 
213  {
214  MotionVector v = *this;
215  v.transform(X);
216  return v;
217  }
218 
233  MotionVector cross(const MotionVector& v);
234 
248  ForceVector cross(const ForceVector& v);
249 
262  {
263  return SpatialMatrix(0, -this->operator[](2), this->operator[](1), 0, 0, 0, this->operator[](2), 0, -this->operator[](0), 0, 0, 0, -this->operator[](1),
264  this->operator[](0), 0, 0, 0, 0, 0, -this->operator[](5), this->operator[](4), 0, -this->operator[](2), this->operator[](1),
265  this->operator[](5), 0, -this->operator[](3), this->operator[](2), 0, -this->operator[](0), -this->operator[](4), this->operator[](3), 0,
266  -this->operator[](1), this->operator[](0), 0);
267  }
268 
274  {
275  return SpatialMatrix(0, -this->operator[](2), this->operator[](1), 0, -this->operator[](5), this->operator[](4), this->operator[](2), 0, -this->operator[](0),
276  this->operator[](5), 0, -this->operator[](3), -this->operator[](1), this->operator[](0), 0, -this->operator[](4), this->operator[](3), 0, 0,
277  0, 0, 0, -this->operator[](2), this->operator[](1), 0, 0, 0, this->operator[](2), 0, -this->operator[](0), 0, 0, 0, -this->operator[](1),
278  this->operator[](0), 0);
279  }
280 
288  {
289  return this->cross(v);
290  }
291 
299  {
300  return this->cross(v);
301  }
302 
308  {
309  (*this) << (this->wx() += v.wx()), (this->wy() += v.wy()), (this->wz() += v.wz()), (this->vx() += v.vx()), (this->vy() += v.vy()), (this->vz() += v.vz());
310  return *this;
311  }
312 };
313 
321 {
322  v.transform(X);
323  return v;
324 }
325 
333 {
334  return v.MotionVector::operator%=(v2);
335 }
336 
344 {
345  return v.MotionVector::operator%=(v2);
346 }
347 typedef std::vector<MotionVector, Eigen::aligned_allocator<MotionVector>> MotionVectorV;
348 } // namespace Math
349 } // namespace RobotDynamics
350 
351 #endif
Contains various geometric objects that have methods for transforming themselves into different frame...
A ForceVector is a SpatialVector containing 3 moments and 3 linear forces.
Definition: ForceVector.hpp:23
Definition: MotionVector.hpp:21
MotionVector(const Eigen::MatrixBase< OtherDerived > &other)
Constructor.
Definition: MotionVector.hpp:29
EIGEN_STRONG_INLINE double vx() const
Get a copy of the linear-x component.
Definition: MotionVector.hpp:174
EIGEN_STRONG_INLINE double & vy()
Get a reference to the linear-y component.
Definition: MotionVector.hpp:156
SpatialMatrix crossm()
Get the spatial motion cross matrix,.
Definition: MotionVector.hpp:261
MotionVector operator%=(const MotionVector &v)
Operator for performing the RBDA operator for two motion vectors, i.e. .
Definition: MotionVector.hpp:287
EIGEN_STRONG_INLINE double vy() const
Get a copy of the linear-y component.
Definition: MotionVector.hpp:183
EIGEN_STRONG_INLINE double & wy()
Get a reference to the angular-y component.
Definition: MotionVector.hpp:102
ForceVector operator%=(const ForceVector &v)
Operator for performing the RBDA operator for a motion vector and a force vector,...
Definition: MotionVector.hpp:298
MotionVector(const double v0, const double v1, const double v2, const double v3, const double v4, const double v5)
Constructor.
Definition: MotionVector.hpp:64
EIGEN_STRONG_INLINE double & vx()
Get a reference to the linear-x component.
Definition: MotionVector.hpp:147
EIGEN_STRONG_INLINE double vz() const
Get a copy of the linear-z component.
Definition: MotionVector.hpp:192
EIGEN_STRONG_INLINE SpatialVector toSpatialVector() const
Get a copy of a MotionVector as a SpatialVector.
Definition: MotionVector.hpp:75
MotionVector & operator=(const MotionVector &other)
Overload equal operator.
Definition: MotionVector.hpp:42
MotionVector operator+=(const MotionVector &v)
Overloaded += operator for a MotionVector.
Definition: MotionVector.hpp:307
EIGEN_STRONG_INLINE double wz() const
Get a copy of the angular-z component.
Definition: MotionVector.hpp:138
SpatialMatrix crossf()
Get the spatial force cross matrix.
Definition: MotionVector.hpp:273
void transform(const SpatialTransform &X)
Transforms a motion vector. Performs .
Definition: MotionVector.hpp:201
EIGEN_STRONG_INLINE MotionVector()
Empty constructor.
Definition: MotionVector.hpp:51
EIGEN_STRONG_INLINE double wy() const
Get a copy of the angular-y component.
Definition: MotionVector.hpp:129
EIGEN_STRONG_INLINE double wx() const
Get a copy of the angular-x component.
Definition: MotionVector.hpp:120
EIGEN_STRONG_INLINE double & vz()
Get a reference to the linear-z component.
Definition: MotionVector.hpp:165
MotionVector cross(const MotionVector &v)
See V. Duindum thesis p.25 for an explanation of what operator is. It is also in Featherstone p....
Definition: MotionVector.cpp:11
MotionVector transform_copy(const SpatialTransform &X) const
Copies, transforms, and returns a MotionVector. Performs .
Definition: MotionVector.hpp:212
MotionVector(const MotionVector &v)
Definition: MotionVector.hpp:33
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
Definition: rdl_eigenmath.hpp:354
Definition: rdl_eigenmath.hpp:187
SpatialVector & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Definition: rdl_eigenmath.hpp:198
void setLinearPart(const Vector3d &v)
Definition: rdl_eigenmath.hpp:266
void setAngularPart(const Vector3d &v)
Definition: rdl_eigenmath.hpp:254
The TransformableGeometricObject class is an essential interface because it forces all geometric obje...
Definition: rdl_eigenmath.hpp:43
MotionVector operator%(MotionVector v, const MotionVector &v2)
Definition: MotionVector.hpp:332
std::vector< MotionVector, Eigen::aligned_allocator< MotionVector > > MotionVectorV
Definition: MotionVector.hpp:347
ForceVector operator*(const SpatialTransform &X, ForceVector f)
Operator for transforming a ForceVector. Calls the ForceVector::transform method.
Definition: ForceVector.hpp:248
Namespace for all structures of the RobotDynamics library.
Definition: examples.hpp:19
Compact representation of spatial transformations.
Definition: rdl_eigenmath.hpp:412
Matrix3d E
Definition: rdl_eigenmath.hpp:595
Vector3d r
Definition: rdl_eigenmath.hpp:596