This class represents a spatial vector and has 6 elements, with a 3-element rotational vector on top of a 3-element translational vector.
Important subclasses of SpatialVector include SpatialVelocity, SpatialAcceleration, SpatialForce, and SpatialMomentum. Each of the 3-element vectors is assumed to be expressed in the same expressed-in frame E. This class only stores 6 elements and does not store the underlying expressed-in frame E or other information. The user is responsible for explicitly tracking the underlying frames with monogram notation. For example, Foo_E denotes an arbitrary spatial vector Foo expressed in a frame E. Details on spatial vectors and monogram notation are in sections Spatial Vectors and monogram notation.
| SV | The type of the more specialized spatial vector class. It must be a template on the scalar type T. |
| T | The scalar type, which must be one of the default scalars. |
#include <drake/multibody/math/spatial_vector.h>
Public Types | |
| enum | { kSpatialVectorSize = 6 , kRotationSize = 3 , kTranslationSize = 3 } |
| Sizes for spatial quantities and its components in 3D (three dimensions). More... | |
| using | SpatialQuantity = SV<T> |
| The more specialized spatial vector class templated on the scalar type T. | |
| using | CoeffsEigenType = Vector6<T> |
| The type of the underlying in-memory representation using an Eigen vector. | |
Public Member Functions | |
| SpatialVector () | |
| Default constructor. | |
| SpatialVector (const Eigen::Ref< const Vector3< T > > &w, const Eigen::Ref< const Vector3< T > > &v) | |
| Constructs a spatial vector from a rotational component w and a translational component v. | |
| template<typename OtherDerived> | |
| SpatialVector (const Eigen::MatrixBase< OtherDerived > &V) | |
| Constructs a spatial vector V from an Eigen expression that represents a 6-element vector (3-element rotational vector on top of a 3-element translational vector). | |
| int | size () const |
| For 3D (three-dimensional) analysis, the total size of the concatenated rotational vector (3 elements) and translational vector (3 elements) is six (6), which is known at compile time. | |
| const T & | operator[] (int i) const |
| Const access to the i-th element of this spatial vector. | |
| T & | operator[] (int i) |
| Mutable access to the i-th element of this spatial vector. | |
| const Vector3< T > & | rotational () const |
| Const access to the rotational component of this spatial vector. | |
| Vector3< T > & | rotational () |
| Mutable access to the rotational component of this spatial vector. | |
| const Vector3< T > & | translational () const |
| Const access to the translational component of this spatial vector. | |
| Vector3< T > & | translational () |
| Mutable access to the translational component of this spatial vector. | |
| const T * | data () const |
| Returns a (const) bare pointer to the underlying data. | |
| T * | mutable_data () |
| Returns a (mutable) bare pointer to the underlying data. | |
| std::tuple< const T, const T > | GetMaximumAbsoluteDifferences (const SpatialQuantity &other) const |
| Returns the maximum absolute values of the differences in the rotational and translational components of this and other (i.e., the infinity norms of the difference in rotational and translational components). | |
| decltype(T()< T()) | IsNearlyEqualWithinAbsoluteTolerance (const SpatialQuantity &other, double rotational_tolerance, double translational_tolerance) const |
| Compares the rotational and translational parts of this and other to check if they are the same to within specified absolute differences. | |
| decltype(T()< T()) | IsApprox (const SpatialQuantity &other, double tolerance=2 *std::numeric_limits< double >::epsilon()) const |
| Determines whether all six corresponding elements of two spatial vectors are equal to each other to within a specified tolerance epsilon. | |
| void | SetNaN () |
| Sets all the elements in this SpatialVector to NaN. | |
| SpatialQuantity & | SetZero () |
| Sets both the rotational and translational components of this SpatialVector to zero. | |
| CoeffsEigenType & | get_coeffs () |
| Returns a mutable reference to the underlying storage. | |
| const CoeffsEigenType & | get_coeffs () const |
| Returns a constant reference to the underlying storage. | |
| SpatialQuantity | operator- () const |
| Unary minus operator. | |
| SpatialQuantity & | operator+= (const SpatialQuantity &V) |
| Addition assignment operator. | |
| SpatialQuantity & | operator-= (const SpatialQuantity &V) |
| Subtraction assignment operator. | |
| SpatialQuantity & | operator*= (const T &s) |
| Multiplication assignment operator. | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
| SpatialVector (const SpatialVector &)=default | |
| SpatialVector & | operator= (const SpatialVector &)=default |
| SpatialVector (SpatialVector &&)=default | |
| SpatialVector & | operator= (SpatialVector &&)=default |
Static Public Member Functions | |
| static SpatialQuantity | Zero () |
| Factory to create a zero spatial vector, i.e., a SpatialVector whose rotational and translational components are both zero. | |
Friends | |
| SpatialQuantity | operator+ (const SpatialQuantity &V1_E, const SpatialQuantity &V2_E) |
| Adds two spatial vectors by simply adding their 6 underlying elements. | |
| SpatialQuantity | operator- (const SpatialQuantity &V1, const SpatialQuantity &V2) |
| Subtracts two spatial vectors by simply subtracting their 6 underlying elements. | |
| SpatialQuantity | operator* (const math::RotationMatrix< T > &R_FE, const SpatialQuantity &V_E) |
| Expresses a spatial vector in another frame. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| SpatialQuantity | operator* (const T &s, const SpatialQuantity &V) |
| Multiplication of a spatial vector V from the left by a scalar s. | |
| SpatialQuantity | operator* (const SpatialQuantity &V, const T &s) |
| Multiplication of a spatial vector V from the right by a scalar s. | |
| template<template< typename > class SpatialQuantity, typename T> | |
| std::ostream & | operator<< (std::ostream &o, const SpatialVector< SpatialQuantity, T > &V) |
| Stream insertion operator to write SpatialVector objects into a std::ostream. | |
| using CoeffsEigenType = Vector6<T> |
The type of the underlying in-memory representation using an Eigen vector.
| using SpatialQuantity = SV<T> |
The more specialized spatial vector class templated on the scalar type T.
| anonymous enum |
|
default |
|
default |
| SpatialVector | ( | ) |
Default constructor.
In Release builds, all 6 elements of a newly constructed spatial vector are uninitialized (for speed). In Debug builds, the 6 elements are set to NaN so that invalid operations on an uninitialized spatial vector fail fast (fast bug detection).
| SpatialVector | ( | const Eigen::Ref< const Vector3< T > > & | w, |
| const Eigen::Ref< const Vector3< T > > & | v ) |
Constructs a spatial vector from a rotational component w and a translational component v.
|
explicit |
Constructs a spatial vector V from an Eigen expression that represents a 6-element vector (3-element rotational vector on top of a 3-element translational vector).
This constructor asserts the size of V is six (6) either at compile-time for fixed sized Eigen expressions or at run-time for dynamic sized Eigen expressions.
| const T * data | ( | ) | const |
Returns a (const) bare pointer to the underlying data.
It is guaranteed that there will be six (6) T's densely packed at data[0], data[1], etc.
| CoeffsEigenType & get_coeffs | ( | ) |
Returns a mutable reference to the underlying storage.
| const CoeffsEigenType & get_coeffs | ( | ) | const |
Returns a constant reference to the underlying storage.
| std::tuple< const T, const T > GetMaximumAbsoluteDifferences | ( | const SpatialQuantity & | other | ) | const |
Returns the maximum absolute values of the differences in the rotational and translational components of this and other (i.e., the infinity norms of the difference in rotational and translational components).
| [in] | other | spatial vector to subtract from this spatial vector. |
| std::tuple | Description |
|---|---|
| w_max_difference | Maximum absolute difference in rotation components |
| v_max_difference | Maximum absolute difference in translation components |
| decltype(T()< T()) IsApprox | ( | const SpatialQuantity & | other, |
| double | tolerance = 2 * std::numeric_limits<double>::epsilon() ) const |
Determines whether all six corresponding elements of two spatial vectors are equal to each other to within a specified tolerance epsilon.
| [in] | other | spatial vector to compare to this spatial vector. |
| [in] | tolerance | specified tolerance for this test. |
| decltype(T()< T()) IsNearlyEqualWithinAbsoluteTolerance | ( | const SpatialQuantity & | other, |
| double | rotational_tolerance, | ||
| double | translational_tolerance ) const |
Compares the rotational and translational parts of this and other to check if they are the same to within specified absolute differences.
| [in] | other | spatial vector to compare to this spatial vector. |
| [in] | rotational_tolerance | maximum allowable absolute difference between the rotational parts of this and other. The units depend on the underlying class. For example, spatial velocity, acceleration, and force have units of rad/sec, rad/sec^2, and N*m, respectively. |
| [in] | translational_tolerance | maximum allowable absolute difference between the translational parts of this and other. The units depend on the underlying class. For example, spatial velocity, acceleration, and force have units of meter/sec, meter/sec^2, and Newton, respectively. |
| T * mutable_data | ( | ) |
Returns a (mutable) bare pointer to the underlying data.
It is guaranteed that there will be six (6) T's densely packed at data[0], data[1], etc.
| SpatialQuantity & operator*= | ( | const T & | s | ) |
Multiplication assignment operator.
| SpatialQuantity & operator+= | ( | const SpatialQuantity & | V | ) |
Addition assignment operator.
| SpatialQuantity operator- | ( | ) | const |
Unary minus operator.
| SpatialQuantity & operator-= | ( | const SpatialQuantity & | V | ) |
Subtraction assignment operator.
|
default |
|
default |
| T & operator[] | ( | int | i | ) |
Mutable access to the i-th element of this spatial vector.
In Debug builds, this function asserts that i is in bounds whereas for release builds, no bounds-check on i is performed (for speed).
| const T & operator[] | ( | int | i | ) | const |
Const access to the i-th element of this spatial vector.
In Debug builds, this function asserts that i is in bounds whereas for release builds, no bounds-check on i is performed (for speed).
| Vector3< T > & rotational | ( | ) |
Mutable access to the rotational component of this spatial vector.
| const Vector3< T > & rotational | ( | ) | const |
Const access to the rotational component of this spatial vector.
| void SetNaN | ( | ) |
Sets all the elements in this SpatialVector to NaN.
This is typically used to quickly detect uninitialized values since NaN will trigger a chain of invalid computations that can be tracked back to their source.
| SpatialQuantity & SetZero | ( | ) |
Sets both the rotational and translational components of this SpatialVector to zero.
| int size | ( | ) | const |
For 3D (three-dimensional) analysis, the total size of the concatenated rotational vector (3 elements) and translational vector (3 elements) is six (6), which is known at compile time.
| Vector3< T > & translational | ( | ) |
Mutable access to the translational component of this spatial vector.
| const Vector3< T > & translational | ( | ) | const |
Const access to the translational component of this spatial vector.
|
static |
Factory to create a zero spatial vector, i.e., a SpatialVector whose rotational and translational components are both zero.
|
friend |
Expresses a spatial vector in another frame.
| [in] | R_FE | RotationMatrix relating a frame F to a frame E. |
| [in] | V_E | spatial vector expressed in frame E. |
V_F.rotational() = R_FE * V_E.rotational(), V_F.translational() = R_FE * V_E.translational()
|
friend |
Multiplication of a spatial vector V from the right by a scalar s.
|
friend |
Multiplication of a spatial vector V from the left by a scalar s.
|
friend |
Adds two spatial vectors by simply adding their 6 underlying elements.
| [in] | V1_E | spatial vector expressed in the same frame E as V2_E. |
| [in] | V2_E | spatial vector expressed in the same frame E as V1_E. |
|
friend |
Subtracts two spatial vectors by simply subtracting their 6 underlying elements.
| [in] | V1 | spatial vector expressed in the same frame as V2. |
| [in] | V2 | spatial vector expressed in the same frame as V1. |
|
Stream insertion operator to write SpatialVector objects into a std::ostream.
Especially useful for debugging.