Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

RecordRange.cc

Go to the documentation of this file.
00001 #include "Behaviors/BehaviorBase.h"
00002 #include "Events/EventRouter.h"
00003 #include "Motion/PIDMC.h"
00004 #include "IPC/SharedObject.h"
00005 
00006 class RecordRange : public BehaviorBase {
00007 public:
00008   RecordRange() : BehaviorBase("RecordRange"), pidID(MotionManager::invalid_MC_ID) {
00009     for(unsigned int i=0; i<NumOutputs; ++i)
00010       maxs[i]=mins[i]=0;
00011   }
00012   virtual void doStart() {
00013     BehaviorBase::doStart();
00014     pidID = motman->addPersistentMotion(SharedObject<PIDMC>(0));
00015     erouter->addListener(this,EventBase::sensorEGID);
00016   }
00017   virtual void doStop() {
00018     motman->removeMotion(pidID);
00019     for(unsigned int i=0; i<NumOutputs; ++i)
00020       std::cout << i << " " << outputNames[i] << ": " << mins[i] << ' ' << maxs[i] << std::endl;
00021     BehaviorBase::doStop();
00022   }
00023   virtual void doEvent() {
00024     for(unsigned int i=0; i<NumOutputs; ++i) {
00025       if(state->outputs[i]<mins[i])
00026         mins[i]=state->outputs[i];
00027       if(state->outputs[i]>maxs[i])
00028         maxs[i]=state->outputs[i];
00029     }
00030   }
00031 protected:
00032   MotionManager::MC_ID pidID;
00033   float maxs[NumOutputs];
00034   float mins[NumOutputs];
00035 };
00036 
00037 REGISTER_BEHAVIOR_MENU_OPT(RecordRange,"Background Behaviors",BEH_NONEXCLUSIVE);
00038 
00039 /*! @file
00040  * @brief Defines RecordRange, a small utility which disables all joint power and records the maximum and minimum positions
00041  * @author ejt (Creator)
00042  */

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:49 2016 by Doxygen 1.6.3