Drake
Drake C++ Documentation
DiagramContinuousState< T > Class Template Referencefinal

Detailed Description

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

DiagramContinuousState is a ContinuousState consisting of Supervectors xc, q, v, z over the corresponding entries in a set of referenced ContinuousState objects, which may or may not be owned by this DiagramContinuousState.

This is done recursively since any of the referenced ContinuousState objects could themselves be DiagramContinuousState objects. The actual numerical data is always contained in the leaf ContinuousState objects at the bottom of the tree.

This object is used both for a Diagram's actual continuous state variables xc (with partitions q, v, z) and for the time derivatives xdot (qdot, vdot, zdot). Cloning a DiagramContinuousState results in an object with identical structure, but which owns the referenced ContinuousState objects, regardless of whether the original had ownership.

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

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

Public Member Functions

DiagramContinuousState (std::vector< ContinuousState< T > * > substates)
 Constructs a ContinuousState that is composed of other ContinuousStates, which are not owned by this object and must outlive it. More...
 
 DiagramContinuousState (std::vector< std::unique_ptr< ContinuousState< T >>> substates)
 Constructs a ContinuousState that is composed (recursively) of other ContinuousState objects, ownership of which is transferred here. More...
 
 ~DiagramContinuousState () override
 
std::unique_ptr< DiagramContinuousStateClone () const
 Creates a deep copy of this DiagramContinuousState, with the same substructure but with new, owned data. More...
 
int num_substates () const
 
const ContinuousState< T > & get_substate (int index) const
 Returns the continuous state at the given index. More...
 
ContinuousState< T > & get_mutable_substate (int index)
 Returns the continuous state at the given index. More...
 
Does not allow copy, move, or assignment
 DiagramContinuousState (const DiagramContinuousState &)=delete
 
DiagramContinuousStateoperator= (const DiagramContinuousState &)=delete
 
 DiagramContinuousState (DiagramContinuousState &&)=delete
 
DiagramContinuousStateoperator= (DiagramContinuousState &&)=delete
 
- Public Member Functions inherited from ContinuousState< T >
 ContinuousState (std::unique_ptr< VectorBase< T >> state)
 Constructs a ContinuousState for a system that does not have second-order structure. More...
 
 ContinuousState (std::unique_ptr< VectorBase< T >> state, int num_q, int num_v, int num_z)
 Constructs a ContinuousState that exposes second-order structure. More...
 
 ContinuousState ()
 Constructs a zero-length ContinuousState. More...
 
virtual ~ContinuousState ()
 
std::unique_ptr< ContinuousState< T > > Clone () const
 Creates a deep copy of this object with the same substructure but with all data owned by the copy. More...
 
int size () const
 Returns the size of the entire continuous state vector, which is necessarily num_q + num_v + num_z. More...
 
int num_q () const
 Returns the number of generalized positions q in this state vector. More...
 
int num_v () const
 Returns the number of generalized velocities v in this state vector. More...
 
int num_z () const
 Returns the number of miscellaneous continuous state variables z in this state vector. More...
 
T & operator[] (std::size_t idx)
 
const T & operator[] (std::size_t idx) const
 
const VectorBase< T > & get_vector () const
 Returns a reference to the entire continuous state vector. More...
 
VectorBase< T > & get_mutable_vector ()
 Returns a mutable reference to the entire continuous state vector. More...
 
const VectorBase< T > & get_generalized_position () const
 Returns a const reference to the subset of the state vector that is generalized position q. More...
 
VectorBase< T > & get_mutable_generalized_position ()
 Returns a mutable reference to the subset of the state vector that is generalized position q. More...
 
const VectorBase< T > & get_generalized_velocity () const
 Returns a const reference to the subset of the continuous state vector that is generalized velocity v. More...
 
VectorBase< T > & get_mutable_generalized_velocity ()
 Returns a mutable reference to the subset of the continuous state vector that is generalized velocity v. More...
 
const VectorBase< T > & get_misc_continuous_state () const
 Returns a const reference to the subset of the continuous state vector that is other continuous state z. More...
 
VectorBase< T > & get_mutable_misc_continuous_state ()
 Returns a mutable reference to the subset of the continuous state vector that is other continuous state z. More...
 
template<typename U >
void SetFrom (const ContinuousState< U > &other)
 Copies the values from other into this, converting the scalar type as necessary. More...
 
void SetFromVector (const Eigen::Ref< const VectorX< T >> &value)
 Sets the entire continuous state vector from an Eigen expression. More...
 
VectorX< T > CopyToVector () const
 Returns a copy of the entire continuous state vector into an Eigen vector. More...
 
 ContinuousState (const ContinuousState &)=delete
 
ContinuousStateoperator= (const ContinuousState &)=delete
 
 ContinuousState (ContinuousState &&)=delete
 
ContinuousStateoperator= (ContinuousState &&)=delete
 
internal::SystemId get_system_id () const
 (Internal) Gets the id of the subsystem that created this state. More...
 
void set_system_id (internal::SystemId id)
 (Internal) Records the id of the subsystem that created this state. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ContinuousState< T >
 ContinuousState (std::unique_ptr< VectorBase< T >> state, std::unique_ptr< VectorBase< T >> q, std::unique_ptr< VectorBase< T >> v, std::unique_ptr< VectorBase< T >> z)
 Constructs a continuous state that exposes second-order structure, with no particular constraints on the layout. More...
 

Constructor & Destructor Documentation

◆ DiagramContinuousState() [1/4]

◆ DiagramContinuousState() [2/4]

◆ DiagramContinuousState() [3/4]

* DiagramContinuousState ( std::vector< ContinuousState< T > * >  substates)
explicit

Constructs a ContinuousState that is composed of other ContinuousStates, which are not owned by this object and must outlive it.

The DiagramContinuousState vector xc = [q v z] will have the same ordering as the substates parameter, which should be the order of the Diagram itself. That is, the substates should be indexed by SubsystemIndex in the same order as the subsystems are.

◆ DiagramContinuousState() [4/4]

DiagramContinuousState ( std::vector< std::unique_ptr< ContinuousState< T >>>  substates)
explicit

Constructs a ContinuousState that is composed (recursively) of other ContinuousState objects, ownership of which is transferred here.

◆ ~DiagramContinuousState()

~DiagramContinuousState ( )
override

Member Function Documentation

◆ Clone()

std::unique_ptr<DiagramContinuousState> Clone ( ) const

Creates a deep copy of this DiagramContinuousState, with the same substructure but with new, owned data.

Intentionally shadows the ContinuousState::Clone() method but with a more-specific return type so you don't have to downcast.

◆ get_mutable_substate()

ContinuousState<T>& get_mutable_substate ( int  index)

Returns the continuous state at the given index.

Aborts if index is out-of-bounds.

◆ get_substate()

const ContinuousState<T>& get_substate ( int  index) const

Returns the continuous state at the given index.

Aborts if index is out-of-bounds.

◆ num_substates()

int num_substates ( ) const

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

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