urgCtrl.h
Go to the documentation of this file.00001 #ifndef URG_CTRL_H
00002 #define URG_CTRL_H
00003
00013 #include "coordinateCtrl.h"
00014 #include "ticksCtrlInterface.h"
00015 #include "urgCapture.h"
00016 #include "timeUtils.h"
00017 #include "ticksPositionInterface.h"
00018
00019
00023 class URGCtrl : public URGInterface, public CoordinateCtrl,
00024 public TicksCtrlInterface {
00025 friend class URG_Simulator;
00026 friend class URGCtrlTest;
00027
00028 enum {
00029 DefaultBaudrate = 115200,
00030 SimulatorPort = 49763,
00031 };
00032 URGCapture* con;
00033 bool isHandstand;
00034
00035 int eachDataByte;
00036 bool enableOver4096;
00037
00038 std::string error_message;
00039 static bool isVersionPrinted;
00040 static bool isHelpPrinted;
00041
00042 bool ignore_beginTimeAdjust;
00043 unsigned short pre_module_ticks;
00044 long total_msec;
00045
00046 ticksInfo_t ticksInfoObj;
00047 ticksInfo_t& getTicksInfo(void) {
00048 return ticksInfoObj;
00049 }
00050
00051 void skipReply(int n);
00052 long decode(const char* data, int data_byte);
00053 int updateTicksDiff(unsigned short ticks);
00054 unsigned long getModuleRawTicks(void);
00055
00056 void printVersion(void);
00057 void printHelp(void);
00058 int getIndexTicks(int index);
00059 URGCtrl(const URGCtrl& rhs);
00060
00061 protected:
00062 enum {
00063 SenseSteps = (1024 * 270 / 360) + 1,
00064 };
00065 bool to_simulator;
00066 bool enableTimestamp;
00071 void initTicksInfo(void);
00072
00076 virtual unsigned long getHostTicks(void);
00077
00081 virtual void beginTimeAdjust(void);
00082
00090 virtual unsigned long getURGTimestamp(void);
00091
00095 virtual void endTimeAdjust(void);
00096
00100 urgParams_t params;
00101
00102 long* getLengthData(void) {
00103 return length;
00104 }
00105
00121 bool parseArgs(int* ret_value, int argc, char *argv[], bool autoCapture);
00122
00126 void checkVersion(void);
00127
00142 virtual int raw_capture(long length[],
00143 int first_index, int last_index, int group,
00144 unsigned long* raw_timestamp = NULL);
00145
00146 public:
00147 enum {
00148 VEND = 3,
00149 PROD,
00150 FIRM,
00151 PROT,
00152 SERI,
00153 DefaultTimeout = -1,
00154 };
00155
00156
00157
00158 urgParams_t& getParameters(void) {
00159 return params;
00160 }
00161
00165 long length[SenseSteps];
00166
00167 URGCtrl(void);
00168 ~URGCtrl(void);
00169
00170 const char* what(void);
00171
00179 void setHandstand(bool on);
00180
00181 virtual int connect(const char* device, long baudrate = DefaultBaudrate,
00182 bool autoCapture = URG::AutoCapture);
00183
00196 int connectSocket(const char* host, short port, bool autoCapture);
00197
00198 virtual int connect(int argc, char *argv[],
00199 bool autoCapture = URG::AutoCapture);
00200
00208 virtual int connect(bool autoCapture = true);
00209
00210 virtual void disconnect(void);
00211
00217 virtual bool isConnected(void);
00218
00224 void set_recvTimeout(int timeout = DefaultTimeout);
00225
00235 enum { LineLength = 64 + 16 };
00236 virtual int getVersionInfo(char lines[][LineLength]);
00237
00238 int capture(int first_index, int last_index, int group = 1);
00239
00240 int capture(int group = 1);
00241
00247 int getCaptureTimes(void);
00248
00254 void convert(void);
00255
00263 void convert(const VXV::Position3D& crd_position);
00264
00272 void convert(const VXV::TicksPositionInterface& position);
00273 };
00274
00275
00279 class URG_Exception : public std::exception {
00280 std::string error_message;
00281
00282 public:
00286 URG_Exception(const char* message) throw () : error_message(message) {}
00287 virtual ~URG_Exception(void) throw () {}
00288
00294 virtual const char* what(void) const throw() {
00295 return error_message.c_str();
00296 }
00297 };
00298
00299 #endif
00300