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
00036
00037 #pragma once
00038
00039 namespace rp { namespace standalone{ namespace rplidar {
00040
00041 class RPlidarDriverSerialImpl : public RPlidarDriver
00042 {
00043 public:
00044
00045 enum {
00046 MAX_SCAN_NODES = 2048,
00047 };
00048
00049 RPlidarDriverSerialImpl();
00050 virtual ~RPlidarDriverSerialImpl();
00051
00052 public:
00053 virtual u_result connect(const char * port_path, _u32 baudrate, _u32 flag);
00054 virtual void disconnect();
00055 virtual bool isConnected();
00056
00057 virtual u_result reset(_u32 timeout = DEFAULT_TIMEOUT);
00058
00059 virtual u_result getHealth(rplidar_response_device_health_t &, _u32 timeout = DEFAULT_TIMEOUT);
00060 virtual u_result getDeviceInfo(rplidar_response_device_info_t &, _u32 timeout = DEFAULT_TIMEOUT);
00061 virtual u_result getFrequency(rplidar_response_measurement_node_t * nodebuffer, size_t count, float & frequency);
00062
00063 virtual u_result startScan(bool force, _u32 timeout = DEFAULT_TIMEOUT);
00064 virtual u_result stop(_u32 timeout = DEFAULT_TIMEOUT);
00065 virtual u_result grabScanData(rplidar_response_measurement_node_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT);
00066 virtual u_result ascendScanData(rplidar_response_measurement_node_t * nodebuffer, size_t count);
00067
00068 virtual u_result stopMotor();
00069 virtual u_result startMotor();
00070
00071
00072 protected:
00073 u_result _waitNode(rplidar_response_measurement_node_t * node, _u32 timeout);
00074 u_result _waitScanData(rplidar_response_measurement_node_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT);
00075 u_result _cacheScanData();
00076 u_result _sendCommand(_u8 cmd, const void * payload = NULL, size_t payloadsize = 0);
00077 u_result _waitResponseHeader(rplidar_ans_header_t * header, _u32 timeout);
00078
00079 void _disableDataGrabbing();
00080
00081 bool _isConnected;
00082 bool _isScanning;
00083
00084 rp::hal::Locker _lock;
00085 rp::hal::Event _dataEvt;
00086 rp::hal::serial_rxtx * _rxtx;
00087 rplidar_response_measurement_node_t _cached_scan_node_buf[2048];
00088 size_t _cached_scan_node_count;
00089 rp::hal::Thread _cachethread;
00090
00091
00092 };
00093
00094
00095 }}}