Drake
SpatialVector< SV, T > Class Template Reference

This class is used to represent physical quantities that correspond to spatial vectors such as spatial velocities, spatial accelerations and spatial forces. More...

#include <multibody/multibody_tree/math/spatial_vector.h>

## Public Types

enum  { kSpatialVectorSize = 6, kRotationSize = 3, kTranslationSize = 3 }
Sizes for spatial quantities and its components in three dimensions. More...

using SpatialQuantity = SV< T >
The more specialized spatial vector class templated on the scalar type T. More...

typedef Vector6< T > CoeffsEigenType
The type of the underlying in-memory representation using an Eigen vector. More...

typedef T ScalarType

## Public Member Functions

SpatialVector ()
Default constructor. More...

SpatialVector (const Eigen::Ref< const Vector3< T >> &w, const Eigen::Ref< const Vector3< T >> &v)
SpatialVector constructor from an rotational component w and a linear component v. More...

template<typename OtherDerived >
SpatialVector (const Eigen::MatrixBase< OtherDerived > &V)
SpatialVector constructor from an Eigen expression that represents a six-dimensional vector. More...

int size () const
The total size of the concatenation of the angular and linear components. More...

const T & operator[] (int i) const

T & operator[] (int i)

const Vector3< T > & rotational () const

Vector3< T > & rotational ()

const Vector3< T > & translational () const

Vector3< T > & translational ()

const T * data () const
Returns a (const) bare pointer to the underlying data. More...

T * mutable_data ()
Returns a (mutable) bare pointer to the underlying data. More...

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). More...

bool IsNearlyEqualWithinAbsoluteTolerance (const SpatialQuantity &other, const T &rotational_tolerance, const T &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. More...

bool IsApprox (const SpatialQuantity &other, double tolerance=Eigen::NumTraits< T >::epsilon()) const
Compares this spatial vector to the provided spatial vector other within a specified precision. More...

void SetNaN ()
Sets all entries in this SpatialVector to NaN. More...

SpatialQuantitySetZero ()
Sets both rotational and translational components of this SpatialVector to zero. More...

CoeffsEigenTypeget_coeffs ()
Returns a reference to the underlying storage. More...

const CoeffsEigenTypeget_coeffs () const
Returns a constant reference to the underlying storage. More...

SpatialQuantity operator- () const
Unary minus operator. More...

Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
SpatialVector (const SpatialVector &)=default

SpatialVectoroperator= (const SpatialVector &)=default

SpatialVector (SpatialVector &&)=default

SpatialVectoroperator= (SpatialVector &&)=default

## Static Public Member Functions

static SpatialQuantity Zero ()
Factory to create a zero SpatialVector, i.e. More...

## Friends

SpatialQuantity operator* (const Matrix3< T > &R_FE, const SpatialQuantity &V_E)
This operation re-expresses the spatial vector V_E originally expressed in frame E, into V_F, the same spatial vector expresed in another frame F. More...

## Related Functions

(Note that these are not member functions.)

SpatialQuantity operator* (const T &s, const SpatialQuantity &V)
Multiplication of a spatial vector V from the left by a scalar s. More...

SpatialQuantity operator* (const SpatialQuantity &V, const T &s)
Multiplication of a spatial vector V from the right by a scalar s. More...

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. More...

## Detailed Description

### template<template< typename > class SV, typename T> class drake::multibody::SpatialVector< SV, T >

This class is used to represent physical quantities that correspond to spatial vectors such as spatial velocities, spatial accelerations and spatial forces.

Spatial vectors are 6-element quantities that are pairs of ordinary 3-vectors. Elements 0-2 are always the rotational component while elements 3-5 are always the translational component. For a more detailed introduction on spatial vectors please refer to section Spatial Vectors.

Template Parameters
 SV The type of the more specialized spatial vector class. It must be a template on the scalar type T. T The underlying scalar type. Must be a valid Eigen scalar.

## Member Typedef Documentation

 typedef Vector6 CoeffsEigenType

The type of the underlying in-memory representation using an Eigen vector.

 typedef T ScalarType
 using SpatialQuantity = SV

The more specialized spatial vector class templated on the scalar type T.

## Member Enumeration Documentation

 anonymous enum

Sizes for spatial quantities and its components in three dimensions.

Enumerator
kSpatialVectorSize
kRotationSize
kTranslationSize

## Constructor & Destructor Documentation

 SpatialVector ( const SpatialVector< SV, T > & )
default
 SpatialVector ( SpatialVector< SV, T > && )
default
 SpatialVector ( )
inline

Default constructor.

In Release builds the elements of the newly constructed spatial vector are left uninitialized resulting in a zero cost operation. However in Debug builds those entries are set to NaN so that operations using this uninitialized spatial vector fail fast, allowing fast bug detection.

 SpatialVector ( const Eigen::Ref< const Vector3< T >> & w, const Eigen::Ref< const Vector3< T >> & v )
inline

SpatialVector constructor from an rotational component w and a linear component v.

 SpatialVector ( const Eigen::MatrixBase< OtherDerived > & V )
inlineexplicit

SpatialVector constructor from an Eigen expression that represents a six-dimensional vector.

This constructor will assert the size of V is six (6) at compile-time for fixed sized Eigen expressions and at run-time for dynamic sized Eigen expressions.

## Member Function Documentation

 const T* data ( ) const
inline

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 ( )
inline

Returns a reference to the underlying storage.

Here is the caller graph for this function:

 const CoeffsEigenType& get_coeffs ( ) const
inline

Returns a constant reference to the underlying storage.

 std::tuple GetMaximumAbsoluteDifferences ( const SpatialQuantity & other ) const
inline

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).

These quantities are returned in a tuple, in the order below.

std::tuple Description
w_max_difference Maximum absolute difference in rotation components
v_max_difference Maximum absolute difference in translation components

Here is the caller graph for this function:

 bool IsApprox ( const SpatialQuantity & other, double tolerance = Eigen::NumTraits::epsilon() ) const
inline

Compares this spatial vector to the provided spatial vector other within a specified precision.

Returns
true if other is within a precision given by tolerance. The comparison is performed by comparing the translational component of this spatial vector with the rotational component of other using the fuzzy comparison provided by Eigen's method isApprox().
 bool IsNearlyEqualWithinAbsoluteTolerance ( const SpatialQuantity & other, const T & rotational_tolerance, const T & translational_tolerance ) const
inline

Compares the rotational and translational parts of this and other to check if they are the same to within specified absolute differences.

Parameters
 [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.
Returns
true if the rotational part of this and other are equal within rotational_tolerance and the translational part of this and other are equal within translational_tolerance.
 T* mutable_data ( )
inline

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
inline

Unary minus operator.

 SpatialVector& operator= ( const SpatialVector< SV, T > & )
default
 SpatialVector& operator= ( SpatialVector< SV, T > && )
default
 const T& operator[] ( int i ) const
inline

Bounds are only checked in Debug builds for a zero overhead implementation in Release builds.

 T& operator[] ( int i )
inline

Bounds are only checked in Debug builds for a zero overhead implementation in Release builds.

 const Vector3& rotational ( ) const
inline

Here is the caller graph for this function:

 Vector3& rotational ( )
inline

 void SetNaN ( )
inline

Sets all entries in this SpatialVector to NaN.

Typically used to quickly detect uninitialized values since NaN will trigger a chain of invalid computations that can then be tracked back to the source.

Here is the caller graph for this function:

 SpatialQuantity& SetZero ( )
inline

Sets both rotational and translational components of this SpatialVector to zero.

 int size ( ) const
inline

The total size of the concatenation of the angular and linear components.

In three dimensions this is six (6) and it is known at compile time.

 const Vector3& translational ( ) const
inline

Here is the caller graph for this function:

 Vector3& translational ( )
inline

 static SpatialQuantity Zero ( )
inlinestatic

Factory to create a zero SpatialVector, i.e.

rotational and translational components are both zero.

## Friends And Related Function Documentation

 SpatialQuantity operator* ( const T & s, const SpatialQuantity & V )
friend

Multiplication of a spatial vector V from the left by a scalar s.

 SpatialQuantity operator* ( const SpatialQuantity & V, const T & s )
friend

Multiplication of a spatial vector V from the right by a scalar s.

 SpatialQuantity operator* ( const Matrix3< T > & R_FE, const SpatialQuantity & V_E )
friend

This operation re-expresses the spatial vector V_E originally expressed in frame E, into V_F, the same spatial vector expresed in another frame F.

The transformation requires the rotation matrix R_FE representing the orientation of the original frame E with respect to frame F. The operation performed is:

  V_F.rotational()    = R_FE * V_E.rotational(),
V_F.translational() = R_FE * V_E.translational()

Returns
V_F The same spatial vector re-expressed in frame F.
 std::ostream & operator<< ( std::ostream & o, const SpatialVector< SpatialQuantity, T > & V )
related

Stream insertion operator to write SpatialVector objects into a std::ostream.

Especially useful for debugging.

The documentation for this class was generated from the following file: