Homepage Demos Overview Downloads Tutorials Reference
Credits

PostureMC Class Reference

#include <PostureMC.h>

Inheritance diagram for PostureMC:

Inheritance graph
[legend]
List of all members.

Detailed Description

a MotionCommand shell for PostureEngine

Will autoprune by default once it reaches the target pose.

If you want to keep it alive so your behavior can use the posture to move around, either call setAutoPrune(false), or pass false to the MotionManager::addMotion() function.

Definition at line 16 of file PostureMC.h.

Public Member Functions

 PostureMC ()
 constructor

 PostureMC (const char *filename)
 constructor, loads from filename

virtual ~PostureMC ()
 destructor

New Stuff
PostureMCsetDirty (bool d=true)
 call this if you call PostureEngine::setOutputCmd(), that doesn't know about dirty flags

bool isDirty () const
 if you want to check the dirty flag

virtual PostureMCsetTolerance (float t)
 sets tolerance, returns *this

virtual float getTolerance ()
 returns tolerance

MotionCommand Stuff
virtual int updateOutputs ()
 is called once per update cycle, can do any processing you need to change your priorities or set output commands on the MotionManager

virtual int isDirty ()
 not used by MotionManager at the moment, but could be used to reduce recomputation, and you may find it useful

virtual int isAlive ()
 returns non-zero (true) if PostureEngine::maxdiff() between this and the current position is over tolerance

PostureEngine Stuff
Had to override stuff to manage a dirty flag

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 PostureEnginesetUnderlay (const PostureEngine &pe)
 sets joints of this which are equal to unused to pe, (layers this over pe) stores into this

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

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

virtual unsigned int LoadBuffer (const char buf[], unsigned int len)
 Load from a saved buffer.


Protected Attributes

bool dirty
 true if changes have been made since last updateOutputs()

float tolerance
 when autopruning, if the maxdiff() of this posture and the robot's current position is below this value, isAlive() will be false, defaults to 0.01 (5.7 degree error)


Constructor & Destructor Documentation

PostureMC::PostureMC  )  [inline]
 

constructor

Definition at line 19 of file PostureMC.h.

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

constructor, loads from filename

Definition at line 21 of file PostureMC.h.

virtual PostureMC::~PostureMC  )  [inline, virtual]
 

destructor

Definition at line 23 of file PostureMC.h.


Member Function Documentation

virtual void PostureMC::clear  )  [inline, virtual]
 

sets all joints to unused

Reimplemented from PostureEngine.

Definition at line 64 of file PostureMC.h.

virtual float PostureMC::getTolerance  )  [inline, virtual]
 

returns tolerance

Definition at line 35 of file PostureMC.h.

virtual int PostureMC::isAlive  )  [inline, virtual]
 

returns non-zero (true) if PostureEngine::maxdiff() between this and the current position is over tolerance

This is handy so you can set to have the robot go to a position and then automatically remove the MotionCommand when it gets there - but beware fighting Postures which average out and neither succeeds

Implements MotionCommand.

Definition at line 52 of file PostureMC.h.

virtual int PostureMC::isDirty  )  [inline, virtual]
 

not used by MotionManager at the moment, but could be used to reduce recomputation, and you may find it useful

Returns:
zero if none of the commands have changed since last getJointCmd(), else non-zero

Implements MotionCommand.

Definition at line 46 of file PostureMC.h.

bool PostureMC::isDirty  )  const [inline]
 

if you want to check the dirty flag

Definition at line 33 of file PostureMC.h.

virtual unsigned int PostureMC::LoadBuffer const char  buf[],
unsigned int  len
[inline, 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

Reimplemented from PostureEngine.

Definition at line 70 of file PostureMC.h.

virtual PostureEngine& PostureMC::setAverage const PostureEngine pe,
float  w = 0.5
[inline, 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 from PostureEngine.

Definition at line 67 of file PostureMC.h.

virtual PostureEngine& PostureMC::setCombine const PostureEngine pe  )  [inline, 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 from PostureEngine.

Definition at line 68 of file PostureMC.h.

PostureMC& PostureMC::setDirty bool  d = true  )  [inline]
 

call this if you call PostureEngine::setOutputCmd(), that doesn't know about dirty flags

Definition at line 32 of file PostureMC.h.

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

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

Reimplemented from PostureEngine.

Definition at line 69 of file PostureMC.h.

Referenced by BatteryMonitorBehavior::setFlipper().

virtual PostureEngine& PostureMC::setOverlay const PostureEngine pe  )  [inline, virtual]
 

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

Reimplemented from PostureEngine.

Definition at line 65 of file PostureMC.h.

virtual PostureMC& PostureMC::setTolerance float  t  )  [inline, virtual]
 

sets tolerance, returns *this

Definition at line 34 of file PostureMC.h.

virtual PostureEngine& PostureMC::setUnderlay const PostureEngine pe  )  [inline, virtual]
 

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

Reimplemented from PostureEngine.

Definition at line 66 of file PostureMC.h.

virtual void PostureMC::takeSnapshot  )  [inline, virtual]
 

sets the internal cmds to the current state of the outputs

Reimplemented from PostureEngine.

Reimplemented in EmergencyStopMC.

Definition at line 63 of file PostureMC.h.

virtual int PostureMC::updateOutputs  )  [inline, virtual]
 

is called once per update cycle, can do any processing you need to change your priorities or set output commands on the MotionManager

Returns:
zero if no changes were made, non-zero otherwise
See also:
RobotInfo::NumFrames

RobotInfo::FrameTime

Implements MotionCommand.

Reimplemented in EmergencyStopMC.

Definition at line 40 of file PostureMC.h.

Referenced by EmergencyStopMC::updateOutputs().


Member Data Documentation

bool PostureMC::dirty [protected]
 

true if changes have been made since last updateOutputs()

Definition at line 74 of file PostureMC.h.

Referenced by clear(), isAlive(), isDirty(), LoadBuffer(), PostureMC(), setAverage(), setCombine(), setDirty(), setOutputCmd(), setOverlay(), setUnderlay(), takeSnapshot(), and updateOutputs().

float PostureMC::tolerance [protected]
 

when autopruning, if the maxdiff() of this posture and the robot's current position is below this value, isAlive() will be false, defaults to 0.01 (5.7 degree error)

Definition at line 75 of file PostureMC.h.

Referenced by getTolerance(), isAlive(), PostureMC(), and setTolerance().


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

Tekkotsu v2.1
Generated Tue Mar 16 23:22:20 2004 by Doxygen 1.3.5