ptu46_driver.h
Go to the documentation of this file.
1 
7 #ifndef _PTU46_DRIVER_H_
8 #define _PTU46_DRIVER_H_
9 
10 #include <termios.h>
11 
12 // serial defines
13 #define PTU46_DEFAULT_BAUD 9600
14 #define PTU46_BUFFER_LEN 255
15 #define PTU46_DEFAULT_PORT "/dev/ttyUSB1"
16 #define PTU46_DEFAULT_HZ 10
17 
18 // command defines
19 #define PTU46_PAN 'p'
20 #define PTU46_TILT 't'
21 #define PTU46_MIN 'n'
22 #define PTU46_MAX 'x'
23 #define PTU46_MIN_SPEED 'l'
24 #define PTU46_MAX_SPEED 'u'
25 #define PTU46_VELOCITY 'v'
26 #define PTU46_POSITION 'i'
27 
28 namespace PTU46 {
29 
58 class PTU46 {
59  public:
63  PTU46(const char* port, int rate);
64  ~PTU46();
65 
67  bool isOpen () {
68  return fd > 0;
69  };
70 
75  float GetPosition (char type);
76 
81  float GetSpeed (char type);
82 
87  float GetResolution (char type) {
88  return (type == PTU46_TILT ? tr : pr);
89  }
90 
95  float GetMin (char type) {
96  return GetResolution(type)*(type == PTU46_TILT ? TMin : PMin);
97  }
102  float GetMax (char type) {
103  return GetResolution(type)*(type == PTU46_TILT ? TMax : PMax);
104  }
105 
110  float GetMinSpeed (char type) {
111  return GetResolution(type)*(type == PTU46_TILT ? TSMin : PSMin);
112  }
117  float GetMaxSpeed (char type) {
118  return GetResolution(type)*(type == PTU46_TILT ? TSMax : PSMax);
119  }
120 
121 
122 
131  bool SetPosition (char type, float pos, bool Block = false);
132 
139  bool SetSpeed (char type, float speed);
140 
146  bool SetMode (char type);
147 
152  char GetMode ();
153 
154  private:
159  float GetRes (char type);
160 
167  int GetLimit (char type, char LimType);
168 
169 
170 
171  // Position Limits
172  int TMin;
173  int TMax;
174  int PMin;
175  int PMax;
176 
177  // Speed Limits
178  int TSMin;
179  int TSMax;
180  int PSMin;
181  int PSMax;
182 
183  protected:
184  float tr;
185  float pr;
186 
187  int fd;
188  struct termios oldtio;
189 
190  char buffer[PTU46_BUFFER_LEN+1];
191 
198  int Write(const char * data, int length = 0);
199 
202  void Disconnect();
203 };
204 
205 }
206 
207 #endif
float GetMax(char type)
Definition: ptu46_driver.h:102
float GetMaxSpeed(char type)
Definition: ptu46_driver.h:117
float GetMin(char type)
Definition: ptu46_driver.h:95
int TMax
Max Tilt in Counts.
Definition: ptu46_driver.h:173
PTU46 Pan Tilt Unit Driver Copyright (C) 2009 Erik Karulf (erik@cse.wustl.edu)
Definition: ptu46_driver.h:58
float GetMinSpeed(char type)
Definition: ptu46_driver.h:110
float tr
tilt resolution (rads/count)
Definition: ptu46_driver.h:184
int PSMin
Min Pan Speed in Counts/second.
Definition: ptu46_driver.h:180
#define PTU46_BUFFER_LEN
Definition: ptu46_driver.h:14
int TMin
Min Tilt in Counts.
Definition: ptu46_driver.h:172
float GetResolution(char type)
Definition: ptu46_driver.h:87
float pr
pan resolution (rads/count)
Definition: ptu46_driver.h:185
int PSMax
Max Pan Speed in Counts/second.
Definition: ptu46_driver.h:181
int PMin
Min Pan in Counts.
Definition: ptu46_driver.h:174
int fd
serial port descriptor
Definition: ptu46_driver.h:187
bool isOpen()
Definition: ptu46_driver.h:67
#define PTU46_TILT
Definition: ptu46_driver.h:20
int TSMin
Min Tilt Speed in Counts/second.
Definition: ptu46_driver.h:178
int TSMax
Max Tilt Speed in Counts/second.
Definition: ptu46_driver.h:179
int PMax
Max Pan in Counts.
Definition: ptu46_driver.h:175


ptu46
Author(s): Erik Karulf, David Lu
autogenerated on Mon Mar 2 2015 01:32:49