00001 00030 #ifndef _BUMPER_H 00031 #define _BUMPER_H 00032 #include <WritableType.H> 00033 #include <Capability.H> 00034 #include <COMObject.H> 00035 #include <queue> 00036 #include <vector> 00037 00038 // $Id: Type.H 66 2007-01-23 20:53:23Z fwph $ 00039 00040 #define BUMPER "Bumper" 00041 // IDNUMBER is used to identify data events . IDNUMBER+1 is the info event. this 00042 // system will probably go away soon... 00043 //#define BUMPERIDNUMBER 2 00044 00045 namespace WURDE { 00046 class Capability; 00047 class CommsManager; 00048 class Logger; 00049 00050 00051 00052 00053 class BumperInfoStruct { 00054 public: Writable< float > x_offset; 00055 std::string source; 00056 Writable< float > y_offset; 00057 Writable< float > phi_separation; 00058 std::string target; 00059 Writable< float > psi_offset; 00060 Time timestamp; 00061 Writable< float > x_separation; 00062 Writable< float > phi_offset; 00063 Writable< float > theta_separation; 00064 Writable< float > psi_separation; 00065 Writable< std::vector< Pose3D > > sensor_positions; 00066 Writable< float > y_separation; 00067 MessageType mType; 00068 Writable< bool > uniform; 00069 Writable< float > theta_offset; 00070 Writable< float > z_separation; 00071 Writable< float > z_offset; 00072 }; 00073 00074 00075 class BumperDataStruct { 00076 public: std::string source; 00077 Time timestamp; 00078 std::vector< bool > bumpers; 00079 bool bumped; 00080 }; 00081 00087 class Bumper : virtual public Capability { 00088 00089 public: 00095 explicit Bumper(const std::string & streamname); 00096 00102 Bumper(const ConnectionStrategy & strategy,const std::string & gblName); 00103 00109 Bumper(const std::string & streamname,const std::string & gblName); 00110 00111 ~Bumper(); 00112 00113 00117 void init(const std::string & streamname,const ConnectionStrategy & strategy, const std::string & gblName); 00118 00119 00124 BumperDataStruct data; 00125 00129 BumperInfoStruct info; 00130 00134 BumperInfoStruct requests; 00135 00136 //RobotObject imps 00137 void runUpdate(); 00138 void setManager(CommsManager *myManager_); 00139 void setCOMObject(COMBase *object){ myCOMObject = dynamic_cast<COMObject<BumperInfoStruct,BumperDataStruct> *> (object);} 00140 void disconnect(){if(myCOMObject){myCOMObject->disconnect();}} 00141 void activateSupplier(); 00142 void activateConsumer(); 00143 std::string getInterfaceName(){ return BUMPER;} 00144 void setStreamName(const std::string & name); 00145 void setGlobalName(const std::string & name); 00146 bool newData(); 00147 bool newInfo(); 00148 void setAutoPing(const bool & val); 00149 void doPing(); 00150 // int getID(){return BUMPERIDNUMBER;} 00151 00155 bool getQueueMode(){return m_queue;}; 00156 00160 void setQueueMode(const bool & val); 00161 00166 BumperDataStruct getNextData(); 00167 00172 BumperInfoStruct getNextInfo(); 00173 00177 BumperInfoStruct getNextRequest(){return getNextInfo();} 00178 00179 void publishData(); 00180 void publishInfo(); 00181 //void publishRequest(); 00182 00183 protected: 00184 COMObject<BumperInfoStruct, BumperDataStruct> *myCOMObject; 00185 00186 bool m_queue; 00187 00188 //notes that the object should be initialized as soon as a streamname is received 00189 bool m_initialize; 00190 std::queue<BumperDataStruct> m_dataVector; 00191 std::queue<BumperInfoStruct> m_infoVector; 00192 std::queue<BumperInfoStruct> m_requestVector; 00193 00194 }; 00195 00196 } 00197 00198 00199 #endif