Homepage Demos Overview Downloads Tutorials Reference
Credits

VisionEvent.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_VisionEvent_h
00003 #define INCLUDED_VisionEvent_h
00004 
00005 #include "EventBase.h"
00006 
00007 //! contains source IDs for the objects we can recognize
00008 namespace VisionEventNS {
00009   //! contains source IDs for the objects we can recognize
00010   enum VisionSourceID_t {
00011     PinkBallSID=0,//!< the plastic pink ball Aibos ship with
00012     RedBallSID=0, //!< a red bean bag ball
00013     HandSID,      //!< Optimized for Ethan's hand, a pasty white thing.
00014     ThumbsupSID,  //!< Recognizes when Ethan is giving a thumbs up.
00015     ThingSID,     //!< Other stuff
00016     MarkersSID    //!< never actually generated: data directly reported to WorldModel
00017   };
00018 }
00019 
00020 //! Extends EventBase to also include location in the visual field and distance (though distance is not implimented yet)
00021 class VisionEvent : public EventBase {
00022  public:
00023   //! Constructor
00024   VisionEvent() : EventBase(EventBase::visionEGID,(unsigned int)-1,EventBase::statusETID,0),_cenX(0),_cenY(0),_distance(),_property(-1) {}
00025   //! Constructor, pass a type id and source id
00026   VisionEvent(EventTypeID_t tid, unsigned int sid) : EventBase(EventBase::visionEGID,sid,tid,0),_cenX(0),_cenY(0),_distance(),_property(-1) {}
00027   //! Constructor, pass the type id, source id, center X and center Y
00028   VisionEvent(EventTypeID_t tid, unsigned int sid, float cenX, float cenY) : EventBase(EventBase::visionEGID,sid,tid,0),_cenX(cenX),_cenY(cenY),_distance(),_property(-1) {}
00029   
00030   float getCenterX() const { return _cenX;} //!< returns the x coordinate
00031   VisionEvent& setCenterX(float cenX) { _cenX=cenX; return *this;} //!< sets the x coordinate
00032   
00033   float getCenterY() const { return _cenY;} //!< returns the y coordinate
00034   VisionEvent& setCenterY(float cenY) { _cenY=cenY; return *this;} //!< sets the y coordinate
00035 
00036   float getDistance() const { return _distance;} //!< returns the distance (not implemented)
00037   VisionEvent& setDistance(float dist) { _distance=dist; return *this;} //!< sets the distance
00038 
00039   int getProperty() const { return _property;} //!< returns the property
00040   VisionEvent& setProperty(int property) { _property=property; return *this;} //!< sets the property
00041       
00042   virtual unsigned int getBinSize() const {
00043     unsigned int used=EventBase::getBinSize();
00044     used+=creatorSize("EventBase::VisionEvent");
00045     used+=sizeof(_cenX);
00046     used+=sizeof(_cenY);
00047     used+=sizeof(_distance);
00048     used+=sizeof(_property);
00049     return used;
00050   }
00051 
00052   virtual unsigned int LoadBuffer(const char buf[], unsigned int len) {
00053     unsigned int origlen=len;
00054     unsigned int used;
00055     if(0==(used=EventBase::LoadBuffer(buf,len))) return 0;
00056     len-=used; buf+=used;
00057     if(0==(used=checkCreator("EventBase::VisionEvent",buf,len,true))) return 0;
00058     len-=used; buf+=used;
00059     if(0==(used=decode(_cenX,buf,len))) return 0;
00060     len-=used; buf+=used;
00061     if(0==(used=decode(_cenY,buf,len))) return 0;
00062     len-=used; buf+=used;
00063     if(0==(used=decode(_distance,buf,len))) return 0;
00064     len-=used; buf+=used;
00065     if(0==(used=decode(_property,buf,len))) return 0;
00066     len-=used; buf+=used;
00067     return origlen-len; 
00068   }
00069 
00070   virtual unsigned int SaveBuffer(char buf[], unsigned int len) const {
00071     unsigned int origlen=len;
00072     unsigned int used;
00073     if(0==(used=EventBase::SaveBuffer(buf,len))) return 0;
00074     len-=used; buf+=used;
00075     if(0==(used=saveCreator("EventBase::VisionEvent",buf,len))) return 0;
00076     len-=used; buf+=used;
00077     if(0==(used=encode(_cenX,buf,len))) return 0;
00078     len-=used; buf+=used;
00079     if(0==(used=encode(_cenY,buf,len))) return 0;
00080     len-=used; buf+=used;
00081     if(0==(used=encode(_distance,buf,len))) return 0;
00082     len-=used; buf+=used;
00083     if(0==(used=encode(_property,buf,len))) return 0;
00084     len-=used; buf+=used;
00085     return origlen-len;
00086   }
00087 
00088  protected:
00089   float _cenX; //!< a value representing location in visual field - from -1 if on the left edge to 1 if it's on the right edge
00090   float _cenY; //!< a value representing location in visual field - from -1 if on the bottom edge to 1 if it's on the top edge
00091   float _distance; //!< distance from snout to object in millimeters.
00092   int _property; //!< some property, depending on the SID
00093 };
00094 
00095 /*! @file
00096  * @brief Provides information about objects recognized in the camera image
00097  * @author alokl (Creator)
00098  *
00099  * $Author: ejt $
00100  * $Name: tekkotsu-1_5 $
00101  * $Revision: 1.9 $
00102  * $State: Rel $
00103  * $Date: 2003/09/12 21:38:20 $
00104  */
00105 
00106 #endif

Tekkotsu v1.5
Generated Fri Oct 10 15:52:00 2003 by Doxygen 1.3.4