Homepage Demos Overview Downloads Tutorials Reference
Credits

LocomotionEvent.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_LocomotionEvent_h_
00002 #define INCLUDED_LocomotionEvent_h_
00003 
00004 #include "EventBase.h"
00005 
00006 //! Gives updates regarding the current movement of the robot through the world
00007 /*! An activate event will be sent when a potential source of motion is created,
00008  *  and a deactivate when it is destroyed.  Status events will be sent at any
00009  *  change of direction/speed.
00010  *
00011  *  The source ID field will hold the MotionManager::MC_ID of the sending MotionCommand
00012  */
00013 class LocomotionEvent : public EventBase {
00014  public:
00015 
00016   //! @name Constructors
00017 
00018   //! constructor
00019   LocomotionEvent() : EventBase(),x(0),y(0),a(0) {}
00020   LocomotionEvent(EventGeneratorID_t gid, unsigned int sid, EventTypeID_t tid, unsigned int dur=0) : EventBase(gid,sid,tid,dur),x(0),y(0),a(0) {}
00021   LocomotionEvent(EventGeneratorID_t gid, unsigned int sid, EventTypeID_t tid, unsigned int dur, const std::string& n, float mag) : EventBase(gid,sid,tid,dur,n,mag),x(0),y(0),a(0) {}
00022   //@}
00023 
00024   //! Allows you to set the new X, Y, and A components
00025   LocomotionEvent& setXYA(float X, float Y, float A) {
00026     x=X;
00027     y=Y;
00028     a=A;
00029     return *this;
00030   }
00031   
00032   virtual unsigned int getBinSize() const {
00033     unsigned int used=EventBase::getBinSize();
00034     used+=creatorSize("EventBase::LocomotionEvent");
00035     used+=sizeof(x);
00036     used+=sizeof(y);
00037     used+=sizeof(a);
00038     return used;
00039   }
00040 
00041   virtual unsigned int LoadBuffer(const char buf[], unsigned int len) {
00042     unsigned int origlen=len;
00043     unsigned int used;
00044     if(0==(used=EventBase::LoadBuffer(buf,len))) return 0;
00045     len-=used; buf+=used;
00046     if(0==(used=checkCreator("EventBase::LocomotionEvent",buf,len,true))) return 0;
00047     len-=used; buf+=used;
00048     if(0==(used=decode(x,buf,len))) return 0;
00049     len-=used; buf+=used;
00050     if(0==(used=decode(y,buf,len))) return 0;
00051     len-=used; buf+=used;
00052     if(0==(used=decode(a,buf,len))) return 0;
00053     len-=used; buf+=used;
00054     return origlen-len; 
00055   }
00056 
00057   virtual unsigned int SaveBuffer(char buf[], unsigned int len) const {
00058     unsigned int origlen=len;
00059     unsigned int used;
00060     if(0==(used=EventBase::SaveBuffer(buf,len))) return 0;
00061     len-=used; buf+=used;
00062     if(0==(used=saveCreator("EventBase::LocomotionEvent",buf,len))) return 0;
00063     len-=used; buf+=used;
00064     if(0==(used=encode(x,buf,len))) return 0;
00065     len-=used; buf+=used;
00066     if(0==(used=encode(y,buf,len))) return 0;
00067     len-=used; buf+=used;
00068     if(0==(used=encode(a,buf,len))) return 0;
00069     len-=used; buf+=used;
00070     return origlen-len;
00071   }
00072 
00073   float x; //!< the new x component (body relative)
00074   float y; //!< the new y component (body relative)
00075   float a; //!< the new angular component (body relative)
00076 };
00077 
00078 /*! @file
00079  * @brief Defines LocomotionEvent, which gives updates regarding the current movement of the robot through the world
00080  * @author ejt (Creator)
00081  *
00082  * $Author: ejt $
00083  * $Name: tekkotsu-2_1 $
00084  * $Revision: 1.5 $
00085  * $State: Rel $
00086  * $Date: 2003/09/25 15:27:10 $
00087  */
00088 
00089 #endif

Tekkotsu v2.1
Generated Tue Mar 16 23:19:14 2004 by Doxygen 1.3.5