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(QueuePointer &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   static unsigned int instance_count;
00056 };
00057 
00058 
00059 class Interface
00060 {
00061  public:
00062   Interface(player_devaddr_t addr,  
00063             StgDriver* driver,
00064             ConfigFile* cf, 
00065             int section );
00066   
00067   virtual ~Interface( void ){ /* TODO: clean up*/ };
00068 
00069   player_devaddr_t addr;
00070   stg_model_t* mod;
00071   double last_publish_time;
00072   
00073   StgDriver* driver; // the driver instance that created this device
00074   
00075   virtual int ProcessMessage(QueuePointer &resp_queue,
00076                              player_msghdr_t* hdr,
00077                              void* data) { return(-1); } // empty implementation
00078   virtual void Publish( void ){}; // empty implementation
00079 };
00080 
00081 
00082 class InterfaceSimulation : public Interface
00083 {
00084  public: 
00085   InterfaceSimulation( player_devaddr_t addr,  StgDriver* driver,ConfigFile* cf, int section );
00086   virtual ~InterfaceSimulation( void ){ /* TODO: clean up*/ };
00087   virtual int ProcessMessage(QueuePointer &resp_queue,
00088                              player_msghdr_t* hdr,
00089                              void* data);
00090 };
00091 
00092 
00093 class InterfaceModel : public Interface
00094 {
00095  public: 
00096   InterfaceModel( player_devaddr_t addr,  
00097                   StgDriver* driver,
00098                   ConfigFile* cf, 
00099                   int section, 
00100                   stg_model_initializer_t init );
00101   
00102   virtual ~InterfaceModel( void ){ /* TODO: clean up*/ };
00103 };
00104 
00105 class InterfacePosition : public InterfaceModel
00106 {
00107  private:
00108   bool stopped;
00109   int last_cmd_time;
00110  public: 
00111   InterfacePosition( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00112   virtual ~InterfacePosition( void ){ /* TODO: clean up*/ };
00113   virtual void Publish( void );
00114   virtual int ProcessMessage(QueuePointer &resp_queue,
00115                              player_msghdr_t* hdr,
00116                              void* data);
00117 };
00118  
00119 class InterfaceGripper : public InterfaceModel
00120 {
00121  public: 
00122   InterfaceGripper( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00123   virtual ~InterfaceGripper( void ){ /* TODO: clean up*/ };
00124   virtual int ProcessMessage(QueuePointer &resp_queue,
00125                              player_msghdr_t* hdr,
00126                              void* data);
00127   virtual void Publish( void );
00128 };
00129 
00130 class InterfaceWifi : public InterfaceModel
00131 {
00132  public: 
00133   InterfaceWifi( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00134   virtual ~InterfaceWifi( void ){ /* TODO: clean up*/ };
00135   virtual int ProcessMessage(QueuePointer &resp_queue,
00136                              player_msghdr_t* hdr,
00137                              void* data);
00138   virtual void Publish( void );
00139 };
00140 
00141 class InterfaceSpeech : public InterfaceModel
00142 {
00143  public: 
00144   InterfaceSpeech( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00145   virtual ~InterfaceSpeech( void ){ /* TODO: clean up*/ };
00146   virtual int ProcessMessage(QueuePointer &resp_queue,
00147                              player_msghdr_t* hdr,
00148                              void* data);
00149   virtual void Publish( void );
00150 };
00151 
00152 class InterfaceAudio : public InterfaceModel
00153 {
00154  public: 
00155   InterfaceAudio( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00156   virtual ~InterfaceAudio( void ){ /* TODO: clean up*/ };
00157   virtual int ProcessMessage(QueuePointer &resp_queue,
00158                              player_msghdr_t* hdr,
00159                              void* data);
00160   virtual void Publish( void );
00161 };
00162 
00163 class InterfaceLaser : public InterfaceModel
00164 {
00165   private:
00166     int scan_id;
00167  public: 
00168   InterfaceLaser( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00169   virtual ~InterfaceLaser( void ){ /* TODO: clean up*/ };
00170   virtual int ProcessMessage(QueuePointer &resp_queue,
00171                               player_msghdr_t* hdr,
00172                               void* data);
00173   virtual void Publish( void );
00174 };
00175 
00176 class InterfacePower : public InterfaceModel
00177 {
00178  public: 
00179   InterfacePower( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00180   virtual ~InterfacePower( void ){ /* TODO: clean up*/ };
00181   
00182   virtual int ProcessMessage( QueuePointer &resp_queue, 
00183                               player_msghdr * hdr, 
00184                               void * data );
00185   
00186   virtual void Publish( void );
00187 };
00188 
00189 class InterfaceFiducial : public InterfaceModel
00190 {
00191  public: 
00192   InterfaceFiducial( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00193   virtual ~InterfaceFiducial( void ){ /* TODO: clean up*/ };
00194 
00195   virtual void Publish( void );
00196   virtual int ProcessMessage(QueuePointer &resp_queue,
00197                              player_msghdr_t* hdr,
00198                              void* data);
00199 };
00200 
00201  
00202 class InterfaceBlobfinder : public InterfaceModel
00203 {
00204  public: 
00205   InterfaceBlobfinder( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00206   virtual ~InterfaceBlobfinder( void ){ /* TODO: clean up*/ };
00207   
00208   virtual int ProcessMessage( QueuePointer &resp_queue, 
00209                               player_msghdr * hdr, 
00210                               void * data );
00211   virtual void Publish( void );
00212 };
00213 
00214 class InterfacePtz : public InterfaceModel
00215 {
00216  public: 
00217   InterfacePtz( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00218   virtual ~InterfacePtz( void ){ /* TODO: clean up*/ };
00219   
00220   virtual int ProcessMessage( QueuePointer &resp_queue, 
00221                               player_msghdr * hdr, 
00222                               void * data );
00223   virtual void Publish( void );
00224 };
00225 
00226 class InterfaceSonar : public InterfaceModel
00227 {
00228  public: 
00229   InterfaceSonar( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00230   virtual ~InterfaceSonar( void ){ /* TODO: clean up*/ };
00231   
00232   virtual int ProcessMessage( QueuePointer &resp_queue, 
00233                               player_msghdr * hdr, 
00234                               void * data );
00235   virtual void Publish( void );
00236 };
00237  
00238 
00239 class InterfaceBumper : public InterfaceModel
00240 {
00241  public: 
00242   InterfaceBumper( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00243   virtual ~InterfaceBumper( void ){ /* TODO: clean up*/ };
00244   
00245   virtual int ProcessMessage( QueuePointer &resp_queue, 
00246                               player_msghdr * hdr, 
00247                               void * data );
00248   virtual void Publish( void );
00249 };
00250  
00251 class InterfaceLocalize : public InterfaceModel
00252 {
00253  public: 
00254   InterfaceLocalize( player_devaddr_t addr, 
00255                      StgDriver* driver, 
00256                      ConfigFile* cf, 
00257                      int section );
00258 
00259   virtual ~InterfaceLocalize( void ){ /* TODO: clean up*/ };
00260 
00261   virtual void Publish( void );
00262   virtual int ProcessMessage(QueuePointer &resp_queue,
00263                              player_msghdr_t* hdr,
00264                              void* data);
00265 };
00266 
00267 class InterfaceMap : public InterfaceModel
00268 {
00269  public: 
00270   InterfaceMap( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00271   virtual ~InterfaceMap( void ){ /* TODO: clean up*/ };
00272   
00273   virtual int ProcessMessage( QueuePointer &resp_queue, 
00274                               player_msghdr * hdr, 
00275                               void * data );
00276   //virtual void Publish( void );
00277   
00278   // called by ProcessMessage to handle individual messages
00279 
00280   int HandleMsgReqInfo( QueuePointer &resp_queue, 
00281                         player_msghdr * hdr, 
00282                         void * data );
00283   int HandleMsgReqData( QueuePointer &resp_queue, 
00284                         player_msghdr * hdr, 
00285                         void * data );
00286 };
00287 
00288 class InterfaceGraphics2d : public InterfaceModel
00289 {
00290  public: 
00291   InterfaceGraphics2d( player_devaddr_t addr, StgDriver* driver, ConfigFile* cf, int section );
00292   virtual ~InterfaceGraphics2d( void );
00293   
00294   virtual int ProcessMessage( QueuePointer &resp_queue, 
00295                               player_msghdr * hdr, 
00296                               void * data );
00297  private:
00298   stg_rtk_fig_t* fig; // a figure we can draw in
00299 };
00300 
00301 
00302 
00303 #endif

Generated on Thu Dec 13 13:55:21 2007 for Stage by  doxygen 1.4.6