00001 #ifndef QRK_RANGE_SENSOR_H
00002 #define QRK_RANGE_SENSOR_H
00003
00013 #include "RangeCaptureMode.h"
00014 #include "MathUtils.h"
00015 #include <vector>
00016 #include <string>
00017
00018
00019 namespace qrk
00020 {
00021 class Connection;
00022 class RangeSensorParameter;
00023
00024
00026 class RangeSensor
00027 {
00028 public:
00029 virtual ~RangeSensor(void) {}
00030
00031
00046 virtual const char* what(void) const = 0;
00047
00048
00070 virtual bool connect(const char* device, long baudrate) = 0;
00071
00072
00078 virtual void setConnection(Connection* con) = 0;
00079
00080
00086 virtual Connection* connection(void) = 0;
00087
00088
00092 virtual void disconnect(void) = 0;
00093
00094
00101 virtual bool isConnected(void) const = 0;
00102
00103
00109 virtual long minDistance(void) const = 0;
00110
00111
00117 virtual long maxDistance(void) const = 0;
00118
00119
00125 virtual int maxScanLines(void) const = 0;
00126
00127 virtual int scanMsec(void) const = 0;
00128
00129 virtual void setCaptureMode(RangeCaptureMode mode) = 0;
00130 virtual RangeCaptureMode captureMode(void) = 0;
00131
00132
00144 virtual int capture(std::vector<long>& data, long* timestamp) = 0;
00145
00146
00147 virtual int captureWithIntensity(std::vector<long>& data,
00148 std::vector<long>& intensity_data,
00149 long* timestamp) = 0;
00150
00151
00164 virtual bool setTimestamp(int timestamp = 0, int* response_msec = NULL,
00165 int* force_delay_msec = NULL) = 0;
00166
00167
00173 virtual long recentTimestamp(void) const
00174 {
00175 return 0;
00176 }
00177
00178
00179 virtual bool setLaserOutput(bool on) = 0;
00180
00181
00195 virtual double index2rad(const int index) const = 0;
00196
00197
00211 int index2deg(const int index) const
00212 {
00213 return static_cast<int>(floor((180.0 * index2rad(index) / M_PI) + 0.5));
00214 }
00215
00216
00228 virtual int rad2index(const double radian) const = 0;
00229
00230
00242 int deg2index(const int degree) const
00243 {
00244 return rad2index(degree * M_PI / 180.0);
00245 }
00246
00247
00253 virtual void setParameter(const RangeSensorParameter& parameter) = 0;
00254
00255
00261 virtual RangeSensorParameter parameter(void) const = 0;
00262 };
00263 }
00264
00265 #endif