All Classes Namespaces Files Functions Variables Enumerations Enumerator
libs/range_sensor/UrgDevice.h
Go to the documentation of this file.
00001 #ifndef QRK_URG_DEVICE_H
00002 #define QRK_URG_DEVICE_H
00003 
00013 #include "RangeSensor.h"
00014 #include "Coordinate.h"
00015 
00016 
00017 namespace qrk
00018 {
00019     class Connection;
00020 
00021 
00023     class UrgDevice : 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         UrgDevice(void);
00038         virtual ~UrgDevice(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 
00133         void setCaptureTimes(size_t times);
00134 
00135 
00143         size_t remainCaptureTimes(void);
00144 
00145 
00169         void setCaptureSkipLines(size_t skip_lines);
00170 
00171 
00172         int capture(std::vector<long>& data, long* timestamp = NULL);
00173 
00174 
00175         /*
00176           \brief Get intensity data and distance data.
00177 
00178           \attention Only Top-URG and Classic-URG supports this fuction (2008-12-24)
00179         */
00180         int captureWithIntensity(std::vector<long>& data,
00181                                  std::vector<long>& intensity_data,
00182                                  long* timestamp = NULL);
00183 
00184 
00190         void stop(void);
00191 
00192 
00193         bool setTimestamp(int timestamp = 0, int* response_msec = NULL,
00194                           int* force_delay_msec = NULL);
00195 
00196         long recentTimestamp(void) const;
00197 
00198 
00204         bool setLaserOutput(bool on);
00205 
00206         double index2rad(const int index) const;
00207         int rad2index(const double radian) const;
00208 
00209         void setParameter(const RangeSensorParameter& parameter);
00210         RangeSensorParameter parameter(void) const;
00211 
00212 
00219         bool loadParameter(void);
00220 
00221 
00233         bool versionLines(std::vector<std::string>& lines);
00234 
00235 
00241         bool reboot(void);
00242 
00243 
00244     protected:
00245         virtual void captureReceived(void);
00246 
00247 
00248     private:
00249         UrgDevice(const UrgDevice& rhs);
00250         UrgDevice& operator = (const UrgDevice& rhs);
00251 
00252         struct pImpl;
00253         std::auto_ptr<pImpl> pimpl;
00254     };
00255 }
00256 
00257 #endif /* !QRK_URG_DEVICE_H */