Package org.robwork.sdurw_kinematics
Class State
- java.lang.Object
-
- org.robwork.sdurw_common.Serializable
-
- org.robwork.sdurw_kinematics.State
-
public class State extends Serializable
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.)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description State
add(State b)
Addition of configuration states.
It is undefined whether it is the tree state of a or b that
is used for the resulting state.State
clone()
performs a deep copy of this state and returns the clone.void
clone(State src)
performs a deep copy of src into this state.void
copy(State src)
copies data from a state into this state.void
delete()
State
divide(double scale)
Scaling of the configuration state by division.
The tree state remains the same.double
get(long i)
static long
getCPtr(State obj)
static State
getDefault(StateData data)
Get default.Frame
getFrame(int id)
gets the frame with id id.StateStructurePtr
getStateStructure()
Returns pointer to the state structure (the structure of Frame's and StateData)int
getUniqueId()
get the state id.State
multiply(double scale)
Scaling of the configuration state by a scalar.
The tree state remains the same.State
negate()
Unary minus operator.
The tree state remains the same.void
read(InputArchive iarchive, java.lang.String id)
Enable read-serialization of inherited class by implementing this method.void
set(long i, double d)
void
setQStateInState(State to)
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).void
setTreeStateInState(State to)
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).long
size()
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.State
subtract(State b)
Subtraction of configuration states.
It is undefined whether it is the tree state of a or b that
is used for the resulting state.void
upgrade()
this function upgrades the current version of this
State to the newest state.void
upgradeTo(State state)
this function upgrades the current version of this
State with the given state.void
write(OutputArchive oarchive, java.lang.String id)
Enable write-serialization of inherited class by implementing this method.-
Methods inherited from class org.robwork.sdurw_common.Serializable
getCPtr
-
-
-
-
Method Detail
-
getCPtr
public static long getCPtr(State obj)
-
delete
public void delete()
- Overrides:
delete
in classSerializable
-
setQStateInState
public void setQStateInState(State to)
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
public void setTreeStateInState(State to)
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.
-
multiply
public State multiply(double scale)
Scaling of the configuration state by a scalar.
The tree state remains the same.
-
divide
public State divide(double scale)
Scaling of the configuration state by division.
The tree state remains the same.
-
add
public State add(State b)
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.
-
subtract
public State subtract(State b)
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.
-
negate
public State negate()
Unary minus operator.
The tree state remains the same.
-
copy
public void copy(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
-
clone
public 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
public void clone(State src)
performs a deep copy of src into this state.- Parameters:
src
- [in] the state that is to be cloned
-
upgrade
public 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.
-
upgradeTo
public void upgradeTo(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
public long size()
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.
-
get
public double get(long i)
-
set
public void set(long i, double d)
-
getFrame
public Frame getFrame(int id)
gets the frame with id id. If a frame with id id does not exist
NULL is returned
-
getUniqueId
public int getUniqueId()
get the state id. Represents the static structure of the StateStructure that
this state relates to.
-
getStateStructure
public StateStructurePtr getStateStructure()
Returns pointer to the state structure (the structure of Frame's and StateData)- Returns:
- Pointer to the StateStructure matching the frame
-
read
public void read(InputArchive iarchive, java.lang.String id)
Description copied from class:Serializable
Enable read-serialization of inherited class by implementing this method. Data is read
from iarchive and filled into this object.- Overrides:
read
in classSerializable
- 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.
-
write
public void write(OutputArchive oarchive, java.lang.String id)
Description copied from class:Serializable
Enable write-serialization of inherited class by implementing this method. Data is
written to oarchive from this object.- Overrides:
write
in classSerializable
- 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.
-
-