MRPT  1.9.9
rplidar_driver_serial.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://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 #include "rplidar_cmd.h"
37 #include "rplidar_driver.h"
38 
40 {
42 {
43  public:
44  enum
45  {
47  };
48 
49  enum
50  {
52  };
53 
55  ~RPlidarDriverSerialImpl() override;
56 
57  public:
58  u_result connect(const char* port_path, _u32 baudrate, _u32 flag) override;
59  void disconnect() override;
60  bool isConnected() override;
61 
62  u_result reset(_u32 timeout = DEFAULT_TIMEOUT) override;
63 
65  rplidar_response_device_health_t&,
66  _u32 timeout = DEFAULT_TIMEOUT) override;
68  rplidar_response_device_info_t&,
69  _u32 timeout = DEFAULT_TIMEOUT) override;
71  rplidar_response_sample_rate_t& rateInfo,
72  _u32 timeout = DEFAULT_TIMEOUT) override;
73 
74  u_result setMotorPWM(_u16 pwm) override;
75  u_result startMotor() override;
76  u_result stopMotor() override;
78  bool& support, _u32 timeout = DEFAULT_TIMEOUT) override;
80  bool inExpressMode, size_t count, float& frequency,
81  bool& is4kmode) override;
82 
84  bool force = false, bool autoExpressMode = true) override;
86  bool force, _u32 timeout = DEFAULT_TIMEOUT) override;
88  bool fixedAngle, _u32 timeout = DEFAULT_TIMEOUT) override;
90  bool& support, _u32 timeout = DEFAULT_TIMEOUT) override;
91 
92  u_result stop(_u32 timeout = DEFAULT_TIMEOUT) override;
94  rplidar_response_measurement_node_t* nodebuffer, size_t& count,
95  _u32 timeout = DEFAULT_TIMEOUT) override;
97  rplidar_response_measurement_node_t* nodebuffer, size_t count) override;
98 
99  protected:
101  rplidar_response_measurement_node_t* node,
102  _u32 timeout = DEFAULT_TIMEOUT);
104  rplidar_response_measurement_node_t* nodebuffer, size_t& count,
105  _u32 timeout = DEFAULT_TIMEOUT);
107  void _capsuleToNormal(
108  const rplidar_response_capsule_measurement_nodes_t& capsule,
109  rplidar_response_measurement_node_t* nodebuffer, size_t& nodeCount);
111  rplidar_response_capsule_measurement_nodes_t& node,
112  _u32 timeout = DEFAULT_TIMEOUT);
115  _u8 cmd, const void* payload = nullptr, size_t payloadsize = 0);
117  rplidar_ans_header_t* header, _u32 timeout = DEFAULT_TIMEOUT);
119  rplidar_response_sample_rate_t* res, _u32 timeout = DEFAULT_TIMEOUT);
120 
121  void _disableDataGrabbing();
122 
123  bool _isConnected{false};
124  bool _isScanning{false};
126 
130  rplidar_response_measurement_node_t _cached_scan_node_buf[2048];
132 
135 
136  rplidar_response_capsule_measurement_nodes_t _cached_previous_capsuledata;
138 
140 };
141 } // namespace rp::standalone::rplidar
GLuint GLuint GLsizei count
Definition: glext.h:3532
u_result stopMotor() override
Stop RPLIDAR's motor when using accessory board.
u_result checkMotorCtrlSupport(bool &support, _u32 timeout=DEFAULT_TIMEOUT) override
Check whether the device support motor control.
u_result startScanNormal(bool force, _u32 timeout=DEFAULT_TIMEOUT) override
u_result stop(_u32 timeout=DEFAULT_TIMEOUT) override
Ask the RPLIDAR core system to stop the current scan operation and enter idle state.
u_result setMotorPWM(_u16 pwm) override
Set the RPLIDAR's motor pwm when using accessory board, currently valid for A2 only.
void _capsuleToNormal(const rplidar_response_capsule_measurement_nodes_t &capsule, rplidar_response_measurement_node_t *nodebuffer, size_t &nodeCount)
u_result startMotor() override
Start RPLIDAR's motor when using accessory board.
u_result ascendScanData(rplidar_response_measurement_node_t *nodebuffer, size_t count) override
Ascending the scan data according to the angle value in the scan.
u_result getHealth(rplidar_response_device_health_t &, _u32 timeout=DEFAULT_TIMEOUT) override
Retrieve the health status of the RPLIDAR The host system can use this operation to check whether RPL...
rplidar_response_capsule_measurement_nodes_t _cached_previous_capsuledata
uint8_t _u8
Definition: rptypes.h:63
nv_oem6_header_t header
Novatel frame: NV_OEM6_BESTPOS.
u_result getFrequency(bool inExpressMode, size_t count, float &frequency, bool &is4kmode) override
Calcuate RPLIDAR's current scanning frequency from the given scan data Please refer to the applicatio...
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 grabScanData(rplidar_response_measurement_node_t *nodebuffer, size_t &count, _u32 timeout=DEFAULT_TIMEOUT) override
Wait and grab a complete 0-360 degree scan data previously received.
u_result checkExpressScanSupported(bool &support, _u32 timeout=DEFAULT_TIMEOUT) override
Check whether the device support express mode.
u_result startScan(bool force=false, bool autoExpressMode=true) override
Ask the RPLIDAR core system to enter the scan mode(Normal/Express, Express mode is 4k mode) A backgro...
u_result reset(_u32 timeout=DEFAULT_TIMEOUT) override
Ask the RPLIDAR core system to reset it self The host system can use the Reset operation to help RPLI...
u_result _waitSampleRate(rplidar_response_sample_rate_t *res, _u32 timeout=DEFAULT_TIMEOUT)
u_result _sendCommand(_u8 cmd, const void *payload=nullptr, size_t payloadsize=0)
void disconnect() override
Disconnect with the RPLIDAR and close the serial port.
bool isConnected() override
Returns TRUE when the connection has been established.
rplidar_response_measurement_node_t _cached_scan_node_buf[2048]
uint32_t _u32
Definition: rptypes.h:69
u_result _waitCapsuledNode(rplidar_response_capsule_measurement_nodes_t &node, _u32 timeout=DEFAULT_TIMEOUT)
GLuint res
Definition: glext.h:7385
uint16_t _u16
Definition: rptypes.h:66
u_result getDeviceInfo(rplidar_response_device_info_t &, _u32 timeout=DEFAULT_TIMEOUT) override
Get the device information of the RPLIDAR include the serial number, firmware version, device model etc.
u_result getSampleDuration_uS(rplidar_response_sample_rate_t &rateInfo, _u32 timeout=DEFAULT_TIMEOUT) override
Get the sample duration information of the RPLIDAR.
u_result startScanExpress(bool fixedAngle, _u32 timeout=DEFAULT_TIMEOUT) override
u_result connect(const char *port_path, _u32 baudrate, _u32 flag) override
Open the specified serial port and connect to a target RPLIDAR device.
uint32_t u_result
Definition: rptypes.h:98
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: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019