ptu46_driver.h
Go to the documentation of this file.
00001 #ifndef _PTU46_DRIVER_H_
00002 #define _PTU46_DRIVER_H_
00003 
00004 #include <termios.h>
00005 
00006 // serial defines
00007 #define PTU46_DEFAULT_BAUD 9600
00008 #define PTU46_BUFFER_LEN 255
00009 #define PTU46_DEFAULT_PORT "/dev/ttyUSB1"
00010 #define PTU46_DEFAULT_HZ 10
00011 
00012 // command defines
00013 #define PTU46_PAN 'p'
00014 #define PTU46_TILT 't'
00015 #define PTU46_MIN 'n'
00016 #define PTU46_MAX 'x'
00017 #define PTU46_MIN_SPEED 'l'
00018 #define PTU46_MAX_SPEED 'u'
00019 #define PTU46_VELOCITY 'v'
00020 #define PTU46_POSITION 'i'
00021 
00022 namespace PTU46 {
00023 
00052 class PTU46 {
00053     public:
00057         PTU46(const char* port, int rate);
00058         ~PTU46();
00059 
00061         bool isOpen () {
00062             return fd > 0;
00063         };
00064 
00069         float GetPosition (char type);
00070 
00075         float GetSpeed (char type);
00076 
00081         float GetResolution (char type) {
00082             return (type == PTU46_TILT ? tr : pr);
00083         }
00084 
00089         float GetMin (char type) {
00090             return GetResolution(type)*(type == PTU46_TILT ? TMin : PMin);
00091         }
00096         float GetMax (char type) {
00097             return GetResolution(type)*(type == PTU46_TILT ? TMax : PMax);
00098         }
00099 
00104         float GetMinSpeed (char type) {
00105             return GetResolution(type)*(type == PTU46_TILT ? TSMin : PSMin);
00106         }
00111         float GetMaxSpeed (char type) {
00112             return GetResolution(type)*(type == PTU46_TILT ? TSMax : PSMax);
00113         }
00114 
00115 
00116 
00125         bool SetPosition  (char type, float pos, bool Block = false);
00126 
00133         bool SetSpeed  (char type, float speed);
00134 
00140         bool SetMode (char type);
00141 
00146         char GetMode ();
00147 
00148     private:
00153         float GetRes (char type);
00154 
00161         int GetLimit (char type, char LimType);
00162 
00163 
00164 
00165         // Position Limits
00166         int TMin;       
00167         int TMax;       
00168         int PMin;       
00169         int PMax;       
00170 
00171         // Speed Limits
00172         int TSMin;      
00173         int TSMax;      
00174         int PSMin;      
00175         int PSMax;      
00176 
00177     protected:
00178         float tr;       
00179         float pr;       
00180 
00181         int fd;         
00182         struct termios oldtio; 
00183 
00184         char buffer[PTU46_BUFFER_LEN+1]; 
00185 
00192         int Write(const char * data, int length = 0);
00193 
00196         void Disconnect();
00197 };
00198 
00199 }
00200 
00201 #endif


ptu46
Author(s): Erik Karulf, David V. Lu!!
autogenerated on Fri Aug 28 2015 12:58:57