Control Libraries 7.4.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
state_representation::State Class Reference

Abstract class to represent a state. More...

#include <State.hpp>

Inheritance diagram for state_representation::State:
state_representation::IOState< double > state_representation::IOState< bool > state_representation::IOState< T > state_representation::Jacobian state_representation::JointState state_representation::ParameterInterface state_representation::Shape state_representation::SpatialState state_representation::Trajectory< StateT >

Public Member Functions

 State ()
 Empty constructor.
 
 State (const std::string &name)
 Constructor with name specification.
 
 State (const State &state)
 Copy constructor from another state.
 
virtual ~State ()=default
 Virtual destructor.
 
Stateoperator= (const State &state)
 Copy assignment operator that has to be defined to the custom assignment operator.
 
const StateTypeget_type () const
 Getter of the type attribute.
 
const std::string & get_name () const
 Getter of the name attribute.
 
bool is_empty () const
 Getter of the empty attribute.
 
const std::chrono::time_point< std::chrono::steady_clock > & get_timestamp () const
 Getter of the timestamp attribute.
 
virtual void set_name (const std::string &name)
 Setter of the name attribute.
 
void reset_timestamp ()
 Reset the timestamp attribute to now.
 
virtual void set_data (const Eigen::VectorXd &data)
 Set the data of the state from an Eigen vector.
 
virtual void set_data (const std::vector< double > &data)
 Set the data of the state from a std vector.
 
virtual void set_data (const Eigen::MatrixXd &data)
 Set the data of the state from an Eigen matrix.
 
double get_age () const
 Get the age of the state, i.e. the time since the last modification.
 
virtual bool is_incompatible (const State &state) const
 Check if the state is incompatible for operations with the state given as argument.
 
bool is_deprecated (double time_delay) const
 Check if the state is deprecated given a certain time delay.
 
template<typename DurationT >
bool is_deprecated (const std::chrono::duration< int64_t, DurationT > &time_delay) const
 Check if the state is deprecated given a certain time delay.
 
virtual void reset ()
 Reset the object to a post-construction state.
 
 operator bool () const noexcept
 Boolean operator for the truthiness of a state.
 

Protected Member Functions

void set_type (const StateType &type)
 Setter of the state type attribute.
 
void set_empty (bool empty=true)
 Setter of the empty attribute.
 
void assert_not_empty () const
 Throw an exception if the state is empty.
 
virtual std::string to_string () const
 Convert the state to its string representation.
 

Friends

void swap (State &state1, State &state2)
 Swap the values of the two states.
 
std::ostream & operator<< (std::ostream &os, const State &state)
 Overload the ostream operator for printing.
 

Detailed Description

Abstract class to represent a state.

Definition at line 25 of file State.hpp.

Constructor & Destructor Documentation

◆ State() [1/3]

state_representation::State::State ( )

Empty constructor.

Definition at line 7 of file State.cpp.

◆ State() [2/3]

state_representation::State::State ( const std::string &  name)
explicit

Constructor with name specification.

Parameters
nameThe name of the state

Definition at line 9 of file State.cpp.

◆ State() [3/3]

state_representation::State::State ( const State state)

Copy constructor from another state.

Definition at line 12 of file State.cpp.

Member Function Documentation

◆ assert_not_empty()

void state_representation::State::assert_not_empty ( ) const
protected

Throw an exception if the state is empty.

Exceptions
exceptions::EmptyStateException

Definition at line 55 of file State.cpp.

◆ get_age()

double state_representation::State::get_age ( ) const

Get the age of the state, i.e. the time since the last modification.

Definition at line 81 of file State.cpp.

◆ get_name()

const std::string & state_representation::State::get_name ( ) const

Getter of the name attribute.

Definition at line 29 of file State.cpp.

◆ get_timestamp()

const std::chrono::time_point< std::chrono::steady_clock > & state_representation::State::get_timestamp ( ) const

Getter of the timestamp attribute.

Definition at line 37 of file State.cpp.

◆ get_type()

const StateType & state_representation::State::get_type ( ) const

Getter of the type attribute.

Definition at line 25 of file State.cpp.

◆ is_deprecated() [1/2]

template<typename DurationT >
bool state_representation::State::is_deprecated ( const std::chrono::duration< int64_t, DurationT > &  time_delay) const
inline

Check if the state is deprecated given a certain time delay.

Parameters
time_delayThe time after which to consider the state as deprecated

Definition at line 188 of file State.hpp.

◆ is_deprecated() [2/2]

bool state_representation::State::is_deprecated ( double  time_delay) const

Check if the state is deprecated given a certain time delay.

Parameters
time_delayThe time after which to consider the state as deprecated

Definition at line 87 of file State.cpp.

◆ is_empty()

bool state_representation::State::is_empty ( ) const

Getter of the empty attribute.

Definition at line 33 of file State.cpp.

◆ is_incompatible()

bool state_representation::State::is_incompatible ( const State state) const
virtual

Check if the state is incompatible for operations with the state given as argument.

Parameters
stateThe state to check compatibility with

Reimplemented in state_representation::IOState< T >, state_representation::IOState< bool >, state_representation::IOState< double >, state_representation::Jacobian, state_representation::JointState, and state_representation::SpatialState.

Definition at line 91 of file State.cpp.

◆ operator bool()

state_representation::State::operator bool ( ) const
explicitnoexcept

Boolean operator for the truthiness of a state.

Returns
False if the state is empty, true otherwise

Definition at line 95 of file State.cpp.

◆ operator=()

State & state_representation::State::operator= ( const State state)

Copy assignment operator that has to be defined to the custom assignment operator.

Parameters
stateThe state with value to assign
Returns
Reference to the current state with new values

Definition at line 19 of file State.cpp.

◆ reset()

void state_representation::State::reset ( )
virtual

◆ reset_timestamp()

void state_representation::State::reset_timestamp ( )

Reset the timestamp attribute to now.

Definition at line 61 of file State.cpp.

◆ set_data() [1/3]

void state_representation::State::set_data ( const Eigen::MatrixXd &  data)
virtual

Set the data of the state from an Eigen matrix.

Reimplemented in state_representation::Jacobian.

Definition at line 73 of file State.cpp.

◆ set_data() [2/3]

void state_representation::State::set_data ( const Eigen::VectorXd &  data)
virtual

◆ set_data() [3/3]

void state_representation::State::set_data ( const std::vector< double > &  data)
virtual

◆ set_empty()

void state_representation::State::set_empty ( bool  empty = true)
protected

Setter of the empty attribute.

Calling this function will also reset the timestamp

Parameters
emptyFlag to specify if the state should be empty or not, default true

Definition at line 50 of file State.cpp.

◆ set_name()

void state_representation::State::set_name ( const std::string &  name)
virtual

Setter of the name attribute.

Definition at line 45 of file State.cpp.

◆ set_type()

void state_representation::State::set_type ( const StateType type)
protected

Setter of the state type attribute.

Definition at line 41 of file State.cpp.

◆ to_string()

std::string state_representation::State::to_string ( ) const
protectedvirtual

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const State state 
)
friend

Overload the ostream operator for printing.

Parameters
osThe ostream to append the string representing the state to
stateThe state to print
Returns
The appended ostream

Definition at line 104 of file State.cpp.

◆ swap

void swap ( State state1,
State state2 
)
friend

Swap the values of the two states.

Parameters
state1State to be swapped with 2
state2State to be swapped with 1

Definition at line 181 of file State.hpp.


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