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 namespace rp { namespace standalone{ namespace rplidar {
00038
00039 class RPlidarDriverSerialImpl : public RPlidarDriver
00040 {
00041 public:
00042
00043 enum {
00044 MAX_SCAN_NODES = 2048,
00045 };
00046
00047 enum {
00048 LEGACY_SAMPLE_DURATION = 476,
00049 };
00050
00051 RPlidarDriverSerialImpl();
00052 virtual ~RPlidarDriverSerialImpl();
00053
00054 public:
00055 virtual u_result connect(const char * port_path, _u32 baudrate, _u32 flag);
00056 virtual void disconnect();
00057 virtual bool isConnected();
00058
00059 virtual u_result reset(_u32 timeout = DEFAULT_TIMEOUT);
00060
00061 virtual u_result getHealth(rplidar_response_device_health_t &, _u32 timeout = DEFAULT_TIMEOUT);
00062 virtual u_result getDeviceInfo(rplidar_response_device_info_t &, _u32 timeout = DEFAULT_TIMEOUT);
00063 virtual u_result getSampleDuration_uS(rplidar_response_sample_rate_t & rateInfo, _u32 timeout = DEFAULT_TIMEOUT);
00064
00065 virtual u_result setMotorPWM(_u16 pwm);
00066 virtual u_result startMotor();
00067 virtual u_result stopMotor();
00068 virtual u_result checkMotorCtrlSupport(bool & support, _u32 timeout = DEFAULT_TIMEOUT);
00069 virtual u_result getFrequency(bool inExpressMode, size_t count, float & frequency, bool & is4kmode);
00070
00071 virtual u_result startScan(bool force = false, bool autoExpressMode = true);
00072 virtual u_result startScanNormal(bool force, _u32 timeout = DEFAULT_TIMEOUT);
00073 virtual u_result startScanExpress(bool fixedAngle, _u32 timeout = DEFAULT_TIMEOUT);
00074 virtual u_result checkExpressScanSupported(bool & support, _u32 timeout = DEFAULT_TIMEOUT);
00075
00076 virtual u_result stop(_u32 timeout = DEFAULT_TIMEOUT);
00077 virtual u_result grabScanData(rplidar_response_measurement_node_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT);
00078 virtual u_result ascendScanData(rplidar_response_measurement_node_t * nodebuffer, size_t count);
00079
00080 protected:
00081 u_result _waitNode(rplidar_response_measurement_node_t * node, _u32 timeout = DEFAULT_TIMEOUT);
00082 u_result _waitScanData(rplidar_response_measurement_node_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT);
00083 u_result _cacheScanData();
00084 void _capsuleToNormal(const rplidar_response_capsule_measurement_nodes_t & capsule, rplidar_response_measurement_node_t *nodebuffer, size_t &nodeCount);
00085 u_result _waitCapsuledNode(rplidar_response_capsule_measurement_nodes_t & node, _u32 timeout = DEFAULT_TIMEOUT);
00086 u_result _cacheCapsuledScanData();
00087 u_result _sendCommand(_u8 cmd, const void * payload = NULL, size_t payloadsize = 0);
00088 u_result _waitResponseHeader(rplidar_ans_header_t * header, _u32 timeout = DEFAULT_TIMEOUT);
00089 u_result _waitSampleRate(rplidar_response_sample_rate_t * res, _u32 timeout = DEFAULT_TIMEOUT);
00090
00091 void _disableDataGrabbing();
00092
00093 bool _isConnected;
00094 bool _isScanning;
00095 bool _isSupportingMotorCtrl;
00096
00097 rp::hal::Locker _lock;
00098 rp::hal::Event _dataEvt;
00099 rp::hal::serial_rxtx * _rxtx;
00100 rplidar_response_measurement_node_t _cached_scan_node_buf[2048];
00101 size_t _cached_scan_node_count;
00102
00103 _u16 _cached_sampleduration_std;
00104 _u16 _cached_sampleduration_express;
00105
00106 rplidar_response_capsule_measurement_nodes_t _cached_previous_capsuledata;
00107 bool _is_previous_capsuledataRdy;
00108
00109 rp::hal::Thread _cachethread;
00110 };
00111
00112
00113 }}}