Specializes BasicVector with specific getters and setters.
#include <drake/examples/rod2d/rod2d_state_vector.h>
Public Types | |
typedef Rod2dStateVectorIndices | K |
An abbreviation for our row index constants. More... | |
Public Member Functions | |
Rod2dStateVector () | |
Default constructor. More... | |
template<typename U = T> | |
std::enable_if_t< std::is_same_v< U, symbolic::Expression > > | SetToNamedVariables () |
Create a symbolic::Variable for each element with the known variable name. More... | |
Rod2dStateVector< T > * | DoClone () const final |
Returns a new BasicVector containing a copy of the entire vector. More... | |
template<typename Archive > | |
void | Serialize (Archive *a) |
Visit each field of this named vector, passing them (in order) to the given Archive. More... | |
drake::boolean< T > | IsValid () const |
Returns whether the current values of this vector are well-formed. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, | |
MoveAssignable | |
Rod2dStateVector (const Rod2dStateVector &other) | |
Rod2dStateVector (Rod2dStateVector &&other) noexcept | |
Rod2dStateVector & | operator= (const Rod2dStateVector &other) |
Rod2dStateVector & | operator= (Rod2dStateVector &&other) noexcept |
Getters and Setters | |
const T & | x () const |
Horizontal location of the center-of-mass. More... | |
void | set_x (const T &x) |
Setter that matches x(). More... | |
Rod2dStateVector< T > | with_x (const T &x) const |
Fluent setter that matches x(). More... | |
const T & | y () const |
Vertical location of the center-of-mass. More... | |
void | set_y (const T &y) |
Setter that matches y(). More... | |
Rod2dStateVector< T > | with_y (const T &y) const |
Fluent setter that matches y(). More... | |
const T & | theta () const |
Angle of the rod (measured counter-clockwise). More... | |
void | set_theta (const T &theta) |
Setter that matches theta(). More... | |
Rod2dStateVector< T > | with_theta (const T &theta) const |
Fluent setter that matches theta(). More... | |
const T & | xdot () const |
Velocity of the horizontal location of the center-of-mass. More... | |
void | set_xdot (const T &xdot) |
Setter that matches xdot(). More... | |
Rod2dStateVector< T > | with_xdot (const T &xdot) const |
Fluent setter that matches xdot(). More... | |
const T & | ydot () const |
Velocity of the vertical location of the center-of-mass. More... | |
void | set_ydot (const T &ydot) |
Setter that matches ydot(). More... | |
Rod2dStateVector< T > | with_ydot (const T &ydot) const |
Fluent setter that matches ydot(). More... | |
const T & | thetadot () const |
Angular velocity of the rod. More... | |
void | set_thetadot (const T &thetadot) |
Setter that matches thetadot(). More... | |
Rod2dStateVector< T > | with_thetadot (const T &thetadot) const |
Fluent setter that matches thetadot(). 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 > 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 | |
BasicVector & | operator= (const BasicVector &)=delete |
BasicVector (BasicVector &&)=delete | |
BasicVector & | operator= (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... | |
VectorBase & | PlusEqScaled (const T &scale, const VectorBase< T > &rhs) |
Add in scaled vector rhs to this vector. More... | |
VectorBase & | PlusEqScaled (const std::initializer_list< std::pair< T, const VectorBase< T > & >> &rhs_scale) |
Add in multiple scaled vectors to this vector. More... | |
VectorBase & | operator+= (const VectorBase< T > &rhs) |
Add in vector rhs to this vector. More... | |
VectorBase & | operator-= (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 | |
VectorBase & | operator= (const VectorBase &)=delete |
VectorBase (VectorBase &&)=delete | |
VectorBase & | operator= (VectorBase &&)=delete |
Static Public Member Functions | |
static const std::vector< std::string > & | GetCoordinateNames () |
See Rod2dStateVectorIndices::GetCoordinateNames(). More... | |
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... | |
Additional Inherited Members | |
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... | |
typedef Rod2dStateVectorIndices K |
An abbreviation for our row index constants.
Rod2dStateVector | ( | ) |
Default constructor.
Sets all rows to their default value:
x
defaults to 0.0 m. y
defaults to 0.0 m. theta
defaults to 0.0 rad. xdot
defaults to 0.0 m/s. ydot
defaults to 0.0 m/s. thetadot
defaults to 0.0 rad/s. Rod2dStateVector | ( | const Rod2dStateVector< T > & | other | ) |
|
noexcept |
|
finalvirtual |
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 >.
|
static |
drake::boolean<T> IsValid | ( | ) | const |
Returns whether the current values of this vector are well-formed.
Rod2dStateVector& operator= | ( | const Rod2dStateVector< T > & | other | ) |
|
noexcept |
void Serialize | ( | Archive * | a | ) |
Visit each field of this named vector, passing them (in order) to the given Archive.
The archive can read and/or write to the vector values. One common use of Serialize is the //common/yaml tools.
void set_theta | ( | const T & | theta | ) |
Setter that matches theta().
void set_thetadot | ( | const T & | thetadot | ) |
Setter that matches thetadot().
void set_x | ( | const T & | x | ) |
Setter that matches x().
void set_xdot | ( | const T & | xdot | ) |
Setter that matches xdot().
void set_y | ( | const T & | y | ) |
Setter that matches y().
void set_ydot | ( | const T & | ydot | ) |
Setter that matches ydot().
std::enable_if_t<std::is_same_v<U, symbolic::Expression> > SetToNamedVariables | ( | ) |
Create a symbolic::Variable for each element with the known variable name.
This is only available for T == symbolic::Expression.
const T& theta | ( | ) | const |
Angle of the rod (measured counter-clockwise).
theta
is expressed in units of rad. const T& thetadot | ( | ) | const |
Angular velocity of the rod.
thetadot
is expressed in units of rad/s. Rod2dStateVector<T> with_theta | ( | const T & | theta | ) | const |
Fluent setter that matches theta().
Returns a copy of this
with theta set to a new value.
Rod2dStateVector<T> with_thetadot | ( | const T & | thetadot | ) | const |
Fluent setter that matches thetadot().
Returns a copy of this
with thetadot set to a new value.
Rod2dStateVector<T> with_x | ( | const T & | x | ) | const |
Fluent setter that matches x().
Returns a copy of this
with x set to a new value.
Rod2dStateVector<T> with_xdot | ( | const T & | xdot | ) | const |
Fluent setter that matches xdot().
Returns a copy of this
with xdot set to a new value.
Rod2dStateVector<T> with_y | ( | const T & | y | ) | const |
Fluent setter that matches y().
Returns a copy of this
with y set to a new value.
Rod2dStateVector<T> with_ydot | ( | const T & | ydot | ) | const |
Fluent setter that matches ydot().
Returns a copy of this
with ydot set to a new value.
const T& x | ( | ) | const |
Horizontal location of the center-of-mass.
x
is expressed in units of m. const T& xdot | ( | ) | const |
Velocity of the horizontal location of the center-of-mass.
xdot
is expressed in units of m/s. const T& y | ( | ) | const |
Vertical location of the center-of-mass.
y
is expressed in units of m. const T& ydot | ( | ) | const |
Velocity of the vertical location of the center-of-mass.
ydot
is expressed in units of m/s.