p_driver.h

Go to the documentation of this file.
00001 #ifndef _STAGE_PLAYER_DRIVER_H
00002 #define _STAGE_PLAYER_DRIVER_H
00003 
00004 #include <unistd.h>
00005 #include <string.h>
00006 #include <math.h>
00007 
00008 #include <libplayercore/playercore.h>
00009 
00010 #include "stage_internal.h"
00011 #include "stg_time.h"
00012 
00013 #define DRIVER_ERROR(X) printf( "Stage driver error: %s\n", X )
00014 
00015 // foward declare;
00016 class Interface;
00017 
00018 class StgDriver : public Driver
00019 {
00020  public:
00021   // Constructor; need that
00022   StgDriver(ConfigFile* cf, int section);
00023   
00024   // Destructor
00025   ~StgDriver(void);
00026   
00027   // Must implement the following methods.
00028   virtual int Setup();
00029   virtual int Shutdown();
00030   virtual int ProcessMessage(MessageQueue* resp_queue, 
00031                              player_msghdr * hdr, 
00032                              void * data);
00033   virtual int Subscribe(player_devaddr_t addr);
00034   virtual int Unsubscribe(player_devaddr_t addr);
00035     
00038   virtual void Update();
00039 
00041   static stg_world_t* world;
00042   
00044   Interface* LookupDevice( player_devaddr_t addr );
00045   
00046   stg_model_t* LocateModel( char* basename, 
00047                             player_devaddr_t* addr,
00048                             stg_model_initializer_t init );
00049   
00050  protected: 
00051   
00053   GPtrArray* devices;  
00054 };
00055 
00056 
00057 class Interface
00058 {
00059  public:
00060   Interface(player_devaddr_t addr,  
00061             StgDriver* driver,
00062             ConfigFile* cf, 
00063             int section );
00064   
00065   virtual ~Interface( void ){ /* TODO: clean up*/ };
00066 
00067   player_devaddr_t addr;
00068   stg_model_t* mod;
00069   double last_publish_time;
00070   
00071   StgDriver* driver; // the driver instance that created this device
00072   
00073   virtual int ProcessMessage(MessageQueue* resp_queue,
00074                              player_msghdr_t* hdr,
00075                              void* data) { return(-1); } // empty implementation
00076   virtual void Publish( void ){}; // empty implementation
00077 };
00078 
00079 
00080 class InterfaceSimulation : public Interface
00081 {
00082  public: 
00083   InterfaceSimulation( player_devaddr_t addr,  StgDriver* driver,ConfigFile* cf, int section );
00084   virtual ~InterfaceSimulation( void ){ /* TODO: clean up*/ };
00085   virtual int ProcessMessage(MessageQueue* resp_queue,
00086                              player_msghdr_t* hdr,
00087                              void* data);
00088 };
00089 
00090 
00091 class InterfaceModel : public Interface
00092 {
00093  public: 
00094   InterfaceModel( player_devaddr_t addr,  
00095                   StgDriver* driver,
00096                   ConfigFile* cf, 
00097                   int section, 
00098                   stg_model_initializer_t init );
00099   
00100   virtual ~InterfaceModel( void ){ /* TODO: clean up*/ };
00101 };
00102 
00103 class InterfacePosition : public InterfaceModel
00104 {
00105  private:
00106   bool stopped;
00107   int last_cmd_time;
00108  public: 
00109   InterfacePosition( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00110   virtual ~InterfacePosition( void ){ /* TODO: clean up*/ };
00111   virtual void Publish( void );
00112   virtual int ProcessMessage(MessageQueue* resp_queue,
00113                              player_msghdr_t* hdr,
00114                              void* data);
00115 };
00116  
00117 class InterfaceGripper : public InterfaceModel
00118 {
00119  public: 
00120   InterfaceGripper( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00121   virtual ~InterfaceGripper( void ){ /* TODO: clean up*/ };
00122   virtual int ProcessMessage(MessageQueue* resp_queue,
00123                              player_msghdr_t* hdr,
00124                              void* data);
00125   virtual void Publish( void );
00126 };
00127 
00128 class InterfaceWifi : public InterfaceModel
00129 {
00130  public: 
00131   InterfaceWifi( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00132   virtual ~InterfaceWifi( void ){ /* TODO: clean up*/ };
00133   virtual int ProcessMessage(MessageQueue* resp_queue,
00134                              player_msghdr_t* hdr,
00135                              void* data);
00136   virtual void Publish( void );
00137 };
00138 
00139 class InterfaceSpeech : public InterfaceModel
00140 {
00141  public: 
00142   InterfaceSpeech( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00143   virtual ~InterfaceSpeech( void ){ /* TODO: clean up*/ };
00144   virtual int ProcessMessage(MessageQueue* resp_queue,
00145                              player_msghdr_t* hdr,
00146                              void* data);
00147   virtual void Publish( void );
00148 };
00149 
00150 class InterfaceLaser : public InterfaceModel
00151 {
00152   private:
00153     int scan_id;
00154  public: 
00155   InterfaceLaser( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00156   virtual ~InterfaceLaser( void ){ /* TODO: clean up*/ };
00157   virtual int ProcessMessage(MessageQueue* resp_queue,
00158                               player_msghdr_t* hdr,
00159                               void* data);
00160   virtual void Publish( void );
00161 };
00162 
00163 class InterfacePower : public InterfaceModel
00164 {
00165  public: 
00166   InterfacePower( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00167   virtual ~InterfacePower( void ){ /* TODO: clean up*/ };
00168   
00169   virtual int ProcessMessage( MessageQueue* resp_queue, 
00170                               player_msghdr * hdr, 
00171                               void * data );
00172   
00173   virtual void Publish( void );
00174 };
00175 
00176 class InterfaceFiducial : public InterfaceModel
00177 {
00178  public: 
00179   InterfaceFiducial( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00180   virtual ~InterfaceFiducial( void ){ /* TODO: clean up*/ };
00181 
00182   virtual void Publish( void );
00183   virtual int ProcessMessage(MessageQueue* resp_queue,
00184                              player_msghdr_t* hdr,
00185                              void* data);
00186 };
00187 
00188  
00189 class InterfaceBlobfinder : public InterfaceModel
00190 {
00191  public: 
00192   InterfaceBlobfinder( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00193   virtual ~InterfaceBlobfinder( void ){ /* TODO: clean up*/ };
00194   
00195   virtual int ProcessMessage( MessageQueue* resp_queue, 
00196                               player_msghdr * hdr, 
00197                               void * data );
00198   virtual void Publish( void );
00199 };
00200 
00201 class InterfacePtz : public InterfaceModel
00202 {
00203  public: 
00204   InterfacePtz( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00205   virtual ~InterfacePtz( void ){ /* TODO: clean up*/ };
00206   
00207   virtual int ProcessMessage( MessageQueue* resp_queue, 
00208                               player_msghdr * hdr, 
00209                               void * data );
00210   virtual void Publish( void );
00211 };
00212 
00213 class InterfaceSonar : public InterfaceModel
00214 {
00215  public: 
00216   InterfaceSonar( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00217   virtual ~InterfaceSonar( void ){ /* TODO: clean up*/ };
00218   
00219   virtual int ProcessMessage( MessageQueue* resp_queue, 
00220                               player_msghdr * hdr, 
00221                               void * data );
00222   virtual void Publish( void );
00223 };
00224  
00225 
00226 class InterfaceBumper : public InterfaceModel
00227 {
00228  public: 
00229   InterfaceBumper( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00230   virtual ~InterfaceBumper( void ){ /* TODO: clean up*/ };
00231   
00232   virtual int ProcessMessage( MessageQueue* resp_queue, 
00233                               player_msghdr * hdr, 
00234                               void * data );
00235   virtual void Publish( void );
00236 };
00237  
00238 class InterfaceLocalize : public InterfaceModel
00239 {
00240  public: 
00241   InterfaceLocalize( player_devaddr_t addr, 
00242                      StgDriver* driver, 
00243                      ConfigFile* cf, 
00244                      int section );
00245 
00246   virtual ~InterfaceLocalize( void ){ /* TODO: clean up*/ };
00247 
00248   virtual void Publish( void );
00249   virtual int ProcessMessage(MessageQueue* resp_queue,
00250                              player_msghdr_t* hdr,
00251                              void* data);
00252 };
00253 
00254 class InterfaceMap : public InterfaceModel
00255 {
00256  public: 
00257   InterfaceMap( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00258   virtual ~InterfaceMap( void ){ /* TODO: clean up*/ };
00259   
00260   virtual int ProcessMessage( MessageQueue* resp_queue, 
00261                               player_msghdr * hdr, 
00262                               void * data );
00263   //virtual void Publish( void );
00264   
00265   // called by ProcessMessage to handle individual messages
00266 
00267   int HandleMsgReqInfo( MessageQueue* resp_queue, 
00268                         player_msghdr * hdr, 
00269                         void * data );
00270   int HandleMsgReqData( MessageQueue* resp_queue, 
00271                         player_msghdr * hdr, 
00272                         void * data );
00273 };
00274 
00275 class InterfaceGraphics2d : public InterfaceModel
00276 {
00277  public: 
00278   InterfaceGraphics2d( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00279   virtual ~InterfaceGraphics2d( void );
00280   
00281   virtual int ProcessMessage( MessageQueue* resp_queue, 
00282                               player_msghdr * hdr, 
00283                               void * data );
00284  private:
00285   stg_rtk_fig_t* fig; // a figure we can draw in
00286 };
00287 
00288 
00289 
00290 #endif

Generated on Thu Dec 13 14:35:18 2007 for Stage by  doxygen 1.4.6