Drake
BasicVector< T > Class Template Reference

BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase. More...

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

Inheritance diagram for BasicVector< T >:
[legend]
Collaboration diagram for BasicVector< T >:
[legend]

Public Member Functions

 BasicVector (int size)
 Initializes with the given size using the drake::dummy_value<T>, which is NaN when T = double. More...
 
 BasicVector (const VectorX< T > &data)
 Constructs a BasicVector with the specified data. More...
 
int size () const override
 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...
 
Eigen::VectorBlock< const VectorX< T > > get_value () const
 Returns the entire vector as a const Eigen::VectorBlock. 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 resizing the vector itself. More...
 
const T & GetAtIndex (int index) const override
 Returns the element at the given index in the vector. More...
 
T & GetAtIndex (int index) override
 Returns the element at the given index in the vector. More...
 
void SetFromVector (const Eigen::Ref< const VectorX< T >> &value) override
 Replaces the entire vector 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 vector to Eigen vector vec, which must be the same size. More...
 
void SetZero () override
 
NormInf () const override
 Computes the infinity norm for this vector. More...
 
std::unique_ptr< BasicVector< T > > Clone () const
 Copies the entire vector to a new BasicVector, with the same concrete implementation type. More...
 
Does not allow copy, move, or assignment
 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[] (std::size_t idx)
 
const T & operator[] (std::size_t idx) const
 
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...
 
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 CalcInequalityConstraint (VectorX< T > *value) const
 Populates a vector value suitable for a SystemConstraint inequality constraint. More...
 
 VectorBase (const VectorBase &)=delete
 
VectorBaseoperator= (const VectorBase &)=delete
 
 VectorBase (VectorBase &&)=delete
 
VectorBaseoperator= (VectorBase &&)=delete
 

Static Public Member Functions

static std::unique_ptr< BasicVector< T > > Make (const std::initializer_list< T > &data)
 Constructs a BasicVector whose elements are the elements of data. 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

virtual BasicVector< T > * DoClone () const
 Returns a new BasicVector containing a copy of the entire vector. More...
 
- Protected Member Functions inherited from VectorBase< T >
 VectorBase ()
 

Static Protected Member Functions

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

Detailed Description

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

BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.

Once constructed, its size is fixed.

Template Parameters
TThe vector element type, which must be a valid Eigen scalar.

Constructor & Destructor Documentation

BasicVector ( const BasicVector< T > &  )
delete
BasicVector ( BasicVector< T > &&  )
delete
BasicVector ( int  size)
inlineexplicit

Initializes with the given size using the drake::dummy_value<T>, which is NaN when T = double.

BasicVector ( const VectorX< T > &  data)
inlineexplicit

Constructs a BasicVector with the specified data.

Member Function Documentation

std::unique_ptr<BasicVector<T> > Clone ( ) const
inline

Copies the entire vector to a new BasicVector, with the same concrete implementation type.

Uses the Non-Virtual Interface idiom because smart pointers do not have type covariance.

Here is the caller graph for this function:

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.

Reimplemented from VectorBase< T >.

Here is the caller graph for this function:

virtual BasicVector<T>* DoClone ( ) const
inlineprotectedvirtual

Returns a new BasicVector containing a copy of the entire vector.

Caller must take ownership, and may rely on the NVI wrapper to initialize the clone elementwise.

Subclasses of BasicVector must override DoClone to return their covariant type.

Reimplemented in DepthSensorOutput< T >, IdmPlannerParameters< T >, BicycleCarParameters< T >, SimpleCarParams< T >, BeamModelParams< T >, PendulumParams< T >, MaliputRailcarParams< T >, Sample< T >, MobilPlannerParameters< T >, SchunkWsgTrajectoryGeneratorStateVector< T >, BicycleCarState< T >, DrivingCommand< T >, TrajectoryCarParams< T >, AcrobotStateVector< T >, SimpleCarState< T >, BouncingBallVector< T >, PendulumState< T >, PendulumStateVector< T >, MaliputRailcarState< T >, PurePursuitParams< T >, TrajectoryCarState< T >, PendulumInput< T >, FrameVelocity< T >, PoseVector< T >, PoseVector< double >, GyroscopeOutput< T >, AccelerometerOutput< T >, and MyVector< N, T >.

Here is the caller graph for this function:

Eigen::VectorBlock<VectorX<T> > get_mutable_value ( )
inline

Returns the entire vector as a mutable Eigen::VectorBlock, which allows mutation of the values, but does not allow resizing the vector itself.

Here is the caller graph for this function:

Eigen::VectorBlock<const VectorX<T> > get_value ( ) const
inline

Returns the entire vector as a const Eigen::VectorBlock.

Here is the caller graph for this function:

const T& GetAtIndex ( int  index) const
inlineoverridevirtual

Returns the element at the given index in the vector.

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

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

Implements VectorBase< T >.

Here is the caller graph for this function:

T& GetAtIndex ( int  index)
inlineoverridevirtual

Returns the element at the given index in the vector.

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

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

Implements VectorBase< T >.

static std::unique_ptr<BasicVector<T> > Make ( const std::initializer_list< T > &  data)
inlinestatic

Constructs a BasicVector whose elements are the elements of data.

Here is the caller graph for this function:

static std::unique_ptr<BasicVector<T> > Make ( Fargs &&...  args)
inlinestatic

Constructs a BasicVector where each element is constructed using the placewise-corresponding member of args as the sole constructor argument.

For instance: BasicVector<symbolic::Expression>::Make("x", "y", "z");

static void MakeRecursive ( BasicVector< T > *  data,
int  index,
F  constructor_arg,
Fargs &&...  recursive_args 
)
inlinestaticprotected

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.

Helper for BasicVector<T>::Make.

Here is the caller graph for this function:

static void MakeRecursive ( BasicVector< T > *  data,
int  index,
F  constructor_arg 
)
inlinestaticprotected

Base case for the MakeRecursive template recursion.

T NormInf ( ) const
inlineoverridevirtual

Computes the infinity norm for this vector.

Reimplemented from VectorBase< T >.

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

Adds a scaled version of this 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 VectorBase< T >.

void set_value ( const Eigen::Ref< const VectorX< T >> &  value)
inline

Sets the vector to the given value.

After a.set_value(b.get_value()), a must be identical to b. Throws std::out_of_range if the new value has different dimensions.

Here is the caller graph for this function:

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

Replaces the entire vector with the contents of value.

Throws std::runtime_error 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.

Reimplemented from VectorBase< T >.

Here is the caller graph for this function:

void SetZero ( )
inlineoverridevirtual

Reimplemented from VectorBase< T >.

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 VectorBase< T >.

Here is the caller graph for this function:


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