Homepage Demos Overview Downloads Tutorials Reference
Credits
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Search

PostureEngine Class Reference

#include <PostureEngine.h>

Inheritance diagram for PostureEngine:

Inheritance graph
[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 12 of file PostureEngine.h.

Public Member Functions

 PostureEngine ()
 constructor

 PostureEngine (const char *filename)
 constructor, loads a position from a file - not necessarily quick!

virtual ~PostureEngine ()
 destructor

virtual void takeSnapshot ()
 sets the internal cmds to the current state of the outputs

virtual void clear ()
 sets all joints to unused

virtual PostureEnginesetOverlay (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 PostureEnginesetUnderlay (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 PostureEnginesetAverage (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 PostureEnginesetCombine (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 sum squared error between this and pe's output values for outputs which are both not unused

Output Accessors
NOT VIRTUAL! You should be able to call this to set outputs without checking out, just a peekMotion(). Theoretically.

PostureEnginesetOutputCmd (unsigned int i, const OutputCmd &c)
 sets output i to OutputCmd c, returns *this so you can chain them

OutputCmdgetOutputCmd (unsigned int i)
 returns output i, returns a reference so you can also set "through" this call.

const OutputCmdgetOutputCmd (unsigned int i) const
 returns output i

LoadSave
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.


Static Protected Member Functions

bool ChkAdvance (int res, const char **buf, unsigned int *len, const char *msg)
 used by LoadBuffer()/SaveBuffer(), checks to see if the amount read/written (res) is nonzero, increments buf, decrements len, or displays msg if is zero

bool ChkAdvance (int res, const char **buf, unsigned int *len, const char *msg, int arg1)
 used by LoadBuffer()/SaveBuffer(), checks to see if the amount read/written (res) is nonzero, increments buf, decrements len, or displays msg with arg1 if is zero


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]
 

constructor

Definition at line 15 of file PostureEngine.h.

PostureEngine::PostureEngine const char *  filename  )  [inline]
 

constructor, loads a position from a file - not necessarily quick!

Todo:
might want to make a library of common positions so they don't have to be loaded repeatedly from memstick

Definition at line 18 of file PostureEngine.h.

References LoadSave::LoadFile().

PostureEngine::~PostureEngine  )  [virtual]
 

destructor

Definition at line 5 of file PostureEngine.cc.


Member Function Documentation

float PostureEngine::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

Todo:
create a version which looks at weights? This doesn't use them.

Definition at line 95 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, OutputCmd::value, and OutputCmd::weight.

bool PostureEngine::ChkAdvance int  res,
const char **  buf,
unsigned int *  len,
const char *  msg,
int  arg1
[static, protected]
 

used by LoadBuffer()/SaveBuffer(), checks to see if the amount read/written (res) is nonzero, increments buf, decrements len, or displays msg with arg1 if is zero

Definition at line 216 of file PostureEngine.cc.

bool PostureEngine::ChkAdvance int  res,
const char **  buf,
unsigned int *  len,
const char *  msg
[static, protected]
 

used by LoadBuffer()/SaveBuffer(), checks to see if the amount read/written (res) is nonzero, increments buf, decrements len, or displays msg if is zero

Definition at line 205 of file PostureEngine.cc.

void PostureEngine::clear  )  [virtual]
 

sets all joints to unused

Reimplemented in PostureMC.

Definition at line 12 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, and OutputCmd::unset().

PostureEngine PostureEngine::createAverage const PostureEngine pe,
float  w = 0.5
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 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 69 of file PostureEngine.cc.

References setAverage().

PostureEngine PostureEngine::createCombine const PostureEngine pe  )  const [virtual]
 

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 80 of file PostureEngine.cc.

References setCombine().

PostureEngine PostureEngine::createOverlay const PostureEngine pe  )  const [virtual]
 

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 23 of file PostureEngine.cc.

References setOverlay().

PostureEngine PostureEngine::createUnderlay const PostureEngine pe  )  const [virtual]
 

sets joints of this which are equal to unused to pe, (layers this over pe) returns new PostureEngine

Definition at line 33 of file PostureEngine.cc.

References setUnderlay().

float PostureEngine::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

Todo:
create a version which looks at weights? This doesn't use them.

Definition at line 85 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, OutputCmd::value, and OutputCmd::weight.

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 119 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, ERS210Info::outputNames, and OutputCmd::weight.

const OutputCmd& PostureEngine::getOutputCmd unsigned int  i  )  const [inline]
 

returns output i

Definition at line 64 of file PostureEngine.h.

References cmds.

OutputCmd& PostureEngine::getOutputCmd unsigned int  i  )  [inline]
 

returns output i, returns a reference so you can also set "through" this call.

Definition at line 63 of file PostureEngine.h.

References cmds.

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 128 of file PostureEngine.cc.

References ChkAdvance(), clear(), cmds, ERS210Info::NumOutputs, ERS210Info::outputNameLen, ERS210Info::outputNames, and OutputCmd::set().

float PostureEngine::maxdiff const PostureEngine pe  )  const
 

returns the max sum squared error between this and pe's output values for outputs which are both not unused

Todo:
create a version which looks at weights? This doesn't use them.

Definition at line 107 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, OutputCmd::value, and OutputCmd::weight.

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 179 of file PostureEngine.cc.

References ChkAdvance(), cmds, ERS210Info::NumOutputs, ERS210Info::outputNames, and OutputCmd::weight.

PostureEngine & PostureEngine::setAverage const PostureEngine pe,
float  w = 0.5
[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 ::unusedJoint 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 45 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, OutputCmd::set(), OutputCmd::value, and OutputCmd::weight.

PostureEngine & PostureEngine::setCombine const PostureEngine pe  )  [virtual]
 

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

Reimplemented in PostureMC.

Definition at line 73 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, OutputCmd::value, and OutputCmd::weight.

PostureEngine& PostureEngine::setOutputCmd unsigned int  i,
const OutputCmd c
[inline]
 

sets output i to OutputCmd c, returns *this so you can chain them

Reimplemented in PostureMC.

Definition at line 62 of file PostureEngine.h.

References cmds.

PostureEngine & PostureEngine::setOverlay const PostureEngine pe  )  [virtual]
 

sets joints of this to all joints of pe which are not equal to unused (layers pe over this) stores into this

Reimplemented in PostureMC.

Definition at line 17 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, and OutputCmd::weight.

PostureEngine & PostureEngine::setUnderlay const PostureEngine pe  )  [virtual]
 

sets joints of this which are equal to unused to pe, (layers this over pe) stores into this

Reimplemented in PostureMC.

Definition at line 27 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, and OutputCmd::weight.

void PostureEngine::takeSnapshot  )  [virtual]
 

sets the internal cmds to the current state of the outputs

Reimplemented in EmergencyStopMC, and PostureMC.

Definition at line 7 of file PostureEngine.cc.

References cmds, ERS210Info::NumOutputs, WorldState::outputs, OutputCmd::set(), and state.


Member Data Documentation

OutputCmd PostureEngine::cmds[NumOutputs] [protected]
 

the table of outputs' values and weights, can be accessed through setOutputCmd() and getOutputCmd()

Definition at line 81 of file PostureEngine.h.


The documentation for this class was generated from the following files:
Tekkotsu v1.4
Generated Sat Jul 19 00:09:06 2003 by Doxygen 1.3.2