driver.h
Go to the documentation of this file.
00001 /*
00002  * flir_ptu_driver ROS package
00003  * Copyright (C) 2014 Mike Purvis (mpurvis@clearpathrobotics.com)
00004  *
00005  * PTU ROS Package
00006  * Copyright (C) 2009 Erik Karulf (erik@cse.wustl.edu)
00007  *
00008  * Author: Toby Collett (University of Auckland)
00009  * Date: 2003-02-10
00010  *
00011  * Player - One Hell of a Robot Server
00012  * Copyright (C) 2000  Brian Gerkey   &  Kasper Stoy
00013  *                     gerkey@usc.edu    kaspers@robotics.usc.edu
00014  *
00015  *  This program is free software; you can redistribute it and/or modify
00016  *  it under the terms of the GNU General Public License as published by
00017  *  the Free Software Foundation; either version 2 of the License, or
00018  *  (at your option) any later version.
00019  *
00020  *  This program is distributed in the hope that it will be useful,
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *  GNU General Public License for more details.
00024  *
00025  *  You should have received a copy of the GNU General Public License
00026  *  along with this program; if not, write to the Free Software
00027  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028  *
00029  */
00030 
00031 #ifndef FLIR_PTU_DRIVER_DRIVER_H
00032 #define FLIR_PTU_DRIVER_DRIVER_H
00033 
00034 // serial defines
00035 #define PTU_DEFAULT_BAUD 9600
00036 #define PTU_BUFFER_LEN 255
00037 #define PTU_DEFAULT_PORT "/dev/ttyUSB0"
00038 #define PTU_DEFAULT_HZ 10
00039 
00040 // command defines
00041 #define PTU_PAN 'p'
00042 #define PTU_TILT 't'
00043 #define PTU_MIN 'n'
00044 #define PTU_MAX 'x'
00045 #define PTU_MIN_SPEED 'l'
00046 #define PTU_MAX_SPEED 'u'
00047 #define PTU_VELOCITY 'v'
00048 #define PTU_POSITION 'i'
00049 
00050 #include <string>
00051 
00052 namespace serial
00053 {
00054 class Serial;
00055 }
00056 
00057 namespace flir_ptu_driver
00058 {
00059 
00060 class PTU
00061 {
00062 public:
00066   explicit PTU(serial::Serial* ser) :
00067     ser_(ser), initialized_(false)
00068   {
00069   }
00070 
00072   bool initialize();
00073 
00075   bool initialized();
00076 
00081   float getPosition(char type);
00082 
00087   float getSpeed(char type);
00088 
00093   float getResolution(char type)
00094   {
00095     return (type == PTU_TILT ? tr : pr);
00096   }
00097 
00102   float getMin(char type)
00103   {
00104     return getResolution(type) * (type == PTU_TILT ? TMin : PMin);
00105   }
00110   float getMax(char type)
00111   {
00112     return getResolution(type) * (type == PTU_TILT ? TMax : PMax);
00113   }
00114 
00119   float getMinSpeed(char type)
00120   {
00121     return getResolution(type) * (type == PTU_TILT ? TSMin : PSMin);
00122   }
00127   float getMaxSpeed(char type)
00128   {
00129     return getResolution(type) * (type == PTU_TILT ? TSMax : PSMax);
00130   }
00131 
00140   bool setPosition(char type, float pos, bool Block = false);
00141 
00148   bool setSpeed(char type, float speed);
00149 
00155   bool setMode(char type);
00156 
00161   char getMode();
00162 
00163   bool home();
00164 
00165 private:
00170   float getRes(char type);
00171 
00178   int getLimit(char type, char limType);
00179 
00180   // Position Limits
00181   int TMin;  
00182   int TMax;  
00183   int PMin;  
00184   int PMax;  
00185 
00186   // Speed Limits
00187   int TSMin;  
00188   int TSMax;  
00189   int PSMin;  
00190   int PSMax;  
00191 
00192 protected:
00198   std::string sendCommand(std::string command);
00199 
00200   serial::Serial* ser_;
00201   bool initialized_;
00202 
00203   float tr;  
00204   float pr;  
00205 };
00206 
00207 }  // namespace flir_ptu_driver
00208 
00209 #endif  // FLIR_PTU_DRIVER_DRIVER_H


flir_ptu_driver
Author(s): Erik Karulf , David V. Lu , Nick Hawes
autogenerated on Fri Aug 28 2015 10:39:27