Home
FAQ
Player
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

stagedevice.h

Go to the documentation of this file.
00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2000  
00004  *     Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
00005  *                      
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00024 //
00025 // File: stagedevice.hh
00026 // Author: Andrew Howard
00027 // Date: 28 Nov 2000
00028 // Desc: Class for stage (simulated) devices
00029 //
00030 // CVS info:
00031 //  $Source: /cvsroot/playerstage/code/player/server/drivers/stage/stagedevice.h,v $
00032 //  $Author: gerkey $
00033 //  $Revision: 1.6 $
00034 //
00035 // Usage:
00036 //  (empty)
00037 //
00038 // Theory of operation:
00039 //  (empty)
00040 //
00041 // Known bugs:
00042 //  (empty)
00043 //
00044 // Possible enhancements:
00045 //  (empty)
00046 //
00048 
00049 #ifndef _STAGEDEVICE_H
00050 #define _STAGEDEVICE_H
00051 
00052 // For length-specific types, error macros, etc
00053 //
00054 #include <playercommon.h>
00055 
00056 #include <device.h>
00057 #include <driver.h>
00058 #include <stage1p3.h>
00059 
00060 // this is the root of the stage device filesystem name
00061 // actual directories have the username and instance appended
00062 // e.g. /tmp/stageIO.vaughan.0
00063 #define IOFILENAME "/tmp/stageIO"
00064 
00065 class StageDevice : public Driver
00066 {
00067   // constructor - info points to a single buffer containing the data,
00068   // command and configuration buffers.  lock fd is an open
00069   // filedescriptor. we'll lock the lockbyte'th byte in this file to
00070   // control access to this device
00071   public: StageDevice( player_stage_info_t* info, 
00072                         int lockfd, int lockbyte );
00073 
00074   // used to keep a list of objects
00075   public: StageDevice* next; 
00076 
00077   // Initialise the device
00078   //
00079   public: virtual int Setup();
00080 
00081   // Terminate the device
00082   //
00083   public: virtual int Shutdown();
00084     
00085   // Read data from the device
00086   //
00087   public: virtual size_t GetData(player_device_id_t id,
00088                                  void* dest, size_t len,
00089                                  struct timeval* timestamp);
00090 
00091   // Write a command to the device
00092   //
00093   public: virtual void PutCommand(player_device_id_t id,
00094                                   void* src, size_t len,
00095                                   struct timeval* timestamp);
00096 
00097   // Give the device a chance to update
00098   public: virtual void Update(void);
00099     
00100   // Simulator lock bookkeeping data and init method
00101   //
00102   private: int lock_fd;
00103   private: int lock_byte;
00104   private: void InstallLock( int fd, int index )
00105            {lock_fd = fd; lock_byte = index;}
00106 
00107   // these two methods are overrides of the Driver definitions.
00108   private: virtual void Lock();
00109   private: virtual void Unlock();
00110 
00111   // Pointer to my Device, which has pointers to data and command
00112   // buffers
00113   private: Device* device;
00114 
00115 
00116   // Pointer to shared info buffers
00117   //
00118   public: player_stage_info_t *m_info;
00119   public: size_t m_info_len;
00120 };
00121 
00122 #endif

Generated on Tue May 3 14:15:36 2005 for Player by doxygen 1.3.6