00001 // 00002 // SfDevices.h 00003 // 00004 // Saphira sonar, laser, and IR range device definitions 00005 00006 // 00007 // Copyright 2001 by Kurt Konolige 00008 // 00009 // The author hereby grants to SRI permission to use this software. 00010 // The author also grants to SRI permission to distribute this software 00011 // to schools for non-commercial educational use only. 00012 // 00013 // The author hereby grants to other individuals or organizations 00014 // permission to use this software for non-commercial 00015 // educational use only. This software may not be distributed to others 00016 // except by SRI, under the conditions above. 00017 // 00018 // Other than these cases, no part of this software may be used or 00019 // distributed without written permission of the author. 00020 // 00021 // Neither the author nor SRI make any representations about the 00022 // suitability of this software for any purpose. It is provided 00023 // "as is" without express or implied warranty. 00024 // 00025 // Kurt Konolige 00026 // Senior Computer Scientist 00027 // SRI International 00028 // 333 Ravenswood Avenue 00029 // Menlo Park, CA 94025 00030 // E-mail: konolige@ai.sri.com 00031 // 00032 00033 #ifndef SFDEVICES_H 00034 #define SFDEVICES_H 00035 00036 #undef SFEXPORT 00037 #if defined(MS_WINDOWS) && !defined(SF_STATIC) 00038 #ifdef MAKE_LIBRARY 00039 #define _declspec( dllexport ) 00040 #else 00041 #define _declspec( dllimport ) 00042 #endif 00043 #else 00044 #define SFEXPORT 00045 #endif 00046 00047 #undef SFLASEREXPORT 00048 #if defined(MS_WINDOWS) && !defined(SF_STATIC) 00049 #ifdef MAKE_LASER_LIBRARY 00050 #define _declspec( dllexport ) 00051 #else 00052 #define _declspec( dllimport ) 00053 #endif 00054 #else 00055 #define SFLASEREXPORT 00056 #endif 00057 00058 00061 00070 class SfRangeDevice : public SfDrawable 00071 { 00072 public: 00074 ArRangeDevice *ourRangeDevice; 00076 ArRangeBuffer *getCurrent() { return ourRangeDevice->getCurrentRangeBuffer(); } 00078 ArRangeBuffer *getAccum() { return ourRangeDevice->getCumulativeRangeBuffer(); } 00080 void lockDevice() { ourRangeDevice->lockDevice(); } 00082 void unlockDevice() { ourRangeDevice->unlockDevice(); } 00084 const char *getName() { return ourRangeDevice->getName().c_str(); } 00085 void *paramWin; // parameter window for GUI 00086 00088 bool accumDraw; // flags for drawing range buffers 00090 bool curDraw; 00091 }; 00092 00093 00095 class SfSonarDevice : public SfRangeDevice 00096 { 00097 public: 00098 SfSonarDevice(SfRobot *robot = NULL); 00099 void draw(SfWin *); 00100 }; 00101 00103 class SfLaserDevice : public SfRangeDevice 00104 { 00105 public: 00106 SfLaserDevice(SfRobot *robot = NULL); 00108 bool start(char *port); // starts up the device; null port is sim 00109 bool startTcp(const char *host, int port); // starts up the device on a tcp connect, DO NOT USE for the sim, use start with a NULL 00111 bool stop(); // shuts down the device 00112 virtual void draw(SfWin *); 00113 00114 // the following were added by benson limketkai (bensonl@ai.sri.com, June 2002) 00115 00117 double getStartAngle(); 00119 double getEndAngle(); 00121 bool isLaserFlipped(); 00123 double getDegrees(); 00125 double getIncrement(); 00126 }; 00127 00128 00130 class SfIrrfDevice : public SfRangeDevice 00131 { 00132 public: 00133 SfIrrfDevice(SfRobot *robot = NULL); 00134 00135 virtual void draw(SfWin *); 00136 00138 double getStartAngle(); 00140 double getEndAngle(); 00142 bool isIrrfFlipped(); 00144 double getDegrees(); 00146 double getIncrement(); 00147 }; 00148 00149 00150 #endif // SFDEVICES_H