urgInterface.h

Go to the documentation of this file.
00001 #ifndef URG_INTERFACE_H
00002 #define URG_INTERFACE_H
00003 
00013 #include <math.h>
00014 #include "math_util.h"
00015 
00016 
00020 namespace URG {
00021   enum {
00022     AutoCapture = true, ManualCapture = false,
00023     DefaultBaudrate = 115200,
00024   };
00025 };
00026 
00030 class URGInterface {
00031 public:
00037   typedef struct {
00038     int cycle_step_max;         
00039     int first_step;             
00040     int sense_steps;            
00041     int rotate_direction;       
00042     int cycle_msec;             
00043     long length_min;            
00044     long length_max;            
00045     int ticks_begin_step; 
00046   } urgParams_t;
00047 
00048 public:
00049   virtual ~URGInterface(void) {}
00050 
00056   virtual urgParams_t& getParameters(void) = 0;
00057 
00063   virtual long* getLengthData(void) = 0;
00064 
00083   virtual const char* what(void) = 0;
00084 
00097   virtual int connect(const char* device,
00098                       long baudrate = URG::DefaultBaudrate,
00099                       bool autoCapture = URG::AutoCapture) = 0;
00100 
00112   virtual int connect(int argc, char *argv[],
00113                       bool autoCapture = URG::AutoCapture) = 0;
00114 
00115 
00121   virtual void disconnect(void) = 0;
00122 
00135   virtual int capture(int first_index, int last_index, int group = 1) = 0;
00136 
00142   virtual int capture(int group = 1) = 0;
00143 
00155   virtual double index2rad(int index) {
00156     urgParams_t& params = getParameters();
00157     return (params.first_step + params.rotate_direction * index) *
00158       (2.0*M_PI) / params.cycle_step_max;
00159   }
00160 
00186   virtual int rad2index(double radian) {
00187     urgParams_t& params = getParameters();
00188     return static_cast<int>(radian / (2.0 * M_PI) * params.cycle_step_max
00189                             - params.first_step);
00190   }
00191 };
00192 
00193 #endif /* !URG_INTERFACE_H */
00194 

Generated on Mon Apr 13 22:52:05 2009 by  doxygen 1.5.7.1