Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

VisualTargetTrans.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_VisualTargetTrans_h_
00003 #define INCLUDED_VisualTargetTrans_h_
00004 
00005 #include "Events/EventRouter.h"
00006 #include "Shared/debuget.h"
00007 #include "Shared/WorldState.h"
00008 
00009 //! causes a transition when a visual object has been seen for at least 6 camera frames
00010 class VisualTargetTrans : public Transition {
00011 public:
00012   //!constructor
00013   VisualTargetTrans(StateNode* destination, unsigned int source_id)
00014     : Transition(destination), sid(source_id), count(0) {}
00015 
00016   //!constructor
00017   VisualTargetTrans(const std::string& name, StateNode* destination, unsigned int source_id)
00018     : Transition(name,destination), sid(source_id), count(0) {}
00019 
00020   //!starts listening for the object specified by the source id in the constructor
00021   virtual void postStart() {
00022     Transition::postStart();
00023     count=0;
00024     erouter->addListener(this,EventBase::visObjEGID,sid);
00025   }
00026 
00027   //!if the object is "close", calls fire()
00028   virtual void doEvent() {
00029     //serr->printf("VisualTargetTrans::doEvent() - enter %d\n",get_time());
00030 
00031     if(event->getTypeID()==EventBase::deactivateETID)
00032       count=0;
00033     else
00034       count++;
00035     if(count>5)
00036       fire(*event);
00037 
00038     //serr->printf("VisualTargetTrans::doEvent() - leave %d\n",get_time());
00039   }
00040 
00041 protected:
00042   //!Source ID of object to track
00043   unsigned int sid;
00044   //! number of frames for which we've seen the object
00045   unsigned int count;
00046 };
00047 
00048 /*! @file
00049  * @brief Defines VisualTargetTrans, which causes a transition when a visual object has been seen for at least 6 camera frames
00050  * @author ejt (Creator)
00051  */
00052 
00053 #endif

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