Drake
Sample< T > Class Template Referencefinal

Specializes BasicVector with specific getters and setters. More...

#include <drake/tools/vector_gen/test/goal/sample.h>

Public Types

typedef SampleIndices K
 An abbreviation for our row index constants. More...
 

Public Member Functions

 Sample ()
 Default constructor. More...
 
template<typename U = T>
std::enable_if< std::is_same< U, symbolic::Expression >::value >::type SetToNamedVariables ()
 Create a symbolic::Variable for each element with the known variable name. More...
 
Sample< T > * DoClone () const final
 Returns a new BasicVector containing a copy of the entire vector. More...
 
drake::boolean< TIsValid () const
 Returns whether the current values of this vector are well-formed. More...
 
void CalcInequalityConstraint (drake::VectorX< T > *value) const final
 Populates a vector value suitable for a SystemConstraint inequality constraint. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible,

MoveAssignable

 Sample (const Sample &other)
 
 Sample (Sample &&other) noexcept
 
Sampleoperator= (const Sample &other)
 
Sampleoperator= (Sample &&other) noexcept
 
Getters and Setters
const Tx () const
 Some coordinate. More...
 
void set_x (const T &x)
 Setter that matches x(). More...
 
DRAKE_VECTOR_GEN_NODISCARD Sample< Twith_x (const T &x) const
 Fluent setter that matches x(). More...
 
const Ttwo_word () const
 A very long documentation string that will certainly flow across multiple lines of C++. More...
 
void set_two_word (const T &two_word)
 Setter that matches two_word(). More...
 
DRAKE_VECTOR_GEN_NODISCARD Sample< Twith_two_word (const T &two_word) const
 Fluent setter that matches two_word(). More...
 
const Tabsone () const
 A signed, normalized value. More...
 
void set_absone (const T &absone)
 Setter that matches absone(). More...
 
DRAKE_VECTOR_GEN_NODISCARD Sample< Twith_absone (const T &absone) const
 Fluent setter that matches absone(). More...
 
const Tunset () const
 A value that is unset by default. More...
 
void set_unset (const T &unset)
 Setter that matches unset(). More...
 
DRAKE_VECTOR_GEN_NODISCARD Sample< Twith_unset (const T &unset) const
 Fluent setter that matches unset(). More...
 
- 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 > data)
 Constructs a BasicVector with the specified data. More...
 
 BasicVector (const std::initializer_list< T > &data)
 Constructs a BasicVector whose elements are the elements of 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 TGetAtIndex (int index) const override
 Returns the element at the given index in the vector. More...
 
TGetAtIndex (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< TCopyToVector () 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
 
T 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...
 
 BasicVector (const BasicVector &)=delete
 
BasicVectoroperator= (const BasicVector &)=delete
 
 BasicVector (BasicVector &&)=delete
 
BasicVectoroperator= (BasicVector &&)=delete
 
- Public Member Functions inherited from VectorBase< T >
virtual ~VectorBase ()
 
Toperator[] (std::size_t idx)
 
const Toperator[] (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...
 
 VectorBase (const VectorBase &)=delete
 
VectorBaseoperator= (const VectorBase &)=delete
 
 VectorBase (VectorBase &&)=delete
 
VectorBaseoperator= (VectorBase &&)=delete
 

Static Public Member Functions

static const std::vector< std::string > & GetCoordinateNames ()
 See SampleIndices::GetCoordinateNames(). More...
 
- Static Public Member Functions inherited from BasicVector< T >
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...
 

Additional Inherited Members

- Protected Member Functions inherited from BasicVector< T >
const VectorX< T > & values () const
 Provides const access to the element storage. More...
 
VectorX< T > & values ()
 Provides mutable access to the element storage. More...
 
- Protected Member Functions inherited from VectorBase< T >
 VectorBase ()
 
- 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...
 

Detailed Description

template<typename T>
class drake::tools::test::Sample< T >

Specializes BasicVector with specific getters and setters.

Member Typedef Documentation

◆ K

typedef SampleIndices K

An abbreviation for our row index constants.

Constructor & Destructor Documentation

◆ Sample() [1/3]

Sample ( )
inline

Default constructor.

Sets all rows to their default value:

  • x defaults to 42.0 m/s.
  • two_word defaults to 0.0 with unknown units.
  • absone defaults to 0.0 with unknown units.
  • unset defaults to a dummy value with unknown units.

◆ Sample() [2/3]

Sample ( const Sample< T > &  other)
inline

◆ Sample() [3/3]

Sample ( Sample< T > &&  other)
inlinenoexcept

Member Function Documentation

◆ absone()

const T& absone ( ) const
inline

A signed, normalized value.

Note
absone has a limited domain of [-1.0, 1.0].

◆ CalcInequalityConstraint()

void CalcInequalityConstraint ( drake::VectorX< T > *  value) const
inlinefinalvirtual

Populates a vector value suitable for a SystemConstraint inequality constraint.

For all indices i in the result vector, the validity constraint is result[i] >= 0. For a given subclass type, the size of the result must not vary over time. The VectorBase default implementation sets the value to be empty (no constraints).

Reimplemented from VectorBase< T >.

◆ DoClone()

Sample<T>* DoClone ( ) const
inlinefinalvirtual

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 from BasicVector< T >.

◆ GetCoordinateNames()

static const std::vector<std::string>& GetCoordinateNames ( )
inlinestatic

◆ IsValid()

drake::boolean<T> IsValid ( ) const
inline

Returns whether the current values of this vector are well-formed.

◆ operator=() [1/2]

Sample& operator= ( const Sample< T > &  other)
inline

◆ operator=() [2/2]

Sample& operator= ( Sample< T > &&  other)
inlinenoexcept

◆ set_absone()

void set_absone ( const T absone)
inline

Setter that matches absone().

◆ set_two_word()

void set_two_word ( const T two_word)
inline

Setter that matches two_word().

◆ set_unset()

void set_unset ( const T unset)
inline

Setter that matches unset().

◆ set_x()

void set_x ( const T x)
inline

Setter that matches x().

◆ SetToNamedVariables()

std::enable_if<std::is_same<U, symbolic::Expression>::value>::type SetToNamedVariables ( )
inline

Create a symbolic::Variable for each element with the known variable name.

This is only available for T == symbolic::Expression.

◆ two_word()

const T& two_word ( ) const
inline

A very long documentation string that will certainly flow across multiple lines of C++.

◆ unset()

const T& unset ( ) const
inline

A value that is unset by default.

◆ with_absone()

DRAKE_VECTOR_GEN_NODISCARD Sample<T> with_absone ( const T absone) const
inline

Fluent setter that matches absone().

Returns a copy of this with absone set to a new value.

◆ with_two_word()

DRAKE_VECTOR_GEN_NODISCARD Sample<T> with_two_word ( const T two_word) const
inline

Fluent setter that matches two_word().

Returns a copy of this with two_word set to a new value.

◆ with_unset()

DRAKE_VECTOR_GEN_NODISCARD Sample<T> with_unset ( const T unset) const
inline

Fluent setter that matches unset().

Returns a copy of this with unset set to a new value.

◆ with_x()

DRAKE_VECTOR_GEN_NODISCARD Sample<T> with_x ( const T x) const
inline

Fluent setter that matches x().

Returns a copy of this with x set to a new value.

◆ x()

const T& x ( ) const
inline

Some coordinate.

Note
x is expressed in units of m/s.
x has a limited domain of [0.0, +Inf].

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