MotionVector.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_MOTION_VECTOR_HPP__
9 #define __RDL_MOTION_VECTOR_HPP__
10 
19 
20 namespace RobotDynamics
21 {
22 namespace Math
23 {
25 {
26  public:
31  template <typename OtherDerived>
32  // cppcheck-suppress noExplicitConstructor
33  MotionVector(const Eigen::MatrixBase<OtherDerived>& other) : SpatialVector(other)
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.data()[0], v.data()[1], v.data()[2], v.data()[3], v.data()[4], v.data()[5];
87  }
88 
93  EIGEN_STRONG_INLINE double& wx()
94  {
95  return this->data()[0];
96  }
97 
102  EIGEN_STRONG_INLINE double& wy()
103  {
104  return this->data()[1];
105  }
106 
111  EIGEN_STRONG_INLINE double& wz()
112  {
113  return this->data()[2];
114  }
115 
120  EIGEN_STRONG_INLINE double wx() const
121  {
122  return this->data()[0];
123  }
124 
129  EIGEN_STRONG_INLINE double wy() const
130  {
131  return this->data()[1];
132  }
133 
138  EIGEN_STRONG_INLINE double wz() const
139  {
140  return this->data()[2];
141  }
142 
147  EIGEN_STRONG_INLINE double& vx()
148  {
149  return this->data()[3];
150  }
151 
156  EIGEN_STRONG_INLINE double& vy()
157  {
158  return this->data()[4];
159  }
160 
165  EIGEN_STRONG_INLINE double& vz()
166  {
167  return this->data()[5];
168  }
169 
174  EIGEN_STRONG_INLINE double vx() const
175  {
176  return this->data()[3];
177  }
178 
183  EIGEN_STRONG_INLINE double vy() const
184  {
185  return this->data()[4];
186  }
187 
192  EIGEN_STRONG_INLINE double vz() const
193  {
194  return this->data()[5];
195  }
196 
201  inline void transform(const SpatialTransform& X)
202  {
203  Vector3d v_rxw(this->data()[3] - X.r[1] * this->data()[2] + X.r[2] * this->data()[1], this->data()[4] - X.r[2] * this->data()[0] + X.r[0] * this->data()[2],
204  this->data()[5] - X.r[0] * this->data()[1] + X.r[1] * this->data()[0]);
205 
206  *this << X.E(0, 0) * this->data()[0] + X.E(0, 1) * this->data()[1] + X.E(0, 2) * this->data()[2],
207  X.E(1, 0) * this->data()[0] + X.E(1, 1) * this->data()[1] + X.E(1, 2) * this->data()[2],
208  X.E(2, 0) * this->data()[0] + X.E(2, 1) * this->data()[1] + X.E(2, 2) * this->data()[2], X.E(0, 0) * v_rxw[0] + X.E(0, 1) * v_rxw[1] + X.E(0, 2) * v_rxw[2],
209  X.E(1, 0) * v_rxw[0] + X.E(1, 1) * v_rxw[1] + X.E(1, 2) * v_rxw[2], X.E(2, 0) * v_rxw[0] + X.E(2, 1) * v_rxw[1] + X.E(2, 2) * v_rxw[2];
210  }
211 
218  {
219  MotionVector v = *this;
220  v.transform(X);
221  return v;
222  }
223 
238  MotionVector cross(const MotionVector& v);
239 
253  ForceVector cross(const ForceVector& v);
254 
267  {
268  return SpatialMatrix(0, -this->data()[2], this->data()[1], 0, 0, 0, this->data()[2], 0, -this->data()[0], 0, 0, 0, -this->data()[1], this->data()[0], 0, 0, 0, 0,
269  0, -this->data()[5], this->data()[4], 0, -this->data()[2], this->data()[1], this->data()[5], 0, -this->data()[3], this->data()[2], 0,
270  -this->data()[0], -this->data()[4], this->data()[3], 0, -this->data()[1], this->data()[0], 0);
271  }
272 
278  {
279  return SpatialMatrix(0, -this->data()[2], this->data()[1], 0, -this->data()[5], this->data()[4], this->data()[2], 0, -this->data()[0], this->data()[5], 0,
280  -this->data()[3], -this->data()[1], this->data()[0], 0, -this->data()[4], this->data()[3], 0, 0, 0, 0, 0, -this->data()[2], this->data()[1],
281  0, 0, 0, this->data()[2], 0, -this->data()[0], 0, 0, 0, -this->data()[1], this->data()[0], 0);
282  }
283 
291  {
292  return this->cross(v);
293  }
294 
302  {
303  return this->cross(v);
304  }
305 
311  {
312  (*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());
313  return *this;
314  }
315 };
316 
324 {
325  v.transform(X);
326  return v;
327 }
328 
336 {
337  return v.MotionVector::operator%=(v2);
338 }
339 
347 {
348  return v.MotionVector::operator%=(v2);
349 }
350 typedef std::vector<MotionVector, Eigen::aligned_allocator<MotionVector>> MotionVectorV;
351 } // namespace Math
352 } // namespace RobotDynamics
353 
354 #endif
MotionVector operator%=(const MotionVector &v)
Operator for performing the RBDA operator for two motion vectors, i.e. .
EIGEN_STRONG_INLINE double wy() const
Get a copy of the angular-y component.
EIGEN_STRONG_INLINE double vy() const
Get a copy of the linear-y component.
SpatialMatrix crossm()
Get the spatial motion cross matrix, .
SpatialMatrix crossf()
Get the spatial force cross matrix.
ForceVector operator*(const SpatialTransform &X, ForceVector f)
Operator for transforming a ForceVector. Calls the ForceVector::transform method. ...
EIGEN_STRONG_INLINE SpatialVector toSpatialVector() const
Get a copy of a MotionVector as a SpatialVector.
MotionVector cross(const MotionVector &v)
See V. Duindum thesis p.25 for an explanation of what operator is. It is also in Featherstone p...
EIGEN_STRONG_INLINE double & vz()
Get a reference to the linear-z component.
void transform(const SpatialTransform &X)
Transforms a motion vector. Performs .
A ForceVector is a SpatialVector containing 3 moments and 3 linear forces.
Definition: ForceVector.hpp:27
MotionVector & operator=(const MotionVector &other)
Overload equal operator.
EIGEN_STRONG_INLINE double vx() const
Get a copy of the linear-x component.
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.
EIGEN_STRONG_INLINE double & vx()
Get a reference to the linear-x component.
EIGEN_STRONG_INLINE double wz() const
Get a copy of the angular-z component.
The TransformableGeometricObject class is an essential interface because it forces all geometric obje...
Definition: rdl_eigenmath.h:43
MotionVector(const Eigen::MatrixBase< OtherDerived > &other)
Constructor.
Compact representation of spatial transformations.
SpatialVector & operator=(const Eigen::MatrixBase< OtherDerived > &other)
MotionVector operator+=(const MotionVector &v)
Overloaded += operator for a MotionVector.
MotionVector(const double v0, const double v1, const double v2, const double v3, const double v4, const double v5)
Constructor.
EIGEN_STRONG_INLINE double vz() const
Get a copy of the linear-z component.
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.
EIGEN_STRONG_INLINE double wx() const
Get a copy of the angular-x component.
ForceVector operator%=(const ForceVector &v)
Operator for performing the RBDA operator for a motion vector and a force vector, i.e. .
EIGEN_STRONG_INLINE MotionVector()
Empty constructor.
MotionVector transform_copy(const SpatialTransform &X) const
Copies, transforms, and returns a MotionVector. Performs .
std::vector< MotionVector, Eigen::aligned_allocator< MotionVector > > MotionVectorV
Namespace for all structures of the RobotDynamics library.
Definition: Body.h:21


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