Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #pragma once
00036
00037
00038 #ifndef __cplusplus
00039 #error "The RPlidar SDK requires a C++ compiler to be built"
00040 #endif
00041
00042 #ifndef DEPRECATED
00043 #ifdef __GNUC__
00044 #define DEPRECATED(func) func __attribute__ ((deprecated))
00045 #elif defined(_MSC_VER)
00046 #define DEPRECATED(func) __declspec(deprecated) func
00047 #else
00048 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
00049 #define DEPRECATED(func) func
00050 #endif
00051 #endif
00052
00053 namespace rp { namespace standalone{ namespace rplidar {
00054
00055 struct RplidarScanMode {
00056 _u16 id;
00057 float us_per_sample;
00058 float max_distance;
00059 _u8 ans_type;
00060 char scan_mode[64];
00061 };
00062
00063 enum {
00064 DRIVER_TYPE_SERIALPORT = 0x0,
00065 DRIVER_TYPE_TCP = 0x1,
00066 };
00067
00068 class ChannelDevice
00069 {
00070 public:
00071 virtual bool bind(const char*, uint32_t ) = 0;
00072 virtual bool open() {return true;}
00073 virtual void close() = 0;
00074 virtual void flush() {return;}
00075 virtual bool waitfordata(size_t data_count,_u32 timeout = -1, size_t * returned_size = NULL) = 0;
00076 virtual int senddata(const _u8 * data, size_t size) = 0;
00077 virtual int recvdata(unsigned char * data, size_t size) = 0;
00078 virtual void setDTR() {return;}
00079 virtual void clearDTR() {return;}
00080 virtual void ReleaseRxTx() {return;}
00081 };
00082
00083 class RPlidarDriver {
00084 public:
00085 enum {
00086 DEFAULT_TIMEOUT = 2000,
00087 };
00088
00089 enum {
00090 MAX_SCAN_NODES = 8192,
00091 };
00092
00093 enum {
00094 LEGACY_SAMPLE_DURATION = 476,
00095 };
00096
00097 public:
00102 static RPlidarDriver * CreateDriver(_u32 drivertype = DRIVER_TYPE_SERIALPORT);
00103
00106 static void DisposeDriver(RPlidarDriver * drv);
00107
00108
00120 virtual u_result connect(const char *, _u32, _u32 flag = 0) = 0;
00121
00122
00124 virtual void disconnect() = 0;
00125
00127 virtual bool isConnected() = 0;
00128
00133 virtual u_result reset(_u32 timeout = DEFAULT_TIMEOUT) = 0;
00134
00135 virtual u_result clearNetSerialRxCache() = 0;
00136
00138 virtual u_result getAllSupportedScanModes(std::vector<RplidarScanMode>& outModes, _u32 timeoutInMs = DEFAULT_TIMEOUT) = 0;
00139
00141 virtual u_result getTypicalScanMode(_u16& outMode, _u32 timeoutInMs = DEFAULT_TIMEOUT) = 0;
00142
00149 virtual u_result startScan(bool force, bool useTypicalScan, _u32 options = 0, RplidarScanMode* outUsedScanMode = NULL) = 0;
00150
00157 virtual u_result startScanExpress(bool force, _u16 scanMode, _u32 options = 0, RplidarScanMode* outUsedScanMode = NULL, _u32 timeout = DEFAULT_TIMEOUT) = 0;
00158
00165 virtual u_result getHealth(rplidar_response_device_health_t & health, _u32 timeout = DEFAULT_TIMEOUT) = 0;
00166
00171 virtual u_result getDeviceInfo(rplidar_response_device_info_t & info, _u32 timeout = DEFAULT_TIMEOUT) = 0;
00172
00178 DEPRECATED(virtual u_result getSampleDuration_uS(rplidar_response_sample_rate_t & rateInfo, _u32 timeout = DEFAULT_TIMEOUT)) = 0;
00179
00183 virtual u_result setMotorPWM(_u16 pwm) = 0;
00184
00186 virtual u_result startMotor() = 0;
00187
00189 virtual u_result stopMotor() = 0;
00190
00196 virtual u_result checkMotorCtrlSupport(bool & support, _u32 timeout = DEFAULT_TIMEOUT) = 0;
00197
00208 DEPRECATED(virtual u_result getFrequency(bool inExpressMode, size_t count, float & frequency, bool & is4kmode)) = 0;
00209
00216 virtual u_result getFrequency(const RplidarScanMode& scanMode, size_t count, float & frequency) = 0;
00217
00224 virtual u_result startScanNormal(bool force, _u32 timeout = DEFAULT_TIMEOUT) = 0;
00225
00231 DEPRECATED(virtual u_result checkExpressScanSupported(bool & support, _u32 timeout = DEFAULT_TIMEOUT)) = 0;
00232
00236 virtual u_result stop(_u32 timeout = DEFAULT_TIMEOUT) = 0;
00237
00238
00257 DEPRECATED(virtual u_result grabScanData(rplidar_response_measurement_node_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT)) = 0;
00258
00276 virtual u_result grabScanDataHq(rplidar_response_measurement_node_hq_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT) = 0;
00277
00285 DEPRECATED(virtual u_result ascendScanData(rplidar_response_measurement_node_t * nodebuffer, size_t count)) = 0;
00286
00294 virtual u_result ascendScanData(rplidar_response_measurement_node_hq_t * nodebuffer, size_t count) = 0;
00295
00303 DEPRECATED(virtual u_result getScanDataWithInterval(rplidar_response_measurement_node_t * nodebuffer, size_t & count)) = 0;
00304
00312 virtual u_result getScanDataWithIntervalHq(rplidar_response_measurement_node_hq_t * nodebuffer, size_t & count) = 0;
00313
00314 virtual ~RPlidarDriver() {}
00315 protected:
00316 RPlidarDriver(){}
00317
00318 public:
00319 ChannelDevice* _chanDev;
00320 };
00321
00322
00323
00324
00325 }}}