Drake
Drake C++ Documentation
SpringMassStateVector< T > Class Template Reference

Detailed Description

template<typename T>
class drake::systems::SpringMassStateVector< T >

The state of a one-dimensional spring-mass system, consisting of the position and velocity of the mass, in meters and meters/s.

Template Parameters
TThe scalar type, which must be one of the default scalars.

#include <drake/systems/analysis/test_utilities/spring_mass_system.h>

Public Member Functions

 SpringMassStateVector (const T &initial_position, const T &initial_velocity)
 
 SpringMassStateVector ()
 Creates a state with position and velocity set to zero. More...
 
 ~SpringMassStateVector () override
 
get_position () const
 Returns the position of the mass in meters, where zero is the point where the spring exerts no force. More...
 
void set_position (const T &q)
 Sets the position of the mass in meters. More...
 
get_velocity () const
 Returns the velocity of the mass in meters per second. More...
 
void set_velocity (const T &v)
 Sets the velocity of the mass in meters per second. More...
 
get_conservative_work () const
 Returns the integral of conservative power, in watts. More...
 
void set_conservative_work (const T &e)
 Initialize the conservative work integral to a given value. More...
 
Does not allow copy, move, or assignment
 SpringMassStateVector (const SpringMassStateVector &)=delete
 
SpringMassStateVectoroperator= (const SpringMassStateVector &)=delete
 
 SpringMassStateVector (SpringMassStateVector &&)=delete
 
SpringMassStateVectoroperator= (SpringMassStateVector &&)=delete
 
- Public Member Functions inherited from BasicVector< T >
 BasicVector ()=default
 Constructs an empty BasicVector. More...
 
 BasicVector (int size)
 Initializes with the given size using the drake::dummy_value<T>, which is NaN when T = double. More...
 
 BasicVector (VectorX< T > vec)
 Constructs a BasicVector with the specified vec data. More...
 
 BasicVector (const std::initializer_list< T > &init)
 Constructs a BasicVector whose elements are the elements of init. More...
 
int size () const final
 Returns the number of elements in the vector. More...
 
void set_value (const Eigen::Ref< const VectorX< T >> &value)
 Sets the vector to the given value. More...
 
const VectorX< T > & value () const
 Returns a const reference to the contained VectorX<T>. More...
 
Eigen::VectorBlock< VectorX< T > > get_mutable_value ()
 Returns the entire vector as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resize() to be invoked on the returned object. More...
 
void SetFromVector (const Eigen::Ref< const VectorX< T >> &value) final
 Replaces the entire vector with the contents of value. More...
 
VectorX< T > CopyToVector () const final
 Copies this entire VectorBase into a contiguous Eigen Vector. More...
 
void ScaleAndAddToVector (const T &scale, EigenPtr< VectorX< T >> vec) const final
 Adds a scaled version of this vector to Eigen vector vec. More...
 
void SetZero () final
 Sets all elements of this vector to zero. More...
 
std::unique_ptr< BasicVector< T > > Clone () const
 Copies the entire vector to a new BasicVector, with the same concrete implementation type. More...
 
Eigen::VectorBlock< const VectorX< T > > get_value () const
 (Don't use this in new code) Returns the entire vector as a const Eigen::VectorBlock. More...
 
 BasicVector (const BasicVector &)=delete
 
BasicVectoroperator= (const BasicVector &)=delete
 
 BasicVector (BasicVector &&)=delete
 
BasicVectoroperator= (BasicVector &&)=delete
 
- Public Member Functions inherited from VectorBase< T >
virtual ~VectorBase ()
 
T & operator[] (int index)
 Returns the element at the given index in the vector. More...
 
const T & operator[] (int index) const
 Returns the element at the given index in the vector. More...
 
const T & GetAtIndex (int index) const
 Returns the element at the given index in the vector. More...
 
T & GetAtIndex (int index)
 Returns the element at the given index in the vector. More...
 
void SetAtIndex (int index, const T &value)
 Replaces the state at the given index with the value. More...
 
virtual void SetFrom (const VectorBase< T > &value)
 Replaces the entire vector with the contents of value. More...
 
virtual void CopyToPreSizedVector (EigenPtr< VectorX< T >> vec) const
 Copies this entire VectorBase into a pre-sized Eigen Vector. More...
 
VectorBasePlusEqScaled (const T &scale, const VectorBase< T > &rhs)
 Add in scaled vector rhs to this vector. More...
 
VectorBasePlusEqScaled (const std::initializer_list< std::pair< T, const VectorBase< T > & >> &rhs_scale)
 Add in multiple scaled vectors to this vector. More...
 
VectorBaseoperator+= (const VectorBase< T > &rhs)
 Add in vector rhs to this vector. More...
 
VectorBaseoperator-= (const VectorBase< T > &rhs)
 Subtract in vector rhs to this vector. More...
 
virtual void GetElementBounds (Eigen::VectorXd *lower, Eigen::VectorXd *upper) const
 Get the bounds for the elements. More...
 
 VectorBase (const VectorBase &)=delete
 
VectorBaseoperator= (const VectorBase &)=delete
 
 VectorBase (VectorBase &&)=delete
 
VectorBaseoperator= (VectorBase &&)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from BasicVector< T >
static std::unique_ptr< BasicVector< T > > Make (const std::initializer_list< T > &init)
 Constructs a BasicVector whose elements are the elements of init. More...
 
template<typename... Fargs>
static std::unique_ptr< BasicVector< T > > Make (Fargs &&... args)
 Constructs a BasicVector where each element is constructed using the placewise-corresponding member of args as the sole constructor argument. More...
 
- Protected Member Functions inherited from BasicVector< T >
const T & DoGetAtIndexUnchecked (int index) const final
 Implementations should ensure this operation is O(1) and allocates no memory. More...
 
T & DoGetAtIndexUnchecked (int index) final
 Implementations should ensure this operation is O(1) and allocates no memory. More...
 
const T & DoGetAtIndexChecked (int index) const final
 Implementations should ensure this operation is O(1) and allocates no memory. More...
 
T & DoGetAtIndexChecked (int index) final
 Implementations should ensure this operation is O(1) and allocates no memory. More...
 
const VectorX< T > & values () const
 Provides const access to the element storage. More...
 
VectorX< T > & values ()
 (Advanced) Provides mutable access to the element storage. More...
 
- Protected Member Functions inherited from VectorBase< T >
 VectorBase ()
 
void ThrowOutOfRange (int index) const
 
void ThrowMismatchedSize (int other_size) const
 
- Static Protected Member Functions inherited from BasicVector< T >
template<typename F , typename... Fargs>
static void MakeRecursive (BasicVector< T > *data, int index, F constructor_arg, Fargs &&... recursive_args)
 Sets data at index to an object of type T, which must have a single-argument constructor invoked via constructor_arg, and then recursively invokes itself on the next index with recursive args. More...
 
template<typename F , typename... Fargs>
static void MakeRecursive (BasicVector< T > *data, int index, F constructor_arg)
 Base case for the MakeRecursive template recursion. More...
 

Constructor & Destructor Documentation

◆ SpringMassStateVector() [1/4]

SpringMassStateVector ( const SpringMassStateVector< T > &  )
delete

◆ SpringMassStateVector() [2/4]

◆ SpringMassStateVector() [3/4]

SpringMassStateVector ( const T &  initial_position,
const T &  initial_velocity 
)
Parameters
initial_positionThe position of the mass in meters.
initial_velocityThe velocity of the mass in meters / second.

◆ SpringMassStateVector() [4/4]

Creates a state with position and velocity set to zero.

◆ ~SpringMassStateVector()

~SpringMassStateVector ( )
override

Member Function Documentation

◆ get_conservative_work()

T get_conservative_work ( ) const

Returns the integral of conservative power, in watts.

◆ get_position()

T get_position ( ) const

Returns the position of the mass in meters, where zero is the point where the spring exerts no force.

◆ get_velocity()

T get_velocity ( ) const

Returns the velocity of the mass in meters per second.

◆ operator=() [1/2]

SpringMassStateVector& operator= ( SpringMassStateVector< T > &&  )
delete

◆ operator=() [2/2]

SpringMassStateVector& operator= ( const SpringMassStateVector< T > &  )
delete

◆ set_conservative_work()

void set_conservative_work ( const T &  e)

Initialize the conservative work integral to a given value.

◆ set_position()

void set_position ( const T &  q)

Sets the position of the mass in meters.

◆ set_velocity()

void set_velocity ( const T &  v)

Sets the velocity of the mass in meters per second.


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