Package org.robwork.sdurw_kinematics
Class StateData
- java.lang.Object
-
- org.robwork.sdurw_kinematics.StateData
-
- Direct Known Subclasses:
Frame
public class StateData extends java.lang.Object
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 Summary
Constructors Constructor Description StateData(int size, java.lang.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.
StateData(int size, java.lang.String name, StateCachePtr cache)
, const std::string&)StateData(long cPtr, boolean cMemoryOwn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete()
boolean
equals(StateData rhs)
Compares the state data to see if they are the same
Checks the ID, name and which statetrucure they belong toStateCachePtr
getCache(State state)
Get the cache.static long
getCPtr(StateData obj)
vector_d
getData(State state)
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.
StateCachePtr
getDefaultCache()
Get default cache.int
getID()
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.java.lang.String
getName()
The name of the state data.
StateStructure
getStateStructure()
Get the state structure.boolean
hasCache()
Check is state data includes a cache.boolean
notEqual(StateData rhs)
Check if not equalvoid
setCache(StateCachePtr cache, State state)
Set the cache values.void
setData(State state, double val)
Assign for state data the size() of values of the array
vals.
The array vals must be of length at least size().
void
setData(State state, vector_d vals)
Assign for state data the size() of values of the array
vals.
The array vals must be of length at least size().
int
size()
The number of doubles allocated by this StateData in
each State object.
-
-
-
Constructor Detail
-
StateData
public StateData(long cPtr, boolean cMemoryOwn)
-
StateData
public StateData(int size, java.lang.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
public StateData(int size, java.lang.String name, StateCachePtr cache)
, const std::string&)- Parameters:
cache
- [in] a cache.
-
-
Method Detail
-
getCPtr
public static long getCPtr(StateData obj)
-
delete
public void delete()
-
getID
public int getID()
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
public java.lang.String getName()
The name of the state data.
- Returns:
- The name of the state data.
-
size
public int size()
The number of doubles allocated by this StateData in
each State object.
- Returns:
- The number of doubles allocated by the StateData
-
setData
public void setData(State state, vector_d vals)
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
public void setData(State state, double val)
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.
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];
-
hasCache
public boolean hasCache()
Check is state data includes a cache.- Returns:
- true if cache, false otherwise.
-
getCache
public StateCachePtr getCache(State state)
Get the cache.- Parameters:
state
- [in] the state.- Returns:
- the cache.
-
getDefaultCache
public StateCachePtr getDefaultCache()
Get default cache.- Returns:
- the cache.
-
setCache
public void setCache(StateCachePtr cache, State state)
Set the cache values.- Parameters:
cache
- [in] the cache.state
- [in/out] state updated with new cache.
-
getStateStructure
public StateStructure getStateStructure()
Get the state structure.- Returns:
- the state structure.
-
equals
public boolean equals(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
-
notEqual
public boolean notEqual(StateData rhs)
Check if not equal- Parameters:
rhs
- [in] the StateData to compare with- Returns:
- true if not equal
-
-