| Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 #include "EvtRptBehavior.h" 00002 #include "Events/EventRouter.h" 00003 #include "Events/VisionEvent.h" 00004 #include "Events/LocomotionEvent.h" 00005 #include "Vision/Vision.h" 00006 00007 void EvtRptBehavior::DoStart() { 00008 BehaviorBase::DoStart(); 00009 erouter->addListener(this,EventBase::locomotionEGID); 00010 erouter->addListener(this,EventBase::visionEGID,VisionEventNS::MarkersSID); 00011 } 00012 00013 void EvtRptBehavior::DoStop() { 00014 erouter->forgetListener(this); 00015 BehaviorBase::DoStop(); 00016 } 00017 00018 //this could be cleaned up event-wise (only use a timer when out of view) 00019 void EvtRptBehavior::processEvent(const EventBase& event) { 00020 00021 if(event.getGeneratorID() == EventBase::visionEGID && 00022 event.getTypeID() == EventBase::statusETID) { 00023 float horiz, vert; 00024 int prop; 00025 00026 horiz = static_cast<const VisionEvent*>(&event)->getCenterX(); 00027 vert = static_cast<const VisionEvent*>(&event)->getCenterY(); 00028 prop = static_cast<const VisionEvent*>(&event)->getProperty(); 00029 00030 if(event.getSourceID() == VisionEventNS::RedBallSID) 00031 cout << "red BALL seen"; 00032 else if(event.getSourceID()==VisionEventNS::PinkBallSID) 00033 cout << "pink BALL seen"; 00034 else if(event.getSourceID()==VisionEventNS::MarkersSID) 00035 cout << "MARKER " << prop << " seen"; 00036 00037 cout << " at h=" << horiz << " v=" << vert << endl; 00038 } 00039 else 00040 if(event.getGeneratorID() == EventBase::locomotionEGID && 00041 event.getTypeID() == EventBase::statusETID) { 00042 float x,y,a; 00043 00044 x = static_cast<const LocomotionEvent*>(&event)->x; 00045 y = static_cast<const LocomotionEvent*>(&event)->y; 00046 a = static_cast<const LocomotionEvent*>(&event)->a; 00047 00048 cout << "MOTION dx=" << x << " dy=" << y << " da=" << a << endl; 00049 } 00050 } 00051 00052 /*! @file 00053 * @brief Implements EvtRptBehavior, which couts information about events it sees 00054 * @author tss (Creator) 00055 */ 00056 00057
|
Tekkotsu v1.5 |
Generated Fri Oct 10 15:51:58 2003 by Doxygen 1.3.4 |