00001
00002 #ifndef INCLUDED_PostureMC_h
00003 #define INCLUDED_PostureMC_h
00004
00005 #include "MotionCommand.h"
00006 #include "PostureEngine.h"
00007 #include "MotionManager.h"
00008
00009 class WorldState;
00010
00011
00012
00013
00014
00015
00016
00017
00018 class PostureMC : public MotionCommand, public PostureEngine {
00019 public:
00020
00021 PostureMC() : MotionCommand(),PostureEngine(),dirty(true),tolerance(.01) { }
00022
00023 PostureMC(const char* filename) : MotionCommand(),PostureEngine(filename),dirty(true),tolerance(.01) { }
00024
00025 PostureMC(const WorldState* st) : MotionCommand(),PostureEngine(st),dirty(true),tolerance(.01) { }
00026
00027 virtual ~PostureMC() {}
00028
00029
00030
00031
00032
00033
00034
00035
00036 PostureMC& setDirty(bool d=true) { dirty=d; return *this; }
00037 bool isDirty() const {return dirty;}
00038 virtual PostureMC& setTolerance(float t) { tolerance=t; return *this; }
00039 virtual float getTolerance() { return tolerance; }
00040
00041
00042
00043
00044 virtual int updateOutputs() {
00045 for(unsigned int i=0; i<NumOutputs; i++)
00046 if(cmds[i].weight>0)
00047 motman->setOutput(this,i,cmds[i]);
00048 bool r=dirty; dirty=false; return r;
00049 }
00050 virtual int isDirty() { return dirty; }
00051
00052
00053
00054
00055
00056 virtual int isAlive() {
00057 if(dirty || getAutoPrune()==false)
00058 return true;
00059 PostureEngine tmp;
00060 tmp.takeSnapshot();
00061 return (maxdiff(tmp)>tolerance);
00062 }
00063
00064
00065
00066
00067 inline virtual void takeSnapshot() { dirty=true; PostureEngine::takeSnapshot(); }
00068 inline virtual void takeSnapshot(const WorldState* st) { dirty=true; PostureEngine::takeSnapshot(st); }
00069 inline virtual void clear() { dirty=true; PostureEngine::clear(); }
00070 inline virtual PostureEngine& setOverlay(const PostureEngine& pe) { dirty=true; PostureEngine::setOverlay(pe); return *this; }
00071 inline virtual PostureEngine& setUnderlay(const PostureEngine& pe) { dirty=true; PostureEngine::setUnderlay(pe); return *this; }
00072 inline virtual PostureEngine& setAverage(const PostureEngine& pe,float w=0.5) { dirty=true; PostureEngine::setAverage(pe,w); return *this; }
00073 inline virtual PostureEngine& setCombine(const PostureEngine& pe) { dirty=true; PostureEngine::setCombine(pe); return *this; }
00074 inline PostureEngine& setOutputCmd(unsigned int i, const OutputCmd& c) { dirty=true; PostureEngine::setOutputCmd(i,c); return *this; }
00075 inline virtual unsigned int LoadBuffer(const char buf[], unsigned int len) { dirty=true; return PostureEngine::LoadBuffer(buf,len); }
00076
00077
00078 protected:
00079 bool dirty;
00080 float tolerance;
00081
00082
00083
00084
00085
00086
00087
00088 };
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #endif