RobWorkProject  23.9.11-
Public Member Functions | Friends | List of all members
StateData Class Reference

the basic building block for the stateless design using the StateStructure class. A StateData represents a size, a unique id, and a unique name, when inserted into the StateStructure. The size will allocate "size"-doubles in State objects originating from the StateStructure. More...

#include <StateData.hpp>

Inherited by Frame, and Constraint.

Public Member Functions

virtual ~StateData ()
 destructor
 
int getID () const
 An integer ID for the StateData. More...
 
const std::string & getName () const
 The name of the state data. More...
 
int size () const
 The number of doubles allocated by this StateData in each State object. More...
 
const double * getData (const rw::kinematics::State &state) const
 An array of length size() containing the values for the state data. More...
 
double * getData (rw::kinematics::State &state)
 An array of length size() containing the values for the state data. More...
 
void setData (rw::kinematics::State &state, const double *vals) const
 Assign for state data the size() of values of the array vals. More...
 
void setData (rw::kinematics::State &state, const std::vector< double > &vals) const
 Assign for state data the size() of values of the array vals. More...
 
void setData (rw::kinematics::State &state, const double &val) const
 Assign for state data the size() of values of the array vals. More...
 
bool hasCache () const
 Check is state data includes a cache. More...
 
rw::core::Ptr< rw::kinematics::StateCachegetCache (const rw::kinematics::State &state) const
 Get the cache. More...
 
rw::core::Ptr< rw::kinematics::StateCachegetCache (rw::kinematics::State &state)
 Get the cache. . More...
 
rw::core::Ptr< rw::kinematics::StateCachegetDefaultCache ()
 Get default cache. More...
 
void setCache (rw::core::Ptr< rw::kinematics::StateCache > cache, rw::kinematics::State &state)
 Set the cache values. More...
 
class rw::kinematics::StateStructuregetStateStructure ()
 Get the state structure. More...
 
bool operator== (const StateData &rhs)
 Compares the state data to see if they are the same Checks the ID, name and which statetrucure they belong to. More...
 
bool operator!= (const StateData &rhs)
 Check if not equal. More...
 
 StateData (int size, const std::string &name)
 A state with size number of doubles in the State vector. More...
 
 StateData (int size, const std::string &name, rw::core::Ptr< rw::kinematics::StateCache > cache)
 A state with size number of doubles in the State vector. More...
 

Friends

class StateStructure
 

Detailed Description

the basic building block for the stateless design using the StateStructure class. A StateData represents a size, a unique id, and a unique name, when inserted into the StateStructure. The size will allocate "size"-doubles in State objects originating from the StateStructure.

Constructor & Destructor Documentation

◆ StateData() [1/2]

StateData ( int  size,
const std::string &  name 
)

A state with size number of doubles in the State vector.

size must be non-negative.

The newly created state data can be added to a structure with StateStructure::addData().

The size of the state data in nr of doubles of the state data is constant throughout the lifetime of the state data.

Parameters
size[in] The number of degrees of freedom of the frame.
name[in] The name of the frame.

◆ StateData() [2/2]

StateData ( int  size,
const std::string &  name,
rw::core::Ptr< rw::kinematics::StateCache cache 
)

A state with size number of doubles in the State vector.

size must be non-negative.

The newly created state data can be added to a structure with StateStructure::addData().

The size of the state data in nr of doubles of the state data is constant throughout the lifetime of the state data.

Parameters
size[in] The number of degrees of freedom of the frame.
name[in] The name of the frame.
cache[in] a cache.

Member Function Documentation

◆ getCache() [1/2]

Get the cache.

Parameters
state[in] the state.
Returns
the cache.

◆ getCache() [2/2]

Get the cache. .

Parameters
state[in] the state.
Returns
the cache. .

◆ getData() [1/2]

const double* getData ( const rw::kinematics::State state) const
inline

An array of length size() containing the values for the state data.

It is OK to call this method also for a StateData with zero size.

Parameters
state[in] The state containing the StateData values.
Returns
The values for the frame.

◆ getData() [2/2]

double* getData ( rw::kinematics::State state)
inline

An array of length size() containing the values for the state data.

It is OK to call this method also for a StateData with zero size.

Parameters
state[in] The state containing the StateData values.
Returns
The values for the frame.

◆ getDefaultCache()

rw::core::Ptr<rw::kinematics::StateCache> getDefaultCache ( )
inline

Get default cache.

Returns
the cache.

◆ getID()

int getID ( ) const
inline

An integer ID for the StateData.

IDs are assigned to the state data upon insertion State. StateData that are not in a State have an ID of -1.

StateData present in different trees may have identical IDs.

IDs are used for the efficient implementation of State. Normally, you should not make use of StateData IDs yourself.

Returns
An integer ID for the frame.

◆ getName()

const std::string& getName ( ) const
inline

The name of the state data.

Returns
The name of the state data.

◆ getStateStructure()

class rw::kinematics::StateStructure* getStateStructure ( )
inline

Get the state structure.

Returns
the state structure.

◆ hasCache()

bool hasCache ( ) const
inline

Check is state data includes a cache.

Returns
true if cache, false otherwise.

◆ operator!=()

bool operator!= ( const StateData rhs)
inline

Check if not equal.

Parameters
rhs[in] the StateData to compare with
Returns
true if not equal
false if equal

◆ operator==()

bool operator== ( const StateData rhs)

Compares the state data to see if they are the same Checks the ID, name and which statetrucure they belong to.

Parameters
rhs[in] the StateData to compare with
Returns
true if equal
false if not equal

◆ setCache()

void setCache ( rw::core::Ptr< rw::kinematics::StateCache cache,
rw::kinematics::State state 
)

Set the cache values.

Parameters
cache[in] the cache.
state[in/out] state updated with new cache.

◆ setData() [1/3]

void setData ( rw::kinematics::State state,
const double &  val 
) const
inline

Assign for state data the size() of values of the array vals.

The array vals must be of length at least size().

Parameters
state[inout] The state to which vals are written.
vals[in] The joint value to assign.

setData() and getData() are related as follows:

data.setData(state, q_in);
const double* q_out = data.getData(state);
for (int i = 0; i < data.getDOF(); i++)
q_in[i] == q_out[i];

◆ setData() [2/3]

void setData ( rw::kinematics::State state,
const double *  vals 
) const
inline

Assign for state data the size() of values of the array vals.

The array vals must be of length at least size().

Parameters
state[inout] The state to which vals are written.
vals[in] The joint values to assign.

setData() and getData() are related as follows:

data.setData(state, q_in);
const double* q_out = data.getData(state);
for (int i = 0; i < data.getDOF(); i++)
q_in[i] == q_out[i];

◆ setData() [3/3]

void setData ( rw::kinematics::State state,
const std::vector< double > &  vals 
) const
inline

Assign for state data the size() of values of the array vals.

The array vals must be of length at least size().

Parameters
state[inout] The state to which vals are written.
vals[in] The joint values to assign.

setData() and getData() are related as follows:

data.setData(state, q_in);
const double* q_out = data.getData(state);
for (int i = 0; i < data.getDOF(); i++)
q_in[i] == q_out[i];

◆ size()

int size ( ) const
inline

The number of doubles allocated by this StateData in each State object.

Returns
The number of doubles allocated by the StateData

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