| Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 //-*-c++-*- 00002 #ifndef INCLUDED_VisualTargetCloseTrans_h_ 00003 #define INCLUDED_VisualTargetCloseTrans_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 VisualTargetCloseTrans : public Transition { 00012 public: 00013 //!constructor 00014 VisualTargetCloseTrans(StateNode* source, StateNode* destination, VisionEventNS::VisionSourceID_t source_id) : Transition(source,destination), sid(source_id) {} 00015 00016 //!starts listening for the object specified by the source id in the constructor 00017 virtual void DoStart() { Transition::DoStart(); erouter->addListener(this,EventBase::visionEGID,sid); } 00018 00019 //!called by StateNode when it becomes inactive - undo whatever you did in Enable() 00020 virtual void DoStop() { erouter->forgetListener(this); Transition::DoStop(); } 00021 00022 //!if the object is "close", calls activate() 00023 virtual void processEvent(const EventBase& e) { 00024 const VisionEvent* ve=dynamic_cast<const VisionEvent*>(&e); 00025 ASSERTRET(ve!=NULL,"Casting error"); 00026 float x=ve->getCenterX(); 00027 float y=ve->getCenterY(); 00028 if(x*x+y*y<0.02f && state->sensors[IRDistOffset]<300) 00029 activate(); 00030 } 00031 00032 virtual std::string getName() const { return "VisualTargetCloseTrans"; } 00033 00034 protected: 00035 //!Source ID of object to track 00036 VisionEventNS::VisionSourceID_t sid; 00037 }; 00038 00039 /*! @file 00040 * @brief Defines VisualTargetCloseTrans, which causes a transition when a visual object is "close" 00041 * @author ejt (Creator) 00042 * 00043 * $Author: ejt $ 00044 * $Name: tekkotsu-1_5 $ 00045 * $Revision: 1.5 $ 00046 * $State: Rel $ 00047 * $Date: 2003/09/25 15:26:57 $ 00048 */ 00049 00050 #endif
|
Tekkotsu v1.5 |
Generated Fri Oct 10 15:52:00 2003 by Doxygen 1.3.4 |