Main MRPT website > C++ reference for MRPT 1.9.9
rplidar_driver_serial.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 /*
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #pragma once
35 
36 namespace rp
37 {
38 namespace standalone
39 {
40 namespace rplidar
41 {
43 {
44  public:
45  enum
46  {
48  };
49 
50  enum
51  {
53  };
54 
56  virtual ~RPlidarDriverSerialImpl();
57 
58  public:
59  virtual u_result connect(const char* port_path, _u32 baudrate, _u32 flag);
60  virtual void disconnect();
61  virtual bool isConnected();
62 
63  virtual u_result reset(_u32 timeout = DEFAULT_TIMEOUT);
64 
65  virtual u_result getHealth(
66  rplidar_response_device_health_t&, _u32 timeout = DEFAULT_TIMEOUT);
67  virtual u_result getDeviceInfo(
68  rplidar_response_device_info_t&, _u32 timeout = DEFAULT_TIMEOUT);
70  rplidar_response_sample_rate_t& rateInfo,
71  _u32 timeout = DEFAULT_TIMEOUT);
72 
73  virtual u_result setMotorPWM(_u16 pwm);
74  virtual u_result startMotor();
75  virtual u_result stopMotor();
77  bool& support, _u32 timeout = DEFAULT_TIMEOUT);
78  virtual u_result getFrequency(
79  bool inExpressMode, size_t count, float& frequency, bool& is4kmode);
80 
81  virtual u_result startScan(bool force = false, bool autoExpressMode = true);
82  virtual u_result startScanNormal(
83  bool force, _u32 timeout = DEFAULT_TIMEOUT);
84  virtual u_result startScanExpress(
85  bool fixedAngle, _u32 timeout = DEFAULT_TIMEOUT);
87  bool& support, _u32 timeout = DEFAULT_TIMEOUT);
88 
89  virtual u_result stop(_u32 timeout = DEFAULT_TIMEOUT);
90  virtual u_result grabScanData(
91  rplidar_response_measurement_node_t* nodebuffer, size_t& count,
92  _u32 timeout = DEFAULT_TIMEOUT);
93  virtual u_result ascendScanData(
94  rplidar_response_measurement_node_t* nodebuffer, size_t count);
95 
96  protected:
98  rplidar_response_measurement_node_t* node,
99  _u32 timeout = DEFAULT_TIMEOUT);
101  rplidar_response_measurement_node_t* nodebuffer, size_t& count,
102  _u32 timeout = DEFAULT_TIMEOUT);
104  void _capsuleToNormal(
105  const rplidar_response_capsule_measurement_nodes_t& capsule,
106  rplidar_response_measurement_node_t* nodebuffer, size_t& nodeCount);
108  rplidar_response_capsule_measurement_nodes_t& node,
109  _u32 timeout = DEFAULT_TIMEOUT);
112  _u8 cmd, const void* payload = nullptr, size_t payloadsize = 0);
114  rplidar_ans_header_t* header, _u32 timeout = DEFAULT_TIMEOUT);
116  rplidar_response_sample_rate_t* res, _u32 timeout = DEFAULT_TIMEOUT);
117 
118  void _disableDataGrabbing();
119 
123 
127  rplidar_response_measurement_node_t _cached_scan_node_buf[2048];
129 
132 
133  rplidar_response_capsule_measurement_nodes_t _cached_previous_capsuledata;
135 
137 };
138 }
139 }
140 }
rp::standalone::rplidar::RPlidarDriverSerialImpl::reset
virtual u_result reset(_u32 timeout=DEFAULT_TIMEOUT)
Ask the RPLIDAR core system to reset it self The host system can use the Reset operation to help RPLI...
Definition: rplidar_driver.cpp:118
_u16
uint16_t _u16
Definition: rptypes.h:63
rp::standalone::rplidar::RPlidarDriverSerialImpl::_disableDataGrabbing
void _disableDataGrabbing()
Definition: rplidar_driver.cpp:1031
u_result
uint32_t u_result
Definition: rptypes.h:95
rp::standalone::rplidar::RPlidarDriverSerialImpl::getSampleDuration_uS
virtual u_result getSampleDuration_uS(rplidar_response_sample_rate_t &rateInfo, _u32 timeout=DEFAULT_TIMEOUT)
Get the sample duration information of the RPLIDAR.
Definition: rplidar_driver.cpp:1037
rp::standalone::rplidar::RPlidarDriverSerialImpl::isConnected
virtual bool isConnected()
Returns TRUE when the connection has been established.
Definition: rplidar_driver.cpp:117
rp::standalone::rplidar::RPlidarDriverSerialImpl::_cachethread
rp::hal::Thread _cachethread
Definition: rplidar_driver_serial.h:136
rp::standalone::rplidar::RPlidarDriverSerialImpl::checkMotorCtrlSupport
virtual u_result checkMotorCtrlSupport(bool &support, _u32 timeout=DEFAULT_TIMEOUT)
Check whether the device support motor control.
Definition: rplidar_driver.cpp:1095
rp::standalone::rplidar::RPlidarDriverSerialImpl::RPlidarDriverSerialImpl
RPlidarDriverSerialImpl()
Definition: rplidar_driver.cpp:66
rp::standalone::rplidar::RPlidarDriverSerialImpl::startScanExpress
virtual u_result startScanExpress(bool fixedAngle, _u32 timeout=DEFAULT_TIMEOUT)
Definition: rplidar_driver.cpp:316
rp::standalone::rplidar::RPlidarDriverSerialImpl::_cached_previous_capsuledata
rplidar_response_capsule_measurement_nodes_t _cached_previous_capsuledata
Definition: rplidar_driver_serial.h:133
rp::standalone::rplidar::RPlidarDriver::DEFAULT_TIMEOUT
@ DEFAULT_TIMEOUT
Definition: rplidar_driver.h:51
rp::standalone::rplidar::RPlidarDriverSerialImpl::MAX_SCAN_NODES
@ MAX_SCAN_NODES
Definition: rplidar_driver_serial.h:47
rp::standalone::rplidar::RPlidarDriverSerialImpl::getFrequency
virtual u_result getFrequency(bool inExpressMode, size_t count, float &frequency, bool &is4kmode)
Calcuate RPLIDAR's current scanning frequency from the given scan data Please refer to the applicatio...
Definition: rplidar_driver.cpp:227
rp::standalone::rplidar::RPlidarDriverSerialImpl::checkExpressScanSupported
virtual u_result checkExpressScanSupported(bool &support, _u32 timeout=DEFAULT_TIMEOUT)
Check whether the device support express mode.
Definition: rplidar_driver.cpp:294
rp::standalone::rplidar::RPlidarDriverSerialImpl::_lock
rp::hal::Locker _lock
Definition: rplidar_driver_serial.h:124
rp::standalone::rplidar::RPlidarDriverSerialImpl::_cached_scan_node_count
size_t _cached_scan_node_count
Definition: rplidar_driver_serial.h:128
rp::standalone::rplidar::RPlidarDriverSerialImpl::stopMotor
virtual u_result stopMotor()
Stop RPLIDAR's motor when using accessory board.
Definition: rplidar_driver.cpp:1193
rp::standalone::rplidar::RPlidarDriverSerialImpl::_isScanning
bool _isScanning
Definition: rplidar_driver_serial.h:121
rp::standalone::rplidar::RPlidarDriverSerialImpl::setMotorPWM
virtual u_result setMotorPWM(_u16 pwm)
Set the RPLIDAR's motor pwm when using accessory board, currently valid for A2 only.
Definition: rplidar_driver.cpp:1155
rp::hal::Event
Definition: event.h:39
rp::standalone::rplidar::RPlidarDriverSerialImpl::_dataEvt
rp::hal::Event _dataEvt
Definition: rplidar_driver_serial.h:125
_u8
uint8_t _u8
Definition: rptypes.h:60
mrpt::obs::gnss::header
nv_oem6_header_t header
Novatel frame: NV_OEM6_BESTPOS.
Definition: gnss_messages_novatel.h:226
rp::standalone::rplidar::RPlidarDriverSerialImpl::getHealth
virtual u_result getHealth(rplidar_response_device_health_t &, _u32 timeout=DEFAULT_TIMEOUT)
Retrieve the health status of the RPLIDAR The host system can use this operation to check whether RPL...
Definition: rplidar_driver.cpp:133
rp::hal::Thread
Definition: thread.h:43
rp::standalone::rplidar::RPlidarDriverSerialImpl::startScanNormal
virtual u_result startScanNormal(bool force, _u32 timeout=DEFAULT_TIMEOUT)
Definition: rplidar_driver.cpp:246
rp::standalone::rplidar::RPlidarDriverSerialImpl::LEGACY_SAMPLE_DURATION
@ LEGACY_SAMPLE_DURATION
Definition: rplidar_driver_serial.h:52
rp::standalone::rplidar::RPlidarDriverSerialImpl::ascendScanData
virtual u_result ascendScanData(rplidar_response_measurement_node_t *nodebuffer, size_t count)
Ascending the scan data according to the angle value in the scan.
Definition: rplidar_driver.cpp:643
rp::standalone::rplidar::RPlidarDriverSerialImpl::_cached_scan_node_buf
rplidar_response_measurement_node_t _cached_scan_node_buf[2048]
Definition: rplidar_driver_serial.h:127
rp::standalone::rplidar::RPlidarDriverSerialImpl::_waitScanData
u_result _waitScanData(rplidar_response_measurement_node_t *nodebuffer, size_t &count, _u32 timeout=DEFAULT_TIMEOUT)
Definition: rplidar_driver.cpp:798
rp::hal::Locker
Definition: locker.h:39
rp::standalone::rplidar::RPlidarDriverSerialImpl::~RPlidarDriverSerialImpl
virtual ~RPlidarDriverSerialImpl()
Definition: rplidar_driver.cpp:75
count
GLuint GLuint GLsizei count
Definition: glext.h:3528
rp::standalone::rplidar::RPlidarDriverSerialImpl::startMotor
virtual u_result startMotor()
Start RPLIDAR's motor when using accessory board.
Definition: rplidar_driver.cpp:1176
res
GLuint res
Definition: glext.h:7268
rp::standalone::rplidar::RPlidarDriverSerialImpl::disconnect
virtual void disconnect()
Disconnect with the RPLIDAR and close the serial port.
Definition: rplidar_driver.cpp:110
rp::standalone::rplidar::RPlidarDriverSerialImpl::_capsuleToNormal
void _capsuleToNormal(const rplidar_response_capsule_measurement_nodes_t &capsule, rplidar_response_measurement_node_t *nodebuffer, size_t &nodeCount)
Definition: rplidar_driver.cpp:462
rp::standalone::rplidar::RPlidarDriverSerialImpl::_cacheCapsuledScanData
u_result _cacheCapsuledScanData()
Definition: rplidar_driver.cpp:550
rp::standalone::rplidar::RPlidarDriverSerialImpl::_waitNode
u_result _waitNode(rplidar_response_measurement_node_t *node, _u32 timeout=DEFAULT_TIMEOUT)
Definition: rplidar_driver.cpp:729
rp::standalone::rplidar::RPlidarDriverSerialImpl::grabScanData
virtual u_result grabScanData(rplidar_response_measurement_node_t *nodebuffer, size_t &count, _u32 timeout=DEFAULT_TIMEOUT)
Wait and grab a complete 0-360 degree scan data previously received.
Definition: rplidar_driver.cpp:611
rp::standalone::rplidar::RPlidarDriverSerialImpl::_cached_sampleduration_express
_u16 _cached_sampleduration_express
Definition: rplidar_driver_serial.h:131
rp::standalone::rplidar::RPlidarDriverSerialImpl
Definition: rplidar_driver_serial.h:42
rp::standalone::rplidar::RPlidarDriverSerialImpl::startScan
virtual u_result startScan(bool force=false, bool autoExpressMode=true)
Ask the RPLIDAR core system to enter the scan mode(Normal/Express, Express mode is 4k mode) A backgro...
Definition: rplidar_driver.cpp:372
rp::standalone::rplidar::RPlidarDriverSerialImpl::_sendCommand
u_result _sendCommand(_u8 cmd, const void *payload=nullptr, size_t payloadsize=0)
Definition: rplidar_driver.cpp:928
rp::standalone::rplidar::RPlidarDriverSerialImpl::connect
virtual u_result connect(const char *port_path, _u32 baudrate, _u32 flag)
Open the specified serial port and connect to a target RPLIDAR device.
Definition: rplidar_driver.cpp:83
rp::standalone::rplidar::RPlidarDriverSerialImpl::_cacheScanData
u_result _cacheScanData()
Definition: rplidar_driver.cpp:409
rp::standalone::rplidar::RPlidarDriverSerialImpl::_is_previous_capsuledataRdy
bool _is_previous_capsuledataRdy
Definition: rplidar_driver_serial.h:134
rp::standalone::rplidar::RPlidarDriverSerialImpl::_isConnected
bool _isConnected
Definition: rplidar_driver_serial.h:120
rp::standalone::rplidar::RPlidarDriverSerialImpl::_waitResponseHeader
u_result _waitResponseHeader(rplidar_ans_header_t *header, _u32 timeout=DEFAULT_TIMEOUT)
Definition: rplidar_driver.cpp:975
rp::standalone::rplidar::RPlidarDriverSerialImpl::stop
virtual u_result stop(_u32 timeout=DEFAULT_TIMEOUT)
Ask the RPLIDAR core system to stop the current scan operation and enter idle state.
Definition: rplidar_driver.cpp:392
rp::hal::serial_rxtx
Definition: abs_rxtx.h:42
rp::standalone::rplidar::RPlidarDriverSerialImpl::_cached_sampleduration_std
_u16 _cached_sampleduration_std
Definition: rplidar_driver_serial.h:130
rp::standalone::rplidar::RPlidarDriverSerialImpl::_waitSampleRate
u_result _waitSampleRate(rplidar_response_sample_rate_t *res, _u32 timeout=DEFAULT_TIMEOUT)
rp
Definition: rplidar_driver.h:40
_u32
uint32_t _u32
Definition: rptypes.h:66
rp::standalone::rplidar::RPlidarDriverSerialImpl::_isSupportingMotorCtrl
bool _isSupportingMotorCtrl
Definition: rplidar_driver_serial.h:122
rp::standalone::rplidar::RPlidarDriverSerialImpl::getDeviceInfo
virtual u_result getDeviceInfo(rplidar_response_device_info_t &, _u32 timeout=DEFAULT_TIMEOUT)
Get the device information of the RPLIDAR include the serial number, firmware version,...
Definition: rplidar_driver.cpp:180
rp::standalone::rplidar::RPlidarDriver
Definition: rplidar_driver.h:46
rp::standalone::rplidar::RPlidarDriverSerialImpl::_waitCapsuledNode
u_result _waitCapsuledNode(rplidar_response_capsule_measurement_nodes_t &node, _u32 timeout=DEFAULT_TIMEOUT)
Definition: rplidar_driver.cpp:829
rp::standalone::rplidar::RPlidarDriverSerialImpl::_rxtx
rp::hal::serial_rxtx * _rxtx
Definition: rplidar_driver_serial.h:126



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST