00001 #ifndef QRK_URG_CTRL_H
00002 #define QRK_URG_CTRL_H
00003
00013 #include "RangeSensor.h"
00014 #include "Coordinate.h"
00015
00016
00017 namespace qrk
00018 {
00019 class Connection;
00020
00021
00023 class UrgCtrl : public Coordinate, public RangeSensor
00024 {
00025 public:
00026
00028 enum {
00029 DefaultBaudrate = 115200,
00030 DefaultRetryTimes = 8,
00031 Infinity = 0,
00032
00033 Off = 0,
00034 On = 1,
00035 };
00036
00037 UrgCtrl(void);
00038 virtual ~UrgCtrl(void);
00039
00040 const char* what(void) const;
00041
00042 bool connect(const char* device, long baudrate = DefaultBaudrate);
00043 void setConnection(Connection* con);
00044 Connection* connection(void);
00045 void disconnect(void);
00046 bool isConnected(void) const;
00047
00048 long minDistance(void) const;
00049 long maxDistance(void) const;
00050 int maxScanLines(void) const;
00051
00052
00062 void setRetryTimes(size_t times);
00063
00064
00070 void setCapturesSize(size_t size);
00071
00072
00078 int scanMsec(void) const;
00079
00080
00088 void setCaptureMode(RangeCaptureMode mode);
00089
00090
00098 RangeCaptureMode captureMode(void);
00099
00100
00109 void setCaptureRange(int begin_index, int end_index);
00110
00111
00120 void setCaptureFrameInterval(size_t interval);
00121
00122
00132 void setCaptureTimes(size_t times);
00133
00134
00142 size_t remainCaptureTimes(void);
00143
00144
00168 void setCaptureSkipLines(size_t skip_lines);
00169
00170
00171 int capture(std::vector<long>& data, long* timestamp = NULL);
00172
00173
00174
00175
00176
00177
00178
00179 int captureWithIntensity(std::vector<long>& data,
00180 std::vector<long>& intensity_data,
00181 long* timestamp = NULL);
00182
00183
00189 void stop(void);
00190
00191
00192 bool setTimestamp(int timestamp = 0, int* response_msec = NULL,
00193 int* force_delay_msec = NULL);
00194
00195 long recentTimestamp(void) const;
00196
00197
00203 bool setLaserOutput(bool on);
00204
00205 double index2rad(const int index) const;
00206 int rad2index(const double radian) const;
00207
00208 void setParameter(const RangeSensorParameter& parameter);
00209 RangeSensorParameter parameter(void) const;
00210
00211
00218 bool loadParameter(void);
00219
00220
00232 bool versionLines(std::vector<std::string>& lines);
00233
00234
00240 bool reboot(void);
00241
00242
00248 bool reset(void);
00249
00250
00251 protected:
00252 virtual void captureReceived(void);
00253
00254
00255 private:
00256 UrgCtrl(const UrgCtrl& rhs);
00257 UrgCtrl& operator = (const UrgCtrl& rhs);
00258
00259 struct pImpl;
00260 std::auto_ptr<pImpl> pimpl;
00261 };
00262 }
00263
00264 #endif