driver.h
Go to the documentation of this file.
1 /*
2  * flir_ptu_driver ROS package
3  * Copyright (C) 2014 Mike Purvis (mpurvis@clearpathrobotics.com)
4  *
5  * PTU ROS Package
6  * Copyright (C) 2009 Erik Karulf (erik@cse.wustl.edu)
7  *
8  * Author: Toby Collett (University of Auckland)
9  * Date: 2003-02-10
10  *
11  * Player - One Hell of a Robot Server
12  * Copyright (C) 2000 Brian Gerkey & Kasper Stoy
13  * gerkey@usc.edu kaspers@robotics.usc.edu
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28  *
29  */
30 
31 #ifndef FLIR_PTU_DRIVER_DRIVER_H
32 #define FLIR_PTU_DRIVER_DRIVER_H
33 
34 // serial defines
35 #define PTU_DEFAULT_BAUD 9600
36 #define PTU_BUFFER_LEN 255
37 #define PTU_DEFAULT_PORT "/dev/ttyUSB0"
38 #define PTU_DEFAULT_HZ 10
39 #define PTU_DEFAULT_VEL 0.0
40 
41 // command defines
42 #define PTU_PAN 'p'
43 #define PTU_TILT 't'
44 #define PTU_MIN 'n'
45 #define PTU_MAX 'x'
46 #define PTU_MIN_SPEED 'l'
47 #define PTU_MAX_SPEED 'u'
48 #define PTU_VELOCITY 'v'
49 #define PTU_POSITION 'i'
50 
51 #include <string>
52 
53 namespace serial
54 {
55 class Serial;
56 }
57 
58 namespace flir_ptu_driver
59 {
60 
61 class PTU
62 {
63 public:
67  explicit PTU(serial::Serial* ser) :
68  ser_(ser), initialized_(false)
69  {
70  }
71 
73  bool initialize();
74 
76  bool disableLimits();
77 
79  bool initialized();
80 
85  float getPosition(char type);
86 
91  float getSpeed(char type);
92 
97  float getResolution(char type)
98  {
99  return (type == PTU_TILT ? tr : pr);
100  }
101 
106  float getMin(char type)
107  {
108  return getResolution(type) * (type == PTU_TILT ? TMin : PMin);
109  }
114  float getMax(char type)
115  {
116  return getResolution(type) * (type == PTU_TILT ? TMax : PMax);
117  }
118 
123  float getMinSpeed(char type)
124  {
125  return getResolution(type) * (type == PTU_TILT ? TSMin : PSMin);
126  }
131  float getMaxSpeed(char type)
132  {
133  return getResolution(type) * (type == PTU_TILT ? TSMax : PSMax);
134  }
135 
144  bool setPosition(char type, float pos, bool Block = false);
145 
152  bool setSpeed(char type, float speed);
153 
159  bool setMode(char type);
160 
165  char getMode();
166 
167  bool home();
168 
169 private:
174  float getRes(char type);
175 
182  int getLimit(char type, char limType);
183 
184  // Position Limits
185  int TMin;
186  int TMax;
187  int PMin;
188  int PMax;
189  bool Lim;
190 
191  // Speed Limits
192  int TSMin;
193  int TSMax;
194  int PSMin;
195  int PSMax;
196 
197 protected:
203  std::string sendCommand(std::string command);
204 
207 
208  float tr;
209  float pr;
210 };
211 
212 } // namespace flir_ptu_driver
213 
214 #endif // FLIR_PTU_DRIVER_DRIVER_H
float getMax(char type)
Definition: driver.h:114
int TMin
Min Tilt in Counts.
Definition: driver.h:185
int PMin
Min Pan in Counts.
Definition: driver.h:187
ROSCONSOLE_DECL void initialize()
bool Lim
Position Limits enabled.
Definition: driver.h:189
float getMaxSpeed(char type)
Definition: driver.h:131
float getResolution(char type)
Definition: driver.h:97
PTU(serial::Serial *ser)
Definition: driver.h:67
float getMinSpeed(char type)
Definition: driver.h:123
serial::Serial * ser_
Definition: driver.h:205
int PSMin
Min Pan Speed in Counts/second.
Definition: driver.h:194
int TSMax
Max Tilt Speed in Counts/second.
Definition: driver.h:193
int PMax
Max Pan in Counts.
Definition: driver.h:188
float tr
tilt resolution (rads/count)
Definition: driver.h:208
int PSMax
Max Pan Speed in Counts/second.
Definition: driver.h:195
int TSMin
Min Tilt Speed in Counts/second.
Definition: driver.h:192
float getMin(char type)
Definition: driver.h:106
float pr
pan resolution (rads/count)
Definition: driver.h:209
int TMax
Max Tilt in Counts.
Definition: driver.h:186
#define PTU_TILT
Definition: driver.h:43


flir_ptu_driver
Author(s): Erik Karulf , David V. Lu , Nick Hawes
autogenerated on Sun Mar 28 2021 02:27:16