00001 00030 #ifndef _OBSTACLEAVOIDERTRANSPORT_H 00031 #define _OBSTACLEAVOIDERTRANSPORT_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 OBSTACLEAVOIDERTRANSPORT "ObstacleAvoiderTransport" 00041 // IDNUMBER is used to identify data events . IDNUMBER+1 is the info event. this 00042 // system will probably go away soon... 00043 //#define OBSTACLEAVOIDERTRANSPORTIDNUMBER 22 00044 00045 namespace WURDE { 00046 class Capability; 00047 class CommsManager; 00048 class Logger; 00049 00050 00051 00052 00053 class ObstacleAvoiderTransportInfoStruct { 00054 public: std::string source; 00055 Writable< bool > absolute; 00056 Writable< float > avoidanceRadius; 00057 Writable< float > maxTranslationVelocity; 00058 Writable< bool > goalHasLocation; 00059 MessageType mType; 00060 std::string target; 00061 Time timestamp; 00062 Writable< bool > goalHasTheta; 00063 Writable< bool > brake; 00064 Writable< float > maxRotationVelocity; 00065 Writable< Pose > goalPose; 00066 }; 00067 00068 00069 class ObstacleAvoiderTransportDataStruct { 00070 public: std::string source; 00071 bool pathObstructed; 00072 float angleToGoal; 00073 Time timestamp; 00074 float distanceToGoal; 00075 }; 00076 00082 class ObstacleAvoiderTransport : virtual public Capability { 00083 00084 public: 00090 explicit ObstacleAvoiderTransport(const std::string & streamname); 00091 00097 ObstacleAvoiderTransport(const ConnectionStrategy & strategy,const std::string & gblName); 00098 00104 ObstacleAvoiderTransport(const std::string & streamname,const std::string & gblName); 00105 00106 ~ObstacleAvoiderTransport(); 00107 00108 00112 void init(const std::string & streamname,const ConnectionStrategy & strategy, const std::string & gblName); 00113 00114 00119 ObstacleAvoiderTransportDataStruct data; 00120 00124 ObstacleAvoiderTransportInfoStruct info; 00125 00129 ObstacleAvoiderTransportInfoStruct requests; 00130 00131 //RobotObject imps 00132 void runUpdate(); 00133 void setManager(CommsManager *myManager_); 00134 void setCOMObject(COMBase *object){ myCOMObject = dynamic_cast<COMObject<ObstacleAvoiderTransportInfoStruct,ObstacleAvoiderTransportDataStruct> *> (object);} 00135 void disconnect(){if(myCOMObject){myCOMObject->disconnect();}} 00136 void activateSupplier(); 00137 void activateConsumer(); 00138 std::string getInterfaceName(){ return OBSTACLEAVOIDERTRANSPORT;} 00139 void setStreamName(const std::string & name); 00140 void setGlobalName(const std::string & name); 00141 bool newData(); 00142 bool newInfo(); 00143 void setAutoPing(const bool & val); 00144 void doPing(); 00145 // int getID(){return OBSTACLEAVOIDERTRANSPORTIDNUMBER;} 00146 00150 bool getQueueMode(){return m_queue;}; 00151 00155 void setQueueMode(const bool & val); 00156 00161 ObstacleAvoiderTransportDataStruct getNextData(); 00162 00167 ObstacleAvoiderTransportInfoStruct getNextInfo(); 00168 00172 ObstacleAvoiderTransportInfoStruct getNextRequest(){return getNextInfo();} 00173 00174 void publishData(); 00175 void publishInfo(); 00176 //void publishRequest(); 00177 00178 protected: 00179 COMObject<ObstacleAvoiderTransportInfoStruct, ObstacleAvoiderTransportDataStruct> *myCOMObject; 00180 00181 bool m_queue; 00182 00183 //notes that the object should be initialized as soon as a streamname is received 00184 bool m_initialize; 00185 std::queue<ObstacleAvoiderTransportDataStruct> m_dataVector; 00186 std::queue<ObstacleAvoiderTransportInfoStruct> m_infoVector; 00187 std::queue<ObstacleAvoiderTransportInfoStruct> m_requestVector; 00188 00189 }; 00190 00191 } 00192 00193 00194 #endif