PostureEngine Class Reference#include <PostureEngine.h>
Inheritance diagram for PostureEngine:
[legend]List of all members.
Detailed Description
A class for storing a set of positions and weights for all the outputs.
Handy for any class which wants to deal with setting joints and postures without writing a custom class - See also:
- PostureMC
Definition at line 15 of file PostureEngine.h.
|
Public Member Functions |
| PostureEngine () |
| constructor
|
| PostureEngine (const char *filename) |
| constructor, loads a position from a file
|
| PostureEngine (const WorldState *st) |
| constructor, initializes joint positions to the current state of the outputs as defined by state
|
virtual | ~PostureEngine () |
| destructor
|
virtual void | takeSnapshot () |
| sets the internal cmds to the current state of the outputs
|
virtual void | takeSnapshot (const WorldState *st) |
| sets the internal cmds to the current state of the outputs as defined by state
|
virtual void | clear () |
| sets all joints to unused
|
virtual PostureEngine & | setOverlay (const PostureEngine &pe) |
| sets joints of this to all joints of pe which are not equal to unused (layers pe over this) stores into this
|
virtual PostureEngine | createOverlay (const PostureEngine &pe) const |
| sets joints of this to all joints of pe which are not equal to unused (layers pe over this) returns new PostureEngine
|
virtual PostureEngine & | setUnderlay (const PostureEngine &pe) |
| sets joints of this which are equal to unused to pe, (layers this over pe) stores into this
|
virtual PostureEngine | createUnderlay (const PostureEngine &pe) const |
| sets joints of this which are equal to unused to pe, (layers this over pe) returns new PostureEngine
|
virtual PostureEngine & | setAverage (const PostureEngine &pe, float w=0.5) |
| computes a weighted average of this vs. pe, w being the weight towards pe (so w==1 just copies pe)
|
virtual PostureEngine | createAverage (const PostureEngine &pe, float w=0.5) const |
| computes a weighted average of this vs. pe, w being the weight towards pe (so w==1 just copies pe)
|
virtual PostureEngine & | setCombine (const PostureEngine &pe) |
| computes a weighted average of this vs. pe, using the weight values of the joints, storing the total weight in the result's weight value
|
virtual PostureEngine | createCombine (const PostureEngine &pe) const |
| computes a weighted average of this vs. pe, using the weight values of the joints, storing the total weight in the result's weight value
|
float | diff (const PostureEngine &pe) const |
| returns the sum squared error between this and pe's output values, but only between outputs which are both not unused
|
float | avgdiff (const PostureEngine &pe) const |
| returns the average sum squared error between this and pe's output values for outputs which are both not unused
|
float | maxdiff (const PostureEngine &pe) const |
| returns the max error between this and pe's output values for outputs which are both not unused
|
bool | solveLinkPosition (const NEWMAT::ColumnVector &Pobj, unsigned int j, const NEWMAT::ColumnVector &Plink) |
| Performs inverse kinematics to solve for positioning Plink on link j to Pobj in base coordinates (expects homogenous form); if solution found, stores result in this posture and returns true.
|
bool | solveLinkPosition (float Pobj_x, float Pobj_y, float Pobj_z, unsigned int j, float Plink_x, float Plink_y, float Plink_z) |
| Performs inverse kinematics to solve for positioning Plink on link j to Pobj in base coordinates; if solution found, stores result in this posture and returns true.
|
bool | solveLinkVector (const NEWMAT::ColumnVector &Pobj, unsigned int j, const NEWMAT::ColumnVector &Plink) |
| Performs inverse kinematics to solve for positioning Plink on link j to Pobj in base coordinates (expects homogenous form); if solution found, stores result in this posture and returns true.
|
bool | solveLinkVector (float Pobj_x, float Pobj_y, float Pobj_z, unsigned int j, float Plink_x, float Plink_y, float Plink_z) |
| Performs inverse kinematics to solve for positioning Plink on link j to Pobj in base coordinates; if solution found, stores result in this posture and returns true.
|
|
NOT VIRTUAL! You should be able to call this to set outputs without checking out, just a peekMotion(). Theoretically.
|
PostureEngine & | setOutputCmd (unsigned int i, const OutputCmd &c) |
| sets output i to OutputCmd c, returns *this so you can chain them
|
OutputCmd & | operator() (unsigned int i) |
| returns output i, returns a reference so you can also set "through" this call.
|
const OutputCmd & | operator() (unsigned int i) const |
| returns output i
|
OutputCmd & | getOutputCmd (unsigned int i) |
| returns output i, returns a reference so you can also set "through" this call.
|
const OutputCmd & | getOutputCmd (unsigned int i) const |
| returns output i
|
|
Uses LoadSave interface so you can load/save to files, uses a human-readable storage format |
virtual unsigned int | getBinSize () const |
| calculates space needed to save - if you can't precisely add up the size, overestimate and things will still work.
|
virtual unsigned int | LoadBuffer (const char buf[], unsigned int len) |
| Load from a saved buffer.
|
virtual unsigned int | SaveBuffer (char buf[], unsigned int len) const |
| Save to a given buffer.
|
virtual unsigned int | LoadFile (const char filename[]) |
virtual unsigned int | SaveFile (const char filename[]) const |
Protected Member Functions |
virtual void | update (unsigned int c, unsigned int l) |
| Called at the beginning of each function which accesses ROBOOP computations - should make sure the ROBOOP structures are up to date with Tekkotsu structures.
|
Protected Attributes |
OutputCmd | cmds [NumOutputs] |
| the table of outputs' values and weights, can be accessed through setOutputCmd() and getOutputCmd()
|
Constructor & Destructor Documentation
PostureEngine::PostureEngine |
( |
|
) |
[inline] |
|
PostureEngine::PostureEngine |
( |
const char * |
filename |
) |
[inline] |
|
|
constructor, loads a position from a file
- Todo:
- might want to make a library of common positions so they don't have to be loaded repeatedly from memstick
Definition at line 21 of file PostureEngine.h. |
PostureEngine::PostureEngine |
( |
const WorldState * |
st |
) |
[inline] |
|
|
constructor, initializes joint positions to the current state of the outputs as defined by state
Definition at line 23 of file PostureEngine.h. |
Member Function Documentation
|
returns the average sum squared error between this and pe's output values for outputs which are both not unused
- Todo:
- create a version which does weighted summing? This treats weights as all or nothing
Definition at line 102 of file PostureEngine.cc. |
void PostureEngine::clear |
( |
|
) |
[virtual] |
|
|
computes a weighted average of this vs. pe, w being the weight towards pe (so w==1 just copies pe)
joints being averaged with weight<=0 have their weights averaged, but not their values (so an output can crossfade properly)
- Parameters:
-
| pe | the other PostureEngine |
| w | amount to weight towards pe
- if w < .001, nothing is done
- if w > .999, a straight copy of pe occurs (sets joints to unused properly at end of fade)
- .001 and .999 is used instead of 0 and 1 to allow for slight addition errors in a loop (if using repeated additions of a delta value instead of repeated divisions)
|
- Returns:
- a new posture containing the results
Definition at line 76 of file PostureEngine.cc. |
|
computes a weighted average of this vs. pe, using the weight values of the joints, storing the total weight in the result's weight value
Definition at line 87 of file PostureEngine.cc. |
|
sets joints of this to all joints of pe which are not equal to unused (layers pe over this) returns new PostureEngine
Definition at line 30 of file PostureEngine.cc. |
|
sets joints of this which are equal to unused to pe, (layers this over pe) returns new PostureEngine
Definition at line 40 of file PostureEngine.cc. |
|
returns the sum squared error between this and pe's output values, but only between outputs which are both not unused
- Todo:
- create a version which does weighted summing? This treats weights as all or nothing
Definition at line 92 of file PostureEngine.cc. |
unsigned int PostureEngine::getBinSize |
( |
|
) |
const [virtual] |
|
|
calculates space needed to save - if you can't precisely add up the size, overestimate and things will still work.
- Returns:
- number of bytes read/written, 0 if error (or empty)
Implements LoadSave.
Definition at line 125 of file PostureEngine.cc. |
const OutputCmd& PostureEngine::getOutputCmd |
( |
unsigned int |
i |
) |
const [inline] |
|
OutputCmd& PostureEngine::getOutputCmd |
( |
unsigned int |
i |
) |
[inline] |
|
unsigned int PostureEngine::LoadBuffer |
( |
const char |
buf[], |
|
|
unsigned int |
len |
|
) |
[virtual] |
|
|
Load from a saved buffer.
- Parameters:
-
| buf | pointer to the memory where you should begin loading |
| len | length of buf available (this isn't all yours, might be more stuff saved after yours) |
- Returns:
- the number of bytes actually used
Implements LoadSave.
Reimplemented in PostureMC.
Definition at line 134 of file PostureEngine.cc.
Referenced by PostureMC::LoadBuffer(). |
unsigned int PostureEngine::LoadFile |
( |
const char |
filename[] |
) |
[virtual] |
|
|
returns the max error between this and pe's output values for outputs which are both not unused
- Todo:
- create a version which does weighted summing? This treats weights as all or nothing
Definition at line 114 of file PostureEngine.cc.
Referenced by PostureMC::isAlive(). |
const OutputCmd& PostureEngine::operator() |
( |
unsigned int |
i |
) |
const [inline] |
|
OutputCmd& PostureEngine::operator() |
( |
unsigned int |
i |
) |
[inline] |
|
|
returns output i, returns a reference so you can also set "through" this call.
Definition at line 71 of file PostureEngine.h. |
unsigned int PostureEngine::SaveBuffer |
( |
char |
buf[], |
|
|
unsigned int |
len |
|
) |
const [virtual] |
|
|
Save to a given buffer.
- Parameters:
-
| buf | pointer to the memory where you should begin writing |
| len | length of buf available. (this isn't all yours, constrain yourself to what you returned in getBinSize() ) |
- Returns:
- the number of bytes actually used
Implements LoadSave.
Definition at line 217 of file PostureEngine.cc. |
unsigned int PostureEngine::SaveFile |
( |
const char |
filename[] |
) |
const [virtual] |
|
|
computes a weighted average of this vs. pe, w being the weight towards pe (so w==1 just copies pe)
joints being averaged with unused joints have their weights averaged, but not their values (so an output can crossfade properly)
- Parameters:
-
| pe | the other PostureEngine |
| w | amount to weight towards pe
- if w < .001, nothing is done
- if w > .999, a straight copy of pe occurs (sets joints to unused properly at end of fade)
- .001 and .999 is used instead of 0 and 1 to allow for slight addition errors in a loop (if using repeated additions of a delta value instead of repeated divisions)
|
- Returns:
*this , stores results into this
Reimplemented in PostureMC.
Definition at line 52 of file PostureEngine.cc.
Referenced by createAverage(), and PostureMC::setAverage(). |
bool PostureEngine::solveLinkPosition |
( |
float |
Pobj_x, |
|
|
float |
Pobj_y, |
|
|
float |
Pobj_z, |
|
|
unsigned int |
j, |
|
|
float |
Plink_x, |
|
|
float |
Plink_y, |
|
|
float |
Plink_z |
|
) |
[inline] |
|
|
Performs inverse kinematics to solve for positioning Plink on link j to Pobj in base coordinates; if solution found, stores result in this posture and returns true.
Definition at line 89 of file PostureEngine.h. |
|
Performs inverse kinematics to solve for positioning Plink on link j to Pobj in base coordinates (expects homogenous form); if solution found, stores result in this posture and returns true.
Definition at line 283 of file PostureEngine.cc.
Referenced by solveLinkPosition(), and solveLinkVector(). |
bool PostureEngine::solveLinkVector |
( |
float |
Pobj_x, |
|
|
float |
Pobj_y, |
|
|
float |
Pobj_z, |
|
|
unsigned int |
j, |
|
|
float |
Plink_x, |
|
|
float |
Plink_y, |
|
|
float |
Plink_z |
|
) |
[inline] |
|
|
Performs inverse kinematics to solve for positioning Plink on link j to Pobj in base coordinates; if solution found, stores result in this posture and returns true.
Definition at line 95 of file PostureEngine.h. |
void PostureEngine::takeSnapshot |
( |
const WorldState * |
st |
) |
[virtual] |
|
void PostureEngine::takeSnapshot |
( |
|
) |
[virtual] |
|
void PostureEngine::update |
( |
unsigned int |
c, |
|
|
unsigned int |
l |
|
) |
[protected, virtual] |
|
|
Called at the beginning of each function which accesses ROBOOP computations - should make sure the ROBOOP structures are up to date with Tekkotsu structures.
This class will pull current values from WorldState, but it is expected that subclasses (i.e. PostureEngine) will want to provide their own joint values. Updates from link 1 through link l. - Parameters:
-
[in] | c | the chain to update |
[in] | l | the last link to update (later links in the chain are left untouched) |
Reimplemented from Kinematics.
Definition at line 323 of file PostureEngine.cc.
Referenced by solveLinkPosition(). |
Member Data Documentation
|
the table of outputs' values and weights, can be accessed through setOutputCmd() and getOutputCmd()
Definition at line 103 of file PostureEngine.h.
Referenced by avgdiff(), clear(), diff(), getBinSize(), getOutputCmd(), LoadBuffer(), maxdiff(), operator()(), SaveBuffer(), setAverage(), setCombine(), setOutputCmd(), setOverlay(), setUnderlay(), and takeSnapshot(). |
The documentation for this class was generated from the following files:
|