Homepage Demos Overview Downloads Tutorials Reference
Credits
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Search

EvtRptBehavior.cc

Go to the documentation of this file.
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,
00011           VisionEventNS::MarkersSID);
00012 
00013   vision->enableEvents(VisionEventNS::MarkersSID);
00014   //vision->enableEvents(VisionEventNS::RedBallSID);
00015   //vision->enableEvents(VisionEventNS::PinkBallSID);
00016 }
00017 
00018 void EvtRptBehavior::DoStop() {
00019   vision->disableEvents(VisionEventNS::MarkersSID);
00020   //vision->disableEvents(VisionEventNS::RedBallSID);
00021   //vision->disableEvents(VisionEventNS::PinkBallSID);
00022 
00023   erouter->forgetListener(this);
00024   BehaviorBase::DoStop();
00025 }
00026 
00027 //this could be cleaned up event-wise (only use a timer when out of view)
00028 void EvtRptBehavior::processEvent(const EventBase& event) {
00029 
00030   if(event.getGeneratorID() == EventBase::visionEGID &&
00031      event.getTypeID() == EventBase::statusETID) {
00032     float horiz, vert;
00033     int prop;
00034 
00035     horiz = static_cast<const VisionEvent*>(&event)->getCenterX();
00036     vert  = static_cast<const VisionEvent*>(&event)->getCenterY();
00037     prop  = static_cast<const VisionEvent*>(&event)->getProperty();
00038 
00039     if(event.getSourceID() == VisionEventNS::RedBallSID)
00040       cout << "red  BALL seen";
00041     else if(event.getSourceID()==VisionEventNS::PinkBallSID)
00042       cout << "pink BALL seen";
00043     else if(event.getSourceID()==VisionEventNS::MarkersSID)
00044       cout << "MARKER " << prop << " seen";
00045 
00046     cout << " at h=" << horiz << " v=" << vert << endl;
00047   }
00048   else
00049   if(event.getGeneratorID() == EventBase::locomotionEGID &&
00050      event.getTypeID() == EventBase::statusETID) {
00051     float x,y,a;
00052 
00053     x = static_cast<const LocomotionEvent*>(&event)->x;
00054     y = static_cast<const LocomotionEvent*>(&event)->y;
00055     a = static_cast<const LocomotionEvent*>(&event)->a;
00056 
00057     cout << "MOTION dx=" << x << " dy=" << y << " da=" << a << endl;
00058   }
00059 }
00060       
00061 /*! @file
00062  * @brief Implements EvtRptBehavior, which couts information about events it sees
00063  * @author tss (Creator)
00064  */
00065 
00066 

Tekkotsu v1.4
Generated Sat Jul 19 00:06:30 2003 by Doxygen 1.3.2