Drake
BasicStateVector< T > Class Template Reference

BasicStateVector is a concrete class template that implements StateVector in a convenient manner for leaf Systems, by owning and wrapping a VectorInterface<T>. More...

#include <drake/systems/framework/basic_state_vector.h>

Inheritance diagram for BasicStateVector< T >:
Collaboration diagram for BasicStateVector< T >:

Public Member Functions

 BasicStateVector (int size)
 Constructs a BasicStateVector that owns a generic BasicVector of the specified size. More...
 
 BasicStateVector (std::unique_ptr< VectorInterface< T >> vector)
 Constructs a BasicStateVector that owns an arbitrary vector, which must not be nullptr. More...
 
int size () const override
 Returns the number of elements in the vector. More...
 
const T GetAtIndex (int index) const override
 Returns the element at the given index in the vector. More...
 
void SetAtIndex (int index, const T &value) override
 Replaces the state at the given index with the value. More...
 
void SetFromVector (const Eigen::Ref< const VectorX< T >> &value) override
 Replaces the entire state with the contents of value. More...
 
VectorX< T > CopyToVector () const override
 Copies the entire state to a vector with no semantics. More...
 
void ScaleAndAddToVector (const T &scale, Eigen::Ref< VectorX< T >> vec) const override
 Adds a scaled version of this state vector to Eigen vector vec, which must be the same size. More...
 
BasicStateVectorPlusEqScaled (const T &scale, const StateVector< T > &rhs) override
 Add in scaled state vector rhs to this state vector. More...
 
- Public Member Functions inherited from LeafStateVector< T >
std::unique_ptr< LeafStateVector< T > > Clone () const
 Copies the entire state to a new LeafStateVector. More...
 
- Public Member Functions inherited from StateVector< T >
virtual ~StateVector ()
 
StateVectoroperator+= (const StateVector< T > &rhs)
 Add in state vector rhs to this state vector. More...
 
StateVectoroperator-= (const StateVector< T > &rhs)
 Subtract in state vector rhs to this state vector. More...
 

Protected Member Functions

 BasicStateVector (const BasicStateVector &other)
 
- Protected Member Functions inherited from LeafStateVector< T >
 LeafStateVector ()
 
- Protected Member Functions inherited from StateVector< T >
 StateVector ()
 

Detailed Description

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

BasicStateVector is a concrete class template that implements StateVector in a convenient manner for leaf Systems, by owning and wrapping a VectorInterface<T>.

It will often be convenient to inherit from BasicStateVector, and add additional semantics specific to the leaf System. Such child classes must override DoClone with an implementation that returns their concrete type.

Template Parameters
TA mathematical type compatible with Eigen's Scalar.

Constructor & Destructor Documentation

BasicStateVector ( int  size)
inlineexplicit

Constructs a BasicStateVector that owns a generic BasicVector of the specified size.

Here is the caller graph for this function:

BasicStateVector ( std::unique_ptr< VectorInterface< T >>  vector)
inlineexplicit

Constructs a BasicStateVector that owns an arbitrary vector, which must not be nullptr.

BasicStateVector ( const BasicStateVector< T > &  other)
inlineprotected

Here is the call graph for this function:

Member Function Documentation

VectorX<T> CopyToVector ( ) const
inlineoverridevirtual

Copies the entire state to a vector with no semantics.

Implementations should ensure this operation is O(N) in the size of the value and allocates only the O(N) memory that it returns.

Implements StateVector< T >.

const T GetAtIndex ( int  index) const
inlineoverridevirtual

Returns the element at the given index in the vector.

Throws std::out_of_range if the index is >= size().

Implementations should ensure this operation is O(1) and allocates no memory.

Implements StateVector< T >.

Here is the call graph for this function:

Here is the caller graph for this function:

BasicStateVector& PlusEqScaled ( const T &  scale,
const StateVector< T > &  rhs 
)
inlineoverridevirtual

Add in scaled state vector rhs to this state vector.

Both vectors must be the same size.

Implementations may override this default implementation with a more efficient approach, for instance if this vector is contiguous. Implementations should ensure this operation remains O(N) in the size of the value and allocates no memory.

Reimplemented from StateVector< T >.

Here is the call graph for this function:

void ScaleAndAddToVector ( const T &  scale,
Eigen::Ref< VectorX< T >>  vec 
) const
inlineoverridevirtual

Adds a scaled version of this state vector to Eigen vector vec, which must be the same size.

Implementations may override this default implementation with a more efficient approach, for instance if this vector is contiguous. Implementations should ensure this operation remains O(N) in the size of the value and allocates no memory.

Reimplemented from StateVector< T >.

Here is the call graph for this function:

void SetAtIndex ( int  index,
const T &  value 
)
inlineoverridevirtual

Replaces the state at the given index with the value.

Throws std::out_of_range if the index is >= size().

Implementations should ensure this operation is O(1) and allocates no memory.

Implements StateVector< T >.

Here is the call graph for this function:

void SetFromVector ( const Eigen::Ref< const VectorX< T >> &  value)
inlineoverridevirtual

Replaces the entire state with the contents of value.

Throws std::out_of_range if value is not a column vector with size() rows.

Implementations should ensure this operation is O(N) in the size of the value and allocates no memory.

Implements StateVector< T >.

Here is the caller graph for this function:

int size ( ) const
inlineoverridevirtual

Returns the number of elements in the vector.

Implementations should ensure this operation is O(1) and allocates no memory.

Implements StateVector< T >.

Here is the caller graph for this function:


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