RobWorkProject  23.9.11-
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
State Class Reference

The state of a work cell (or kinematics tree). More...

#include <State.hpp>

Inherits Serializable.

Public Types

typedef rw::core::Ptr< StatePtr
 Smart pointer type to State.
 
typedef double value_type
 Value type.
 

Public Member Functions

 State ()
 Default constructor giving an empty state. Beware that the state is not initialized and that passing this state to a procedure will typically cause a program crash.
 
virtual ~State ()
 destructor
 
void setQStateInState (State &to) const
 Assign to a state the configuration state of this state. More...
 
void setTreeStateInState (State &to) const
 Assign to a state the tree state of this state. More...
 
State operator* (double scale) const
 Scaling of the configuration state by a scalar. More...
 
State operator/ (double scale) const
 Scaling of the configuration state by division. More...
 
State operator+ (const State &b) const
 Addition of configuration states. More...
 
State operator- (const State &b) const
 Subtraction of configuration states. More...
 
State operator- () const
 Unary minus operator. More...
 
void copy (const State &src)
 copies data from a state into this state. The version of the state is allowed to be different from this state. Only state data that is valid for both states will be copied. More...
 
State clone ()
 performs a deep copy of this state and returns the clone. Both QState and TreeState are (deep) copied as normal however the cachestates will be copied using their clone method. More...
 
void clone (const State &src)
 performs a deep copy of src into this state. More...
 
void upgrade ()
 this function upgrades the current version of this State to the newest state. It will not override data values that is set in the current state.
 
void upgradeTo (const State &state)
 this function upgrades the current version of this State with the given state. It will not override data values that is set in the current state.
 
size_t size () const
 The dimension of the configuration state vector. More...
 
double & operator() (size_t index)
 Provides direct access to the configurations stored in the state. More...
 
const double & operator() (size_t index) const
 Provides direct read access to the configurations stored in the state. More...
 
double & operator[] (size_t index)
 Same as operator().
 
const double & operator[] (size_t index) const
 Same as operator().
 
rw::kinematics::FramegetFrame (int id)
 gets the frame with id id. If a frame with id id does not exist NULL is returned
 
int getUniqueId () const
 get the state id. Represents the static structure of the StateStructure that this state relates to.
 
rw::core::Ptr< StateStructuregetStateStructure () const
 Returns pointer to the state structure (the structure of Frame's and StateData) More...
 
void read (class rw::common::InputArchive &iarchive, const std::string &id)
 
void write (class rw::common::OutputArchive &oarchive, const std::string &id) const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 destructor
 

Static Public Member Functions

static const StategetDefault (rw::kinematics::StateData *data)
 Get default. More...
 

Friends

class StateData
 
class Frame
 
class StateStructure
 
State operator* (double scale, const State &state)
 Scaling of the configuration state by a scalar. More...
 

Detailed Description

The state of a work cell (or kinematics tree).

You need a work cell state in order to calculate forward kinematics for trees of frames.

Work cell states can be copied and assigned freely.

The work cell state consists of a part for the tree structure and a part for the configuration values. You are encouraged to use the getParent(), getChildren(), getQ() and setQ() utility functions rather than explicitly type, say, state.getQState().getQ(). That way you will have a much easier time of updating the code if we decide to change the way the kinematics data structures are stored (!). Also getQ(state, frame) is shorter to type also.

The operation of a work cell state is undefined valid if the tree used for its initialization is modified. (The implementation takes some care to check for this and crashes the program in a controlled way if it takes place.)

Member Function Documentation

◆ clone() [1/2]

State clone ( )

performs a deep copy of this state and returns the clone. Both QState and TreeState are (deep) copied as normal however the cachestates will be copied using their clone method.

Returns
a deep copy of this state (clone)

◆ clone() [2/2]

void clone ( const State src)

performs a deep copy of src into this state.

Parameters
src[in] the state that is to be cloned

◆ copy()

void copy ( const State src)

copies data from a state into this state. The version of the state is allowed to be different from this state. Only state data that is valid for both states will be copied.

Parameters
src[in] the state that is to be copied

◆ getDefault()

static const State& getDefault ( rw::kinematics::StateData data)
static

Get default.

Parameters
data[in] the state data.
Returns
default state.

◆ getStateStructure()

rw::core::Ptr<StateStructure> getStateStructure ( ) const

Returns pointer to the state structure (the structure of Frame's and StateData)

Returns
Pointer to the StateStructure matching the frame

◆ operator()() [1/2]

double& operator() ( size_t  index)
inline

Provides direct access to the configurations stored in the state.

Notice that modifying a state directly may result in the state being inconsistent

Parameters
index[in] Index of element to access

◆ operator()() [2/2]

const double& operator() ( size_t  index) const
inline

Provides direct read access to the configurations stored in the state.

Parameters
index[in] Index of element to access

◆ operator*()

State operator* ( double  scale) const
inline

Scaling of the configuration state by a scalar.

The tree state remains the same.

◆ operator+()

State operator+ ( const State b) const
inline

Addition of configuration states.

It is undefined whether it is the tree state of a or b that is used for the resulting state. We say that it is undefined to force you to use setTreeStateInState() to make you explicitly choose the tree state.

◆ operator-() [1/2]

State operator- ( ) const
inline

Unary minus operator.

The tree state remains the same.

◆ operator-() [2/2]

State operator- ( const State b) const
inline

Subtraction of configuration states.

It is undefined whether it is the tree state of a or b that is used for the resulting state. We say that it is undefined to force you to use setTreeStateInState() to make you explicitly choose the tree state.

◆ operator/()

State operator/ ( double  scale) const
inline

Scaling of the configuration state by division.

The tree state remains the same.

◆ read()

void read ( class rw::common::InputArchive iarchive,
const std::string &  id 
)
virtual

Enable read-serialization of inherited class by implementing this method. Data is read from iarchive and filled into this object.

Parameters
iarchive[in] the InputArchive from which to read data.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

Implements Serializable.

◆ setQStateInState()

void setQStateInState ( State to) const
inline

Assign to a state the configuration state of this state.

The State can be thought of as consisting of a tree state (TreeState) (for the structure of the tree) and a configuration state (QState) (containing joint values, for example). The setQStateInState() method copies into this state the QState part of another state.

Parameters
to[out] The state to which the configuration state is written.

◆ setTreeStateInState()

void setTreeStateInState ( State to) const
inline

Assign to a state the tree state of this state.

The State can be thought of as consisting of a tree state (TreeState) (for the structure of the tree) and a configuration state (QState) (containing joint values, for example). The setTreeState() method copies into this state the TreeState part of another state.

Implementation note: setTreeStateInState() is currently a lot faster than setQStateInState() (even though they are both fast), so if you have the choice then use the former.

Parameters
to[out] The state to which the tree state is written.

◆ size()

size_t size ( ) const
inline

The dimension of the configuration state vector.

Knowing the size of the state is useful for example in error messages, so that you can report if two states seem to belong to different workcells.

◆ write()

void write ( class rw::common::OutputArchive oarchive,
const std::string &  id 
) const
virtual

Enable write-serialization of inherited class by implementing this method. Data is written to oarchive from this object.

Parameters
oarchive[out] the OutputArchive in which data should be written.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

Implements Serializable.

Friends And Related Function Documentation

◆ operator*

State operator* ( double  scale,
const State state 
)
friend

Scaling of the configuration state by a scalar.

The tree state remains the same.


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