Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 //-*-c++-*- 00002 #ifndef INCLUDED_VisualTargetTrans_h_ 00003 #define INCLUDED_VisualTargetTrans_h_ 00004 00005 #include "Events/EventRouter.h" 00006 #include "Events/VisionObjectEvent.h" 00007 #include "Shared/debuget.h" 00008 #include "Shared/WorldState.h" 00009 00010 //! causes a transition when a visual object is "close" 00011 class VisualTargetTrans : public Transition { 00012 public: 00013 //!constructor 00014 VisualTargetTrans(StateNode* destination, unsigned int source_id) 00015 : Transition(destination), sid(source_id), count(0) {} 00016 00017 //!starts listening for the object specified by the source id in the constructor 00018 virtual void DoStart() { 00019 //serr->printf("VisualTargetTrans::DoStart() - enter\n"); 00020 Transition::DoStart(); 00021 count=0; 00022 erouter->addListener(this,EventBase::visObjEGID,sid); 00023 //serr->printf("VisualTargetTrans::DoStart() - leave\n"); 00024 } 00025 00026 //!called by StateNode when it becomes inactive - undo whatever you did in Enable() 00027 virtual void DoStop() { 00028 //serr->printf("VisualTargetTrans::DoStop() - enter\n"); 00029 erouter->forgetListener(this); 00030 count=0; 00031 Transition::DoStop(); 00032 //serr->printf("VisualTargetTrans::DoStop() - leave\n"); 00033 } 00034 00035 //!if the object is "close", calls activate() 00036 virtual void processEvent(const EventBase& e) { 00037 //serr->printf("VisualTargetTrans::processEvent() - enter %d\n",get_time()); 00038 00039 if(e.getTypeID()==EventBase::deactivateETID) 00040 count=0; 00041 else 00042 count++; 00043 if(count>5) 00044 activate(); 00045 00046 //serr->printf("VisualTargetTrans::processEvent() - leave %d\n",get_time()); 00047 } 00048 00049 virtual std::string getName() const { return "VisualTargetTrans"; } 00050 00051 protected: 00052 //!Source ID of object to track 00053 unsigned int sid; 00054 //! number of frames for which we've seen the object 00055 unsigned int count; 00056 }; 00057 00058 /*! @file 00059 * @brief Defines VisualTargetTrans, which causes a transition when a visual object is seen for a few frames 00060 * @author ejt (Creator) 00061 * 00062 * $Author: ejt $ 00063 * $Name: tekkotsu-2_0 $ 00064 * $Revision: 1.9 $ 00065 * $State: Exp $ 00066 * $Date: 2003/12/08 00:21:02 $ 00067 */ 00068 00069 #endif
Tekkotsu v2.0 |
Generated Wed Jan 21 03:20:30 2004 by Doxygen 1.3.4 |