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 
37 {
39 {
40  public:
41  enum
42  {
44  };
45 
46  enum
47  {
49  };
50 
52  virtual ~RPlidarDriverSerialImpl();
53 
54  public:
55  virtual u_result connect(const char* port_path, _u32 baudrate, _u32 flag);
56  virtual void disconnect();
57  virtual bool isConnected();
58 
59  virtual u_result reset(_u32 timeout = DEFAULT_TIMEOUT);
60 
61  virtual u_result getHealth(
62  rplidar_response_device_health_t&, _u32 timeout = DEFAULT_TIMEOUT);
63  virtual u_result getDeviceInfo(
64  rplidar_response_device_info_t&, _u32 timeout = DEFAULT_TIMEOUT);
66  rplidar_response_sample_rate_t& rateInfo,
67  _u32 timeout = DEFAULT_TIMEOUT);
68 
69  virtual u_result setMotorPWM(_u16 pwm);
70  virtual u_result startMotor();
71  virtual u_result stopMotor();
73  bool& support, _u32 timeout = DEFAULT_TIMEOUT);
74  virtual u_result getFrequency(
75  bool inExpressMode, size_t count, float& frequency, bool& is4kmode);
76 
77  virtual u_result startScan(bool force = false, bool autoExpressMode = true);
78  virtual u_result startScanNormal(
79  bool force, _u32 timeout = DEFAULT_TIMEOUT);
80  virtual u_result startScanExpress(
81  bool fixedAngle, _u32 timeout = DEFAULT_TIMEOUT);
83  bool& support, _u32 timeout = DEFAULT_TIMEOUT);
84 
85  virtual u_result stop(_u32 timeout = DEFAULT_TIMEOUT);
86  virtual u_result grabScanData(
87  rplidar_response_measurement_node_t* nodebuffer, size_t& count,
88  _u32 timeout = DEFAULT_TIMEOUT);
89  virtual u_result ascendScanData(
90  rplidar_response_measurement_node_t* nodebuffer, size_t count);
91 
92  protected:
94  rplidar_response_measurement_node_t* node,
95  _u32 timeout = DEFAULT_TIMEOUT);
97  rplidar_response_measurement_node_t* nodebuffer, size_t& count,
98  _u32 timeout = DEFAULT_TIMEOUT);
100  void _capsuleToNormal(
101  const rplidar_response_capsule_measurement_nodes_t& capsule,
102  rplidar_response_measurement_node_t* nodebuffer, size_t& nodeCount);
104  rplidar_response_capsule_measurement_nodes_t& node,
105  _u32 timeout = DEFAULT_TIMEOUT);
108  _u8 cmd, const void* payload = nullptr, size_t payloadsize = 0);
110  rplidar_ans_header_t* header, _u32 timeout = DEFAULT_TIMEOUT);
112  rplidar_response_sample_rate_t* res, _u32 timeout = DEFAULT_TIMEOUT);
113 
114  void _disableDataGrabbing();
115 
119 
123  rplidar_response_measurement_node_t _cached_scan_node_buf[2048];
125 
128 
129  rplidar_response_capsule_measurement_nodes_t _cached_previous_capsuledata;
131 
133 };
134 }
135 
GLuint GLuint GLsizei count
Definition: glext.h:3528
virtual u_result startScanNormal(bool force, _u32 timeout=DEFAULT_TIMEOUT)
virtual bool isConnected()
Returns TRUE when the connection has been established.
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.
void _capsuleToNormal(const rplidar_response_capsule_measurement_nodes_t &capsule, rplidar_response_measurement_node_t *nodebuffer, size_t &nodeCount)
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...
virtual u_result getSampleDuration_uS(rplidar_response_sample_rate_t &rateInfo, _u32 timeout=DEFAULT_TIMEOUT)
Get the sample duration information of the RPLIDAR.
virtual u_result connect(const char *port_path, _u32 baudrate, _u32 flag)
Open the specified serial port and connect to a target RPLIDAR device.
virtual u_result startScanExpress(bool fixedAngle, _u32 timeout=DEFAULT_TIMEOUT)
virtual void disconnect()
Disconnect with the RPLIDAR and close the serial port.
rplidar_response_capsule_measurement_nodes_t _cached_previous_capsuledata
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.
uint8_t _u8
Definition: rptypes.h:60
virtual u_result stopMotor()
Stop RPLIDAR's motor when using accessory board.
nv_oem6_header_t header
Novatel frame: NV_OEM6_BESTPOS.
virtual u_result checkMotorCtrlSupport(bool &support, _u32 timeout=DEFAULT_TIMEOUT)
Check whether the device support motor control.
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...
virtual u_result startMotor()
Start RPLIDAR's motor when using accessory board.
virtual u_result setMotorPWM(_u16 pwm)
Set the RPLIDAR's motor pwm when using accessory board, currently valid for A2 only.
u_result _waitResponseHeader(rplidar_ans_header_t *header, _u32 timeout=DEFAULT_TIMEOUT)
u_result _waitNode(rplidar_response_measurement_node_t *node, _u32 timeout=DEFAULT_TIMEOUT)
u_result _waitSampleRate(rplidar_response_sample_rate_t *res, _u32 timeout=DEFAULT_TIMEOUT)
virtual u_result checkExpressScanSupported(bool &support, _u32 timeout=DEFAULT_TIMEOUT)
Check whether the device support express mode.
u_result _sendCommand(_u8 cmd, const void *payload=nullptr, size_t payloadsize=0)
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, device model etc.
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...
rplidar_response_measurement_node_t _cached_scan_node_buf[2048]
uint32_t _u32
Definition: rptypes.h:66
u_result _waitCapsuledNode(rplidar_response_capsule_measurement_nodes_t &node, _u32 timeout=DEFAULT_TIMEOUT)
virtual u_result stop(_u32 timeout=DEFAULT_TIMEOUT)
Ask the RPLIDAR core system to stop the current scan operation and enter idle state.
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...
GLuint res
Definition: glext.h:7268
uint16_t _u16
Definition: rptypes.h:63
uint32_t u_result
Definition: rptypes.h:95
u_result _waitScanData(rplidar_response_measurement_node_t *nodebuffer, size_t &count, _u32 timeout=DEFAULT_TIMEOUT)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020