| 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/VisionEvent.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* source, StateNode* destination, VisionEventNS::VisionSourceID_t source_id) 00015 : Transition(source,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::visionEGID,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 VisionEventNS::VisionSourceID_t sid; 00054 unsigned int count; 00055 }; 00056 00057 /*! @file 00058 * @brief Defines VisualTargetTrans, which causes a transition when a visual object is seen for a few frames 00059 * @author ejt (Creator) 00060 * 00061 * $Author: ejt $ 00062 * $Name: tekkotsu-1_5 $ 00063 * $Revision: 1.5 $ 00064 * $State: Rel $ 00065 * $Date: 2003/10/03 03:40:23 $ 00066 */ 00067 00068 #endif
|
Tekkotsu v1.5 |
Generated Fri Oct 10 15:52:00 2003 by Doxygen 1.3.4 |