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

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     RedBallSID=0, //!< a red bean bag ball
00012     PinkBallSID,  //!< the plastic pink ball Aibos ship with
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
00017                   //!  reported to WorldModel
00018   };
00019 }
00020 
00021 //! Extends EventBase to also include location in the visual field and distance (though distance is not implimented yet)
00022 class VisionEvent : public EventBase {
00023  public:
00024   //! Constructor
00025   VisionEvent() : EventBase(EventBase::visionEGID,(unsigned int)-1,EventBase::statusETID,0),_cenX(0),_cenY(0),_distance(),_property(-1) {}
00026   //! Constructor, pass a type id and source id
00027   VisionEvent(EventTypeID_t tid, unsigned int sid) : EventBase(EventBase::visionEGID,sid,tid,0),_cenX(0),_cenY(0),_distance(),_property(-1) {}
00028   //! Constructor, pass the type id, source id, center X and center Y
00029   VisionEvent(EventTypeID_t tid, unsigned int sid, float cenX, float cenY) : EventBase(EventBase::visionEGID,sid,tid,0),_cenX(cenX),_cenY(cenY),_distance(),_property(-1) {}
00030   
00031   float getCenterX() const { return _cenX;} //!< returns the x coordinate
00032   VisionEvent& setCenterX(float cenX) { _cenX=cenX; return *this;} //!< sets the x coordinate
00033   
00034   float getCenterY() const { return _cenY;} //!< returns the y coordinate
00035   VisionEvent& setCenterY(float cenY) { _cenY=cenY; return *this;} //!< sets the y coordinate
00036 
00037   float getDistance() const { return _distance;} //!< returns the distance (not implemented)
00038   VisionEvent& setDistance(float dist) { _distance=dist; return *this;} //!< sets the distance
00039 
00040   int getProperty() const { return _property;} //!< returns the property
00041   VisionEvent& setProperty(int property) { _property=property; return *this;} //!< sets the property
00042       
00043   virtual unsigned int getBinSize() const {
00044     unsigned int used=EventBase::getBinSize();
00045     used+=creatorSize("EventBase::VisionEvent");
00046     used+=sizeof(_cenX);
00047     used+=sizeof(_cenY);
00048     used+=sizeof(_distance);
00049     used+=sizeof(_property);
00050     return used;
00051   }
00052 
00053   virtual unsigned int LoadBuffer(const char buf[], unsigned int len) {
00054     unsigned int origlen=len;
00055     unsigned int used;
00056     if(0==(used=EventBase::LoadBuffer(buf,len))) return 0;
00057     len-=used; buf+=used;
00058     if(0==(used=checkCreator("EventBase::VisionEvent",buf,len,true))) return 0;
00059     len-=used; buf+=used;
00060     if(0==(used=decode(_cenX,buf,len))) return 0;
00061     len-=used; buf+=used;
00062     if(0==(used=decode(_cenY,buf,len))) return 0;
00063     len-=used; buf+=used;
00064     if(0==(used=decode(_distance,buf,len))) return 0;
00065     len-=used; buf+=used;
00066     if(0==(used=decode(_property,buf,len))) return 0;
00067     len-=used; buf+=used;
00068     return origlen-len; 
00069   }
00070 
00071   virtual unsigned int SaveBuffer(char buf[], unsigned int len) const {
00072     unsigned int origlen=len;
00073     unsigned int used;
00074     if(0==(used=EventBase::SaveBuffer(buf,len))) return 0;
00075     len-=used; buf+=used;
00076     if(0==(used=saveCreator("EventBase::VisionEvent",buf,len))) return 0;
00077     len-=used; buf+=used;
00078     if(0==(used=encode(_cenX,buf,len))) return 0;
00079     len-=used; buf+=used;
00080     if(0==(used=encode(_cenY,buf,len))) return 0;
00081     len-=used; buf+=used;
00082     if(0==(used=encode(_distance,buf,len))) return 0;
00083     len-=used; buf+=used;
00084     if(0==(used=encode(_property,buf,len))) return 0;
00085     len-=used; buf+=used;
00086     return origlen-len;
00087   }
00088 
00089  protected:
00090   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
00091   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
00092   float _distance; //!< distance from snout to object in millimeters.
00093   int _property; //!< some property, depending on the SID
00094 };
00095 
00096 /*! @file
00097  * @brief Provides information about objects recognized in the camera image
00098  * @author alokl (Creator)
00099  *
00100  * $Author: ejt $
00101  * $Name: tekkotsu-1_4_1 $
00102  * $Revision: 1.7 $
00103  * $State: Exp $
00104  * $Date: 2003/06/12 23:41:40 $
00105  */
00106 
00107 #endif

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