Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

LocomotionEvent.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_LocomotionEvent_h_
00003 #define INCLUDED_LocomotionEvent_h_
00004 
00005 #include "EventBase.h"
00006 #include <iostream>
00007 
00008 //! Gives updates regarding the current movement of the robot through the world
00009 /*! An activate event will be sent when a potential source of motion is created,
00010  *  and a deactivate when it is destroyed.  Status events will be sent at any
00011  *  change of direction/speed.
00012  *
00013  *  The source ID field will hold the MotionManager::MC_ID of the sending MotionCommand
00014  */
00015 class LocomotionEvent : public EventBase {
00016  public:
00017 
00018   //! @name Constructors
00019 
00020   //! constructor
00021   LocomotionEvent() : EventBase(),x(0),y(0),a(0) {}
00022   LocomotionEvent(EventGeneratorID_t gid, size_t sid, EventTypeID_t tid, unsigned int dur=0) : EventBase(gid,sid,tid,dur),x(0),y(0),a(0) {}
00023   LocomotionEvent(EventGeneratorID_t gid, size_t 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) {}
00024   virtual EventBase* clone() const { return new LocomotionEvent(*this); }
00025   //@}
00026 
00027   virtual unsigned int getClassTypeID() const { return autoRegisterLocomotionEvent; }
00028 
00029   //! Allows you to set the new X, Y, and A components
00030   LocomotionEvent& setXYA(float X, float Y, float A) {
00031     x=X;
00032     y=Y;
00033     a=A;
00034     return *this;
00035   }
00036 
00037   virtual std::string getDescription(bool showTypeSpecific=true, unsigned int verbosity=0) const;
00038 
00039   virtual unsigned int getBinSize() const;
00040   virtual unsigned int loadBinaryBuffer(const char buf[], unsigned int len);
00041   virtual unsigned int saveBinaryBuffer(char buf[], unsigned int len) const;
00042   virtual void loadXML(xmlNode* node);
00043   virtual void saveXML(xmlNode * node) const;
00044 
00045   //!< Returns true if this event indicates motion has stopped (x,y,a are all essentially zero; may not be exactly zero in Mirage)
00046   virtual bool isStop() const { return fabs(x) < 1e-3 && fabs(y) < 1e-3 && fabs(a) < 1e-3;}
00047 
00048   float x; //!< the new x component (body relative)
00049   float y; //!< the new y component (body relative)
00050   float a; //!< the new angular component (body relative)
00051 
00052 protected:
00053   //! causes class type id to automatically be registered with EventBase's FamilyFactory (getTypeRegistry())
00054   static const EventBase::classTypeID_t autoRegisterLocomotionEvent;
00055 };
00056 
00057 /*! @file
00058  * @brief Describes LocomotionEvent, which gives updates regarding the current movement of the robot through the world
00059  * @author ejt (Creator)
00060  */
00061 
00062 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:44 2016 by Doxygen 1.6.3