rplidar_driver.h
Go to the documentation of this file.
1 /*
2  * RPLIDAR SDK
3  *
4  * Copyright (c) 2009 - 2014 RoboPeak Team
5  * http://www.robopeak.com
6  * Copyright (c) 2014 - 2019 Shanghai Slamtec Co., Ltd.
7  * http://www.slamtec.com
8  *
9  */
10 /*
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  *
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 
35 #pragma once
36 
37 
38 #ifndef __cplusplus
39 #error "The RPlidar SDK requires a C++ compiler to be built"
40 #endif
41 
42 #ifndef DEPRECATED
43  #ifdef __GNUC__
44  #define DEPRECATED(func) func __attribute__ ((deprecated))
45  #elif defined(_MSC_VER)
46  #define DEPRECATED(func) __declspec(deprecated) func
47  #else
48  #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
49  #define DEPRECATED(func) func
50  #endif
51 #endif
52 
53 namespace rp { namespace standalone{ namespace rplidar {
54 
57  float us_per_sample; // microseconds per sample
58  float max_distance; // max distance
59  _u8 ans_type; // the answer type of the scam mode, its value should be RPLIDAR_ANS_TYPE_MEASUREMENT*
60  char scan_mode[64]; // name of scan mode, max 63 characters
61 };
62 
63 enum {
66 };
67 
69 {
70 public:
71  virtual bool bind(const char*, uint32_t ) = 0;
72  virtual bool open() {return true;}
73  virtual void close() = 0;
74  virtual void flush() {return;}
75  virtual bool waitfordata(size_t data_count,_u32 timeout = -1, size_t * returned_size = NULL) = 0;
76  virtual int senddata(const _u8 * data, size_t size) = 0;
77  virtual int recvdata(unsigned char * data, size_t size) = 0;
78  virtual void setDTR() {return;}
79  virtual void clearDTR() {return;}
80  virtual void ReleaseRxTx() {return;}
81 };
82 
84 public:
85  enum {
86  DEFAULT_TIMEOUT = 2000, //2000 ms
87  };
88 
89  enum {
90  MAX_SCAN_NODES = 8192,
91  };
92 
93  enum {
94  LEGACY_SAMPLE_DURATION = 476,
95  };
96 
97 public:
102  static RPlidarDriver * CreateDriver(_u32 drivertype = DRIVER_TYPE_SERIALPORT);
103 
106  static void DisposeDriver(RPlidarDriver * drv);
107 
108 
120  virtual u_result connect(const char *, _u32, _u32 flag = 0) = 0;
121 
122 
124  virtual void disconnect() = 0;
125 
127  virtual bool isConnected() = 0;
128 
133  virtual u_result reset(_u32 timeout = DEFAULT_TIMEOUT) = 0;
134 
135  virtual u_result clearNetSerialRxCache() = 0;
136  // FW1.24
138  virtual u_result getAllSupportedScanModes(std::vector<RplidarScanMode>& outModes, _u32 timeoutInMs = DEFAULT_TIMEOUT) = 0;
139 
141  virtual u_result getTypicalScanMode(_u16& outMode, _u32 timeoutInMs = DEFAULT_TIMEOUT) = 0;
142 
149  virtual u_result startScan(bool force, bool useTypicalScan, _u32 options = 0, RplidarScanMode* outUsedScanMode = NULL) = 0;
150 
157  virtual u_result startScanExpress(bool force, _u16 scanMode, _u32 options = 0, RplidarScanMode* outUsedScanMode = NULL, _u32 timeout = DEFAULT_TIMEOUT) = 0;
158 
165  virtual u_result getHealth(rplidar_response_device_health_t & health, _u32 timeout = DEFAULT_TIMEOUT) = 0;
166 
171  virtual u_result getDeviceInfo(rplidar_response_device_info_t & info, _u32 timeout = DEFAULT_TIMEOUT) = 0;
172 
178  DEPRECATED(virtual u_result getSampleDuration_uS(rplidar_response_sample_rate_t & rateInfo, _u32 timeout = DEFAULT_TIMEOUT)) = 0;
179 
183  virtual u_result setMotorPWM(_u16 pwm) = 0;
184 
188  virtual u_result setLidarSpinSpeed(_u16 rpm, _u32 timeout = DEFAULT_TIMEOUT) = 0;
189 
191  virtual u_result startMotor() = 0;
192 
194  virtual u_result stopMotor() = 0;
195 
201  virtual u_result checkMotorCtrlSupport(bool & support, _u32 timeout = DEFAULT_TIMEOUT) = 0;
202 
208  virtual u_result checkIfTofLidar(bool & isTofLidar, _u32 timeout = DEFAULT_TIMEOUT) = 0;
209 
220  DEPRECATED(virtual u_result getFrequency(bool inExpressMode, size_t count, float & frequency, bool & is4kmode)) = 0;
221 
228  virtual u_result getFrequency(const RplidarScanMode& scanMode, size_t count, float & frequency) = 0;
229 
236  virtual u_result startScanNormal(bool force, _u32 timeout = DEFAULT_TIMEOUT) = 0;
237 
243  DEPRECATED(virtual u_result checkExpressScanSupported(bool & support, _u32 timeout = DEFAULT_TIMEOUT)) = 0;
244 
248  virtual u_result stop(_u32 timeout = DEFAULT_TIMEOUT) = 0;
249 
250 
269  DEPRECATED(virtual u_result grabScanData(rplidar_response_measurement_node_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT)) = 0;
270 
288  virtual u_result grabScanDataHq(rplidar_response_measurement_node_hq_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT) = 0;
289 
297  DEPRECATED(virtual u_result ascendScanData(rplidar_response_measurement_node_t * nodebuffer, size_t count)) = 0;
298 
306  virtual u_result ascendScanData(rplidar_response_measurement_node_hq_t * nodebuffer, size_t count) = 0;
307 
315  DEPRECATED(virtual u_result getScanDataWithInterval(rplidar_response_measurement_node_t * nodebuffer, size_t & count)) = 0;
316 
327  virtual u_result getScanDataWithIntervalHq(rplidar_response_measurement_node_hq_t * nodebuffer, size_t & count) = 0;
328 
329  virtual ~RPlidarDriver() {}
330 protected:
332 
333 public:
335 };
336 
337 
338 
339 
340 }}}
_u8 flag
Definition: rplidar_cmd.h:2
_u8 size
uint8_t _u8
Definition: rptypes.h:63
#define DEPRECATED(func)
_u16 rpm
Definition: rplidar_cmd.h:2
uint32_t _u32
Definition: rptypes.h:69
uint16_t _u16
Definition: rptypes.h:66
_u8 data[0]
RPlidarDriver * drv
Definition: node.cpp:48
uint32_t u_result
Definition: rptypes.h:100


rplidar_ros
Author(s):
autogenerated on Wed Jan 1 2020 04:01:40