diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index dafad8a7..a6af961a 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,11 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package rplidar_ros
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+1.10.0 (2021-10-27)
+------------------
+* Update RPLIDAR SDK to 2.0.0
+* [new feature] 1.redesign the skelton of the sdk. 2.support Rplidar S2
+* Contributors: tony,WubinXia
1.10.0 (2019-02-22)
------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a5f22489..50483f73 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 2.8.3)
project(rplidar_ros)
set(RPLIDAR_SDK_PATH "./sdk/")
+set(CMAKE_BUILD_TYPE "Release")
+set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
FILE(GLOB RPLIDAR_SDK_SRC
"${RPLIDAR_SDK_PATH}/src/arch/linux/*.cpp"
diff --git a/README.md b/README.md
index 12d2a236..da9cec91 100644
--- a/README.md
+++ b/README.md
@@ -27,8 +27,10 @@ I. Run rplidar node and view in the rviz
roslaunch rplidar_ros view_rplidar.launch (for RPLIDAR A1/A2)
,
roslaunch rplidar_ros view_rplidar_a3.launch (for RPLIDAR A3)
-or
+,
roslaunch rplidar_ros view_rplidar_s1.launch (for RPLIDAR S1)
+or
+roslaunch rplidar_ros view_rplidar_s2.launch (for RPLIDAR S2)
You should see rplidar's scan result in the rviz.
@@ -37,14 +39,16 @@ II. Run rplidar node and view using test application
roslaunch rplidar_ros rplidar.launch (for RPLIDAR A1/A2)
,
roslaunch rplidar_ros rplidar_a3.launch (for RPLIDAR A3)
-or
+,
roslaunch rplidar_ros rplidar_s1.launch (for RPLIDAR S1)
+or
+roslaunch rplidar_ros rplidar_s2.launch (for RPLIDAR S2)
rosrun rplidar_ros rplidarNodeClient
You should see rplidar's scan result in the console
-Notice: the different is serial_baudrate between A1/A2 and A3/S1
+Notice: the different is serial_baudrate between A1/A2<115200> , A3/S1<256000> and S2<1000000>
RPLidar frame
=====================================================================
diff --git a/launch/rplidar_s2.launch b/launch/rplidar_s2.launch
new file mode 100644
index 00000000..e998fc21
--- /dev/null
+++ b/launch/rplidar_s2.launch
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/launch/rplidar_t1.launch b/launch/rplidar_t1.launch
new file mode 100644
index 00000000..31d22e2c
--- /dev/null
+++ b/launch/rplidar_t1.launch
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/launch/view_rplidar_s2.launch b/launch/view_rplidar_s2.launch
new file mode 100644
index 00000000..65bf1c86
--- /dev/null
+++ b/launch/view_rplidar_s2.launch
@@ -0,0 +1,10 @@
+
+
+
+
+
+
diff --git a/launch/view_rplidar_t1.launch b/launch/view_rplidar_t1.launch
new file mode 100644
index 00000000..e07878ca
--- /dev/null
+++ b/launch/view_rplidar_t1.launch
@@ -0,0 +1,10 @@
+
+
+
+
+
+
diff --git a/sdk/Makefile b/sdk/Makefile
new file mode 100644
index 00000000..81215d9a
--- /dev/null
+++ b/sdk/Makefile
@@ -0,0 +1,67 @@
+#/*
+# * RPLIDAR SDK
+# *
+# * Copyright (c) 2009 - 2014 RoboPeak Team
+# * http://www.robopeak.com
+# * Copyright (c) 2014 - 2019 Shanghai Slamtec Co., Ltd.
+# * http://www.slamtec.com
+# *
+# */
+#/*
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions are met:
+# *
+# * 1. Redistributions of source code must retain the above copyright notice,
+# * this list of conditions and the following disclaimer.
+# *
+# * 2. Redistributions in binary form must reproduce the above copyright notice,
+# * this list of conditions and the following disclaimer in the documentation
+# * and/or other materials provided with the distribution.
+# *
+# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# *
+# */
+#
+HOME_TREE := ../
+
+MODULE_NAME := $(notdir $(CURDIR))
+
+include $(HOME_TREE)/mak_def.inc
+
+CXXSRC += src/sl_lidar_driver.cpp \
+ src/hal/thread.cpp\
+ src/sl_crc.cpp\
+ src/sl_serial_channel.cpp\
+ src/sl_tcp_channel.cpp\
+ src/sl_udp_channel.cpp
+
+C_INCLUDES += -I$(CURDIR)/include -I$(CURDIR)/src
+
+ifeq ($(BUILD_TARGET_PLATFORM),Linux)
+CXXSRC += src/arch/linux/net_serial.cpp \
+ src/arch/linux/net_socket.cpp \
+ src/arch/linux/timer.cpp
+endif
+
+
+ifeq ($(BUILD_TARGET_PLATFORM),Darwin)
+CXXSRC += src/arch/macOS/net_serial.cpp \
+ src/arch/macOS/net_socket.cpp \
+ src/arch/macOS/timer.cpp
+endif
+
+all: build_sdk
+
+include $(HOME_TREE)/mak_common.inc
+
+clean: clean_sdk
diff --git a/sdk/README.txt b/sdk/README.txt
index b05d81fd..42a4f9d4 100644
--- a/sdk/README.txt
+++ b/sdk/README.txt
@@ -1,5 +1,5 @@
Copyright (c) 2009 - 2014 RoboPeak Team
-Copyright (c) 2014 - 2019 Shanghai Slamtec Co., Ltd.
+Copyright (c) 2014 - 2021 Shanghai Slamtec Co., Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,6 @@ This folder contains RPLIDAR SDK source code which is provided by RoboPeak.
RoboPeak Website: http://www.robopeak.com
SlamTec HomePage: http://www.slamtec.com
-RPLIDAR_SDK_VERSION: 1.10.0
+RPLIDAR_SDK_VERSION: 2.0.0
Note: The SDK version may not up-to-date.
rplidar product: http://www.slamtec.com/en/Lidar
diff --git a/sdk/include/rplidar.h b/sdk/include/rplidar.h
index 3e545a81..2f7de3d7 100644
--- a/sdk/include/rplidar.h
+++ b/sdk/include/rplidar.h
@@ -41,4 +41,4 @@
#include "rplidar_driver.h"
-#define RPLIDAR_SDK_VERSION "1.12.0"
+#define SLAMTEC_LIDAR_SDK_VERSION SL_LIDAR_SDK_VERSION
diff --git a/sdk/include/rplidar_cmd.h b/sdk/include/rplidar_cmd.h
index 89f1aec8..9922bac3 100644
--- a/sdk/include/rplidar_cmd.h
+++ b/sdk/include/rplidar_cmd.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2009 - 2014 RoboPeak Team
* http://www.robopeak.com
- * Copyright (c) 2014 - 2019 Shanghai Slamtec Co., Ltd.
+ * Copyright (c) 2014-2020 Shanghai Slamtec Co., Ltd.
* http://www.slamtec.com
*
*/
@@ -33,35 +33,40 @@
*/
#pragma once
-
+#include "sl_lidar_cmd.h"
#include "rplidar_protocol.h"
// Commands
//-----------------------------------------
+#define RPLIDAR_AUTOBAUD_MAGICBYTE SL_LIDAR_AUTOBAUD_MAGICBYTE
+
// Commands without payload and response
-#define RPLIDAR_CMD_STOP 0x25
-#define RPLIDAR_CMD_SCAN 0x20
-#define RPLIDAR_CMD_FORCE_SCAN 0x21
-#define RPLIDAR_CMD_RESET 0x40
+#define RPLIDAR_CMD_STOP SL_LIDAR_CMD_STOP
+#define RPLIDAR_CMD_SCAN SL_LIDAR_CMD_SCAN
+#define RPLIDAR_CMD_FORCE_SCAN SL_LIDAR_CMD_FORCE_SCAN
+#define RPLIDAR_CMD_RESET SL_LIDAR_CMD_RESET
// Commands without payload but have response
-#define RPLIDAR_CMD_GET_DEVICE_INFO 0x50
-#define RPLIDAR_CMD_GET_DEVICE_HEALTH 0x52
+#define RPLIDAR_CMD_GET_DEVICE_INFO SL_LIDAR_CMD_GET_DEVICE_INFO
+#define RPLIDAR_CMD_GET_DEVICE_HEALTH SL_LIDAR_CMD_GET_DEVICE_HEALTH
+
+#define RPLIDAR_CMD_GET_SAMPLERATE SL_LIDAR_CMD_GET_SAMPLERATE //added in fw 1.17
-#define RPLIDAR_CMD_GET_SAMPLERATE 0x59 //added in fw 1.17
+#define RPLIDAR_CMD_HQ_MOTOR_SPEED_CTRL SL_LIDAR_CMD_HQ_MOTOR_SPEED_CTRL
-#define RPLIDAR_CMD_HQ_MOTOR_SPEED_CTRL 0xA8
+// Commands with payload but no response
+#define RPLIDAR_CMD_NEW_BAUDRATE_CONFIRM SL_LIDAR_CMD_NEW_BAUDRATE_CONFIRM //added in fw 1.30
// Commands with payload and have response
-#define RPLIDAR_CMD_EXPRESS_SCAN 0x82 //added in fw 1.17
-#define RPLIDAR_CMD_HQ_SCAN 0x83 //added in fw 1.24
-#define RPLIDAR_CMD_GET_LIDAR_CONF 0x84 //added in fw 1.24
-#define RPLIDAR_CMD_SET_LIDAR_CONF 0x85 //added in fw 1.24
+#define RPLIDAR_CMD_EXPRESS_SCAN SL_LIDAR_CMD_EXPRESS_SCAN //added in fw 1.17
+#define RPLIDAR_CMD_HQ_SCAN SL_LIDAR_CMD_HQ_SCAN //added in fw 1.24
+#define RPLIDAR_CMD_GET_LIDAR_CONF SL_LIDAR_CMD_GET_LIDAR_CONF //added in fw 1.24
+#define RPLIDAR_CMD_SET_LIDAR_CONF SL_LIDAR_CMD_SET_LIDAR_CONF //added in fw 1.24
//add for A2 to set RPLIDAR motor pwm when using accessory board
-#define RPLIDAR_CMD_SET_MOTOR_PWM 0xF0
-#define RPLIDAR_CMD_GET_ACC_BOARD_FLAG 0xFF
+#define RPLIDAR_CMD_SET_MOTOR_PWM SL_LIDAR_CMD_SET_MOTOR_PWM
+#define RPLIDAR_CMD_GET_ACC_BOARD_FLAG SL_LIDAR_CMD_GET_ACC_BOARD_FLAG
#if defined(_WIN32)
#pragma pack(1)
@@ -70,231 +75,138 @@
// Payloads
// ------------------------------------------
-#define RPLIDAR_EXPRESS_SCAN_MODE_NORMAL 0
-#define RPLIDAR_EXPRESS_SCAN_MODE_FIXANGLE 0 // won't been supported but keep to prevent build fail
+#define RPLIDAR_EXPRESS_SCAN_MODE_NORMAL SL_LIDAR_EXPRESS_SCAN_MODE_NORMAL
+#define RPLIDAR_EXPRESS_SCAN_MODE_FIXANGLE SL_LIDAR_EXPRESS_SCAN_MODE_FIXANGLE // won't been supported but keep to prevent build fail
//for express working flag(extending express scan protocol)
-#define RPLIDAR_EXPRESS_SCAN_FLAG_BOOST 0x0001
-#define RPLIDAR_EXPRESS_SCAN_FLAG_SUNLIGHT_REJECTION 0x0002
+#define RPLIDAR_EXPRESS_SCAN_FLAG_BOOST SL_LIDAR_EXPRESS_SCAN_FLAG_BOOST
+#define RPLIDAR_EXPRESS_SCAN_FLAG_SUNLIGHT_REJECTION SL_LIDAR_EXPRESS_SCAN_FLAG_SUNLIGHT_REJECTION
//for ultra express working flag
-#define RPLIDAR_ULTRAEXPRESS_SCAN_FLAG_STD 0x0001
-#define RPLIDAR_ULTRAEXPRESS_SCAN_FLAG_HIGH_SENSITIVITY 0x0002
+#define RPLIDAR_ULTRAEXPRESS_SCAN_FLAG_STD SL_LIDAR_ULTRAEXPRESS_SCAN_FLAG_STD
+#define RPLIDAR_ULTRAEXPRESS_SCAN_FLAG_HIGH_SENSITIVITY SL_LIDAR_ULTRAEXPRESS_SCAN_FLAG_HIGH_SENSITIVITY
#define RPLIDAR_HQ_SCAN_FLAG_CCW (0x1<<0)
#define RPLIDAR_HQ_SCAN_FLAG_RAW_ENCODER (0x1<<1)
#define RPLIDAR_HQ_SCAN_FLAG_RAW_DISTANCE (0x1<<2)
-typedef struct _rplidar_payload_express_scan_t {
- _u8 working_mode;
- _u16 working_flags;
- _u16 param;
-} __attribute__((packed)) rplidar_payload_express_scan_t;
-
-typedef struct _rplidar_payload_hq_scan_t {
- _u8 flag;
- _u8 reserved[32];
-} __attribute__((packed)) rplidar_payload_hq_scan_t;
-
-typedef struct _rplidar_payload_get_scan_conf_t {
- _u32 type;
- _u8 reserved[32];
-} __attribute__((packed)) rplidar_payload_get_scan_conf_t;
-#define MAX_MOTOR_PWM 1023
-#define DEFAULT_MOTOR_PWM 660
-typedef struct _rplidar_payload_motor_pwm_t {
- _u16 pwm_value;
-} __attribute__((packed)) rplidar_payload_motor_pwm_t;
-
-typedef struct _rplidar_payload_acc_board_flag_t {
- _u32 reserved;
-} __attribute__((packed)) rplidar_payload_acc_board_flag_t;
-
-typedef struct _rplidar_payload_hq_spd_ctrl_t {
- _u16 rpm;
-} __attribute__((packed)) rplidar_payload_hq_spd_ctrl_t;
+typedef sl_lidar_payload_express_scan_t rplidar_payload_express_scan_t;
+typedef sl_lidar_payload_hq_scan_t rplidar_payload_hq_scan_t;
+typedef sl_lidar_payload_get_scan_conf_t rplidar_payload_get_scan_conf_t;
+typedef sl_lidar_payload_motor_pwm_t rplidar_payload_motor_pwm_t;
+typedef sl_lidar_payload_acc_board_flag_t rplidar_payload_acc_board_flag_t;
+typedef sl_lidar_payload_set_scan_conf_t rplidar_payload_set_scan_conf_t;
+typedef sl_lidar_payload_new_bps_confirmation_t rplidar_payload_new_bps_confirmation_t;
// Response
// ------------------------------------------
-#define RPLIDAR_ANS_TYPE_DEVINFO 0x4
-#define RPLIDAR_ANS_TYPE_DEVHEALTH 0x6
-
-#define RPLIDAR_ANS_TYPE_MEASUREMENT 0x81
+#define RPLIDAR_ANS_TYPE_DEVINFO SL_LIDAR_ANS_TYPE_DEVINFO
+#define RPLIDAR_ANS_TYPE_DEVHEALTH SL_LIDAR_ANS_TYPE_DEVHEALTH
+#define RPLIDAR_ANS_TYPE_MEASUREMENT SL_LIDAR_ANS_TYPE_MEASUREMENT
// Added in FW ver 1.17
-#define RPLIDAR_ANS_TYPE_MEASUREMENT_CAPSULED 0x82
-#define RPLIDAR_ANS_TYPE_MEASUREMENT_HQ 0x83
-
-
+#define RPLIDAR_ANS_TYPE_MEASUREMENT_CAPSULED SL_LIDAR_ANS_TYPE_MEASUREMENT_CAPSULED
+#define RPLIDAR_ANS_TYPE_MEASUREMENT_HQ SL_LIDAR_ANS_TYPE_MEASUREMENT_HQ
// Added in FW ver 1.17
-#define RPLIDAR_ANS_TYPE_SAMPLE_RATE 0x15
+#define RPLIDAR_ANS_TYPE_SAMPLE_RATE SL_LIDAR_ANS_TYPE_SAMPLE_RATE
//added in FW ver 1.23alpha
-#define RPLIDAR_ANS_TYPE_MEASUREMENT_CAPSULED_ULTRA 0x84
+#define RPLIDAR_ANS_TYPE_MEASUREMENT_CAPSULED_ULTRA SL_LIDAR_ANS_TYPE_MEASUREMENT_CAPSULED_ULTRA
//added in FW ver 1.24
-#define RPLIDAR_ANS_TYPE_GET_LIDAR_CONF 0x20
-#define RPLIDAR_ANS_TYPE_SET_LIDAR_CONF 0x21
-#define RPLIDAR_ANS_TYPE_MEASUREMENT_DENSE_CAPSULED 0x85
-#define RPLIDAR_ANS_TYPE_ACC_BOARD_FLAG 0xFF
+#define RPLIDAR_ANS_TYPE_GET_LIDAR_CONF SL_LIDAR_ANS_TYPE_GET_LIDAR_CONF
+#define RPLIDAR_ANS_TYPE_SET_LIDAR_CONF SL_LIDAR_ANS_TYPE_SET_LIDAR_CONF
+#define RPLIDAR_ANS_TYPE_MEASUREMENT_DENSE_CAPSULED SL_LIDAR_ANS_TYPE_MEASUREMENT_DENSE_CAPSULED
+#define RPLIDAR_ANS_TYPE_ACC_BOARD_FLAG SL_LIDAR_ANS_TYPE_ACC_BOARD_FLAG
-#define RPLIDAR_RESP_ACC_BOARD_FLAG_MOTOR_CTRL_SUPPORT_MASK (0x1)
-typedef struct _rplidar_response_acc_board_flag_t {
- _u32 support_flag;
-} __attribute__((packed)) rplidar_response_acc_board_flag_t;
+#define RPLIDAR_RESP_ACC_BOARD_FLAG_MOTOR_CTRL_SUPPORT_MASK SL_LIDAR_RESP_ACC_BOARD_FLAG_MOTOR_CTRL_SUPPORT_MASK
+typedef sl_lidar_response_acc_board_flag_t rplidar_response_acc_board_flag_t;
-#define RPLIDAR_STATUS_OK 0x0
-#define RPLIDAR_STATUS_WARNING 0x1
-#define RPLIDAR_STATUS_ERROR 0x2
-#define RPLIDAR_RESP_MEASUREMENT_SYNCBIT (0x1<<0)
-#define RPLIDAR_RESP_MEASUREMENT_QUALITY_SHIFT 2
+#define RPLIDAR_STATUS_OK SL_LIDAR_STATUS_OK
+#define RPLIDAR_STATUS_WARNING SL_LIDAR_STATUS_WARNING
+#define RPLIDAR_STATUS_ERROR SL_LIDAR_STATUS_ERROR
-#define RPLIDAR_RESP_HQ_FLAG_SYNCBIT (0x1<<0)
+#define RPLIDAR_RESP_MEASUREMENT_SYNCBIT SL_LIDAR_RESP_MEASUREMENT_SYNCBIT
+#define RPLIDAR_RESP_MEASUREMENT_QUALITY_SHIFT SL_LIDAR_RESP_MEASUREMENT_QUALITY_SHIFT
+#define RPLIDAR_RESP_HQ_FLAG_SYNCBIT SL_LIDAR_RESP_HQ_FLAG_SYNCBIT
+#define RPLIDAR_RESP_MEASUREMENT_CHECKBIT SL_LIDAR_RESP_MEASUREMENT_CHECKBIT
+#define RPLIDAR_RESP_MEASUREMENT_ANGLE_SHIFT SL_LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT
-#define RPLIDAR_RESP_MEASUREMENT_CHECKBIT (0x1<<0)
-#define RPLIDAR_RESP_MEASUREMENT_ANGLE_SHIFT 1
-
-typedef struct _rplidar_response_sample_rate_t {
- _u16 std_sample_duration_us;
- _u16 express_sample_duration_us;
-} __attribute__((packed)) rplidar_response_sample_rate_t;
-
-typedef struct _rplidar_response_measurement_node_t {
- _u8 sync_quality; // syncbit:1;syncbit_inverse:1;quality:6;
- _u16 angle_q6_checkbit; // check_bit:1;angle_q6:15;
- _u16 distance_q2;
-} __attribute__((packed)) rplidar_response_measurement_node_t;
+typedef sl_lidar_response_sample_rate_t rplidar_response_sample_rate_t;
+typedef sl_lidar_response_measurement_node_t rplidar_response_measurement_node_t;
//[distance_sync flags]
-#define RPLIDAR_RESP_MEASUREMENT_EXP_ANGLE_MASK (0x3)
-#define RPLIDAR_RESP_MEASUREMENT_EXP_DISTANCE_MASK (0xFC)
+#define RPLIDAR_RESP_MEASUREMENT_EXP_ANGLE_MASK SL_LIDAR_RESP_MEASUREMENT_EXP_ANGLE_MASK
+#define RPLIDAR_RESP_MEASUREMENT_EXP_DISTANCE_MASK SL_LIDAR_RESP_MEASUREMENT_EXP_DISTANCE_MASK
+
+typedef sl_lidar_response_cabin_nodes_t rplidar_response_cabin_nodes_t;
-typedef struct _rplidar_response_cabin_nodes_t {
- _u16 distance_angle_1; // see [distance_sync flags]
- _u16 distance_angle_2; // see [distance_sync flags]
- _u8 offset_angles_q3;
-} __attribute__((packed)) rplidar_response_cabin_nodes_t;
+#define RPLIDAR_RESP_MEASUREMENT_EXP_SYNC_1 SL_LIDAR_RESP_MEASUREMENT_EXP_SYNC_1
+#define RPLIDAR_RESP_MEASUREMENT_EXP_SYNC_2 SL_LIDAR_RESP_MEASUREMENT_EXP_SYNC_2
+#define RPLIDAR_RESP_MEASUREMENT_HQ_SYNC SL_LIDAR_RESP_MEASUREMENT_HQ_SYNC
+#define RPLIDAR_RESP_MEASUREMENT_EXP_SYNCBIT SL_LIDAR_RESP_MEASUREMENT_EXP_SYNCBIT
-#define RPLIDAR_RESP_MEASUREMENT_EXP_SYNC_1 0xA
-#define RPLIDAR_RESP_MEASUREMENT_EXP_SYNC_2 0x5
-#define RPLIDAR_RESP_MEASUREMENT_HQ_SYNC 0xA5
+typedef sl_lidar_response_capsule_measurement_nodes_t rplidar_response_capsule_measurement_nodes_t;
+typedef sl_lidar_response_dense_cabin_nodes_t rplidar_response_dense_cabin_nodes_t;
+typedef sl_lidar_response_dense_capsule_measurement_nodes_t rplidar_response_dense_capsule_measurement_nodes_t;
-#define RPLIDAR_RESP_MEASUREMENT_EXP_SYNCBIT (0x1<<15)
+// ext1 : x2 boost mode
-typedef struct _rplidar_response_capsule_measurement_nodes_t {
- _u8 s_checksum_1; // see [s_checksum_1]
- _u8 s_checksum_2; // see [s_checksum_1]
- _u16 start_angle_sync_q6;
- rplidar_response_cabin_nodes_t cabins[16];
-} __attribute__((packed)) rplidar_response_capsule_measurement_nodes_t;
+#define RPLIDAR_RESP_MEASUREMENT_EXP_ULTRA_MAJOR_BITS SL_LIDAR_RESP_MEASUREMENT_EXP_ULTRA_MAJOR_BITS
+#define RPLIDAR_RESP_MEASUREMENT_EXP_ULTRA_PREDICT_BITS SL_LIDAR_RESP_MEASUREMENT_EXP_ULTRA_PREDICT_BITS
-typedef struct _rplidar_response_dense_cabin_nodes_t {
- _u16 distance;
-} __attribute__((packed)) rplidar_response_dense_cabin_nodes_t;
+typedef sl_lidar_response_ultra_cabin_nodes_t rplidar_response_ultra_cabin_nodes_t;
+typedef sl_lidar_response_ultra_capsule_measurement_nodes_t rplidar_response_ultra_capsule_measurement_nodes_t;
+typedef sl_lidar_response_measurement_node_hq_t rplidar_response_measurement_node_hq_t;
+typedef sl_lidar_response_hq_capsule_measurement_nodes_t rplidar_response_hq_capsule_measurement_nodes_t;
-typedef struct _rplidar_response_dense_capsule_measurement_nodes_t {
- _u8 s_checksum_1; // see [s_checksum_1]
- _u8 s_checksum_2; // see [s_checksum_1]
- _u16 start_angle_sync_q6;
- rplidar_response_dense_cabin_nodes_t cabins[40];
-} __attribute__((packed)) rplidar_response_dense_capsule_measurement_nodes_t;
-// ext1 : x2 boost mode
+# define RPLIDAR_CONF_SCAN_COMMAND_STD SL_LIDAR_CONF_SCAN_COMMAND_STD
+# define RPLIDAR_CONF_SCAN_COMMAND_EXPRESS SL_LIDAR_CONF_SCAN_COMMAND_EXPRESS
+# define RPLIDAR_CONF_SCAN_COMMAND_HQ SL_LIDAR_CONF_SCAN_COMMAND_HQ
+# define RPLIDAR_CONF_SCAN_COMMAND_BOOST SL_LIDAR_CONF_SCAN_COMMAND_BOOST
+# define RPLIDAR_CONF_SCAN_COMMAND_STABILITY SL_LIDAR_CONF_SCAN_COMMAND_STABILITY
+# define RPLIDAR_CONF_SCAN_COMMAND_SENSITIVITY SL_LIDAR_CONF_SCAN_COMMAND_SENSITIVITY
-#define RPLIDAR_RESP_MEASUREMENT_EXP_ULTRA_MAJOR_BITS 12
-#define RPLIDAR_RESP_MEASUREMENT_EXP_ULTRA_PREDICT_BITS 10
-
-typedef struct _rplidar_response_ultra_cabin_nodes_t {
- // 31 0
- // | predict2 10bit | predict1 10bit | major 12bit |
- _u32 combined_x3;
-} __attribute__((packed)) rplidar_response_ultra_cabin_nodes_t;
-
-typedef struct _rplidar_response_ultra_capsule_measurement_nodes_t {
- _u8 s_checksum_1; // see [s_checksum_1]
- _u8 s_checksum_2; // see [s_checksum_1]
- _u16 start_angle_sync_q6;
- rplidar_response_ultra_cabin_nodes_t ultra_cabins[32];
-} __attribute__((packed)) rplidar_response_ultra_capsule_measurement_nodes_t;
-
-typedef struct rplidar_response_measurement_node_hq_t {
- _u16 angle_z_q14;
- _u32 dist_mm_q2;
- _u8 quality;
- _u8 flag;
-} __attribute__((packed)) rplidar_response_measurement_node_hq_t;
-
-typedef struct _rplidar_response_hq_capsule_measurement_nodes_t{
- _u8 sync_byte;
- _u64 time_stamp;
- rplidar_response_measurement_node_hq_t node_hq[16];
- _u32 crc32;
-}__attribute__((packed)) rplidar_response_hq_capsule_measurement_nodes_t;
-
-
-# define RPLIDAR_CONF_SCAN_COMMAND_STD 0
-# define RPLIDAR_CONF_SCAN_COMMAND_EXPRESS 1
-# define RPLIDAR_CONF_SCAN_COMMAND_HQ 2
-# define RPLIDAR_CONF_SCAN_COMMAND_BOOST 3
-# define RPLIDAR_CONF_SCAN_COMMAND_STABILITY 4
-# define RPLIDAR_CONF_SCAN_COMMAND_SENSITIVITY 5
-
-#define RPLIDAR_CONF_ANGLE_RANGE 0x00000000
-#define RPLIDAR_CONF_DESIRED_ROT_FREQ 0x00000001
-#define RPLIDAR_CONF_SCAN_COMMAND_BITMAP 0x00000002
-#define RPLIDAR_CONF_MIN_ROT_FREQ 0x00000004
-#define RPLIDAR_CONF_MAX_ROT_FREQ 0x00000005
-#define RPLIDAR_CONF_MAX_DISTANCE 0x00000060
+#define RPLIDAR_CONF_ANGLE_RANGE SL_LIDAR_CONF_ANGLE_RANGE
+#define RPLIDAR_CONF_DESIRED_ROT_FREQ SL_LIDAR_CONF_DESIRED_ROT_FREQ
+#define RPLIDAR_CONF_SCAN_COMMAND_BITMAP SL_LIDAR_CONF_SCAN_COMMAND_BITMAP
+#define RPLIDAR_CONF_MIN_ROT_FREQ SL_LIDAR_CONF_MIN_ROT_FREQ
+#define RPLIDAR_CONF_MAX_ROT_FREQ SL_LIDAR_CONF_MAX_ROT_FREQ
+#define RPLIDAR_CONF_MAX_DISTANCE SL_LIDAR_CONF_MAX_DISTANCE
-#define RPLIDAR_CONF_SCAN_MODE_COUNT 0x00000070
-#define RPLIDAR_CONF_SCAN_MODE_US_PER_SAMPLE 0x00000071
-#define RPLIDAR_CONF_SCAN_MODE_MAX_DISTANCE 0x00000074
-#define RPLIDAR_CONF_SCAN_MODE_ANS_TYPE 0x00000075
-#define RPLIDAR_CONF_SCAN_MODE_TYPICAL 0x0000007C
-#define RPLIDAR_CONF_SCAN_MODE_NAME 0x0000007F
-#define RPLIDAR_EXPRESS_SCAN_STABILITY_BITMAP 4
-#define RPLIDAR_EXPRESS_SCAN_SENSITIVITY_BITMAP 5
-
-typedef struct _rplidar_response_get_lidar_conf{
- _u32 type;
- _u8 payload[0];
-}__attribute__((packed)) rplidar_response_get_lidar_conf_t;
-
-typedef struct _rplidar_response_set_lidar_conf{
- _u32 result;
-}__attribute__((packed)) rplidar_response_set_lidar_conf_t;
-
-
-typedef struct _rplidar_response_device_info_t {
- _u8 model;
- _u16 firmware_version;
- _u8 hardware_version;
- _u8 serialnum[16];
-} __attribute__((packed)) rplidar_response_device_info_t;
-
-typedef struct _rplidar_response_device_health_t {
- _u8 status;
- _u16 error_code;
-} __attribute__((packed)) rplidar_response_device_health_t;
+#define RPLIDAR_CONF_SCAN_MODE_COUNT SL_LIDAR_CONF_SCAN_MODE_COUNT
+#define RPLIDAR_CONF_SCAN_MODE_US_PER_SAMPLE SL_LIDAR_CONF_SCAN_MODE_US_PER_SAMPLE
+#define RPLIDAR_CONF_SCAN_MODE_MAX_DISTANCE SL_LIDAR_CONF_SCAN_MODE_MAX_DISTANCE
+#define RPLIDAR_CONF_SCAN_MODE_ANS_TYPE SL_LIDAR_CONF_SCAN_MODE_ANS_TYPE
+#define RPLIDAR_CONF_SCAN_MODE_TYPICAL SL_LIDAR_CONF_SCAN_MODE_TYPICAL
+#define RPLIDAR_CONF_SCAN_MODE_NAME SL_LIDAR_CONF_SCAN_MODE_NAME
+#define RPLIDAR_EXPRESS_SCAN_STABILITY_BITMAP SL_LIDAR_EXPRESS_SCAN_STABILITY_BITMAP
+#define RPLIDAR_EXPRESS_SCAN_SENSITIVITY_BITMAP SL_LIDAR_EXPRESS_SCAN_SENSITIVITY_BITMAP
+#define RPLIDAR_CONF_LIDAR_STATIC_IP_ADDR SL_LIDAR_CONF_LIDAR_STATIC_IP_ADDR
+#define RPLIDAR_CONF_LIDAR_MAC_ADDR SL_LIDAR_CONF_LIDAR_MAC_ADDR
+
+#define RPLIDAR_CONF_DETECTED_SERIAL_BPS SL_LIDAR_CONF_DETECTED_SERIAL_BPS
+
+typedef sl_lidar_response_get_lidar_conf_t rplidar_response_get_lidar_conf_t;
+typedef sl_lidar_response_set_lidar_conf_t rplidar_response_set_lidar_conf_t;
+typedef sl_lidar_response_device_info_t rplidar_response_device_info_t;
+typedef sl_lidar_response_device_health_t rplidar_response_device_health_t;
+typedef sl_lidar_ip_conf_t rplidar_ip_conf_t;
+typedef sl_lidar_response_device_macaddr_info_t rplidar_response_device_macaddr_info_t;
// Definition of the variable bit scale encoding mechanism
-#define RPLIDAR_VARBITSCALE_X2_SRC_BIT 9
-#define RPLIDAR_VARBITSCALE_X4_SRC_BIT 11
-#define RPLIDAR_VARBITSCALE_X8_SRC_BIT 12
-#define RPLIDAR_VARBITSCALE_X16_SRC_BIT 14
-
-#define RPLIDAR_VARBITSCALE_X2_DEST_VAL 512
-#define RPLIDAR_VARBITSCALE_X4_DEST_VAL 1280
-#define RPLIDAR_VARBITSCALE_X8_DEST_VAL 1792
-#define RPLIDAR_VARBITSCALE_X16_DEST_VAL 3328
-
-#define RPLIDAR_VARBITSCALE_GET_SRC_MAX_VAL_BY_BITS(_BITS_) \
- ( (((0x1<<(_BITS_)) - RPLIDAR_VARBITSCALE_X16_DEST_VAL)<<4) + \
- ((RPLIDAR_VARBITSCALE_X16_DEST_VAL - RPLIDAR_VARBITSCALE_X8_DEST_VAL)<<3) + \
- ((RPLIDAR_VARBITSCALE_X8_DEST_VAL - RPLIDAR_VARBITSCALE_X4_DEST_VAL)<<2) + \
- ((RPLIDAR_VARBITSCALE_X4_DEST_VAL - RPLIDAR_VARBITSCALE_X2_DEST_VAL)<<1) + \
- RPLIDAR_VARBITSCALE_X2_DEST_VAL - 1)
+#define RPLIDAR_VARBITSCALE_X2_SRC_BIT SL_LIDAR_VARBITSCALE_X2_SRC_BIT
+#define RPLIDAR_VARBITSCALE_X4_SRC_BIT SL_LIDAR_VARBITSCALE_X4_SRC_BIT
+#define RPLIDAR_VARBITSCALE_X8_SRC_BIT SL_LIDAR_VARBITSCALE_X8_SRC_BIT
+#define RPLIDAR_VARBITSCALE_X16_SRC_BIT SL_LIDAR_VARBITSCALE_X16_SRC_BIT
+
+#define RPLIDAR_VARBITSCALE_X2_DEST_VAL SL_LIDAR_VARBITSCALE_X2_DEST_VAL
+#define RPLIDAR_VARBITSCALE_X4_DEST_VAL SL_LIDAR_VARBITSCALE_X4_DEST_VAL
+#define RPLIDAR_VARBITSCALE_X8_DEST_VAL SL_LIDAR_VARBITSCALE_X8_DEST_VAL
+#define RPLIDAR_VARBITSCALE_X16_DEST_VAL SL_LIDAR_VARBITSCALE_X16_DEST_VAL
+#define RPLIDAR_VARBITSCALE_GET_SRC_MAX_VAL_BY_BITS(_BITS_) SL_LIDAR_VARBITSCALE_GET_SRC_MAX_VAL_BY_BITS(_BITS_)
#if defined(_WIN32)
#pragma pack()
diff --git a/sdk/include/rplidar_driver.h b/sdk/include/rplidar_driver.h
index 9e263617..26f121a9 100644
--- a/sdk/include/rplidar_driver.h
+++ b/sdk/include/rplidar_driver.h
@@ -33,53 +33,22 @@
*/
#pragma once
-
+#include "sl_lidar_driver.h"
#ifndef __cplusplus
#error "The RPlidar SDK requires a C++ compiler to be built"
#endif
-#ifndef DEPRECATED
- #ifdef __GNUC__
- #define DEPRECATED(func) func __attribute__ ((deprecated))
- #elif defined(_MSC_VER)
- #define DEPRECATED(func) __declspec(deprecated) func
- #else
- #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
- #define DEPRECATED(func) func
- #endif
-#endif
namespace rp { namespace standalone{ namespace rplidar {
-
-struct RplidarScanMode {
- _u16 id;
- float us_per_sample; // microseconds per sample
- float max_distance; // max distance
- _u8 ans_type; // the answer type of the scam mode, its value should be RPLIDAR_ANS_TYPE_MEASUREMENT*
- char scan_mode[64]; // name of scan mode, max 63 characters
-};
-
-enum {
- DRIVER_TYPE_SERIALPORT = 0x0,
- DRIVER_TYPE_TCP = 0x1,
-};
-
-class ChannelDevice
-{
-public:
- virtual bool bind(const char*, uint32_t ) = 0;
- virtual bool open() {return true;}
- virtual void close() = 0;
- virtual void flush() {return;}
- virtual bool waitfordata(size_t data_count,_u32 timeout = -1, size_t * returned_size = NULL) = 0;
- virtual int senddata(const _u8 * data, size_t size) = 0;
- virtual int recvdata(unsigned char * data, size_t size) = 0;
- virtual void setDTR() {return;}
- virtual void clearDTR() {return;}
- virtual void ReleaseRxTx() {return;}
-};
-
+ using namespace sl;
+ typedef LidarScanMode RplidarScanMode;
+
+//enum {
+// DRIVER_TYPE_SERIALPORT = 0x0,
+// DRIVER_TYPE_TCP = 0x1,
+// DRIVER_TYPE_UDP = 0x2,
+//};
class RPlidarDriver {
public:
enum {
@@ -99,13 +68,15 @@ class RPlidarDriver {
/// This interface should be invoked first before any other operations
///
/// \param drivertype the connection type used by the driver.
- static RPlidarDriver * CreateDriver(_u32 drivertype = DRIVER_TYPE_SERIALPORT);
+ static RPlidarDriver * CreateDriver(_u32 drivertype = CHANNEL_TYPE_SERIALPORT);
+
+
+ RPlidarDriver(sl_u32 channelType);
/// Dispose the RPLIDAR Driver Instance specified by the drv parameter
/// Applications should invoke this interface when the driver instance is no longer used in order to free memory
static void DisposeDriver(RPlidarDriver * drv);
-
/// Open the specified serial port and connect to a target RPLIDAR device
///
/// \param port_path the device path of the serial port
@@ -117,28 +88,29 @@ class RPlidarDriver {
///
/// \param flag other flags
/// Reserved for future use, always set to Zero
- virtual u_result connect(const char *, _u32, _u32 flag = 0) = 0;
-
-
+ u_result connect(const char *path, _u32 portOrBaud, _u32 flag = 0);
+
/// Disconnect with the RPLIDAR and close the serial port
- virtual void disconnect() = 0;
+ void disconnect();
/// Returns TRUE when the connection has been established
- virtual bool isConnected() = 0;
+ bool isConnected();
/// Ask the RPLIDAR core system to reset it self
/// The host system can use the Reset operation to help RPLIDAR escape the self-protection mode.
///
/// \param timeout The operation timeout value (in millisecond) for the serial port communication
- virtual u_result reset(_u32 timeout = DEFAULT_TIMEOUT) = 0;
+ u_result reset(_u32 timeout = DEFAULT_TIMEOUT);
- virtual u_result clearNetSerialRxCache() = 0;
+ u_result clearNetSerialRxCache() {
+ return RESULT_OK;
+ }
// FW1.24
/// Get all scan modes that supported by lidar
- virtual u_result getAllSupportedScanModes(std::vector& outModes, _u32 timeoutInMs = DEFAULT_TIMEOUT) = 0;
-
+ u_result getAllSupportedScanModes(std::vector& outModes, _u32 timeoutInMs = DEFAULT_TIMEOUT);
+
/// Get typical scan mode of lidar
- virtual u_result getTypicalScanMode(_u16& outMode, _u32 timeoutInMs = DEFAULT_TIMEOUT) = 0;
+ u_result getTypicalScanMode(_u16& outMode, _u32 timeoutInMs = DEFAULT_TIMEOUT);
/// Start scan
///
@@ -146,7 +118,7 @@ class RPlidarDriver {
/// \param useTypicalScan Use lidar's typical scan mode or use the compatibility mode (2k sps)
/// \param options Scan options (please use 0)
/// \param outUsedScanMode The scan mode selected by lidar
- virtual u_result startScan(bool force, bool useTypicalScan, _u32 options = 0, RplidarScanMode* outUsedScanMode = NULL) = 0;
+ u_result startScan(bool force, bool useTypicalScan, _u32 options = 0, RplidarScanMode* outUsedScanMode = NULL);
/// Start scan in specific mode
///
@@ -154,7 +126,7 @@ class RPlidarDriver {
/// \param scanMode The scan mode id (use getAllSupportedScanModes to get supported modes)
/// \param options Scan options (please use 0)
/// \param outUsedScanMode The scan mode selected by lidar
- virtual u_result startScanExpress(bool force, _u16 scanMode, _u32 options = 0, RplidarScanMode* outUsedScanMode = NULL, _u32 timeout = DEFAULT_TIMEOUT) = 0;
+ u_result startScanExpress(bool force, _u16 scanMode, _u32 options = 0, RplidarScanMode* outUsedScanMode = NULL, _u32 timeout = DEFAULT_TIMEOUT);
/// Retrieve the health status of the RPLIDAR
/// The host system can use this operation to check whether RPLIDAR is in the self-protection mode.
@@ -162,111 +134,47 @@ class RPlidarDriver {
/// \param health The health status info returned from the RPLIDAR
///
/// \param timeout The operation timeout value (in millisecond) for the serial port communication
- virtual u_result getHealth(rplidar_response_device_health_t & health, _u32 timeout = DEFAULT_TIMEOUT) = 0;
+ u_result getHealth(rplidar_response_device_health_t & health, _u32 timeout = DEFAULT_TIMEOUT);
/// Get the device information of the RPLIDAR include the serial number, firmware version, device model etc.
///
/// \param info The device information returned from the RPLIDAR
/// \param timeout The operation timeout value (in millisecond) for the serial port communication
- virtual u_result getDeviceInfo(rplidar_response_device_info_t & info, _u32 timeout = DEFAULT_TIMEOUT) = 0;
+ u_result getDeviceInfo(rplidar_response_device_info_t & info, _u32 timeout = DEFAULT_TIMEOUT);
- /// Get the sample duration information of the RPLIDAR.
- /// DEPRECATED, please use RplidarScanMode::us_per_sample
- ///
- /// \param rateInfo The sample duration information returned from the RPLIDAR
- /// \param timeout The operation timeout value (in millisecond) for the serial port communication
- DEPRECATED(virtual u_result getSampleDuration_uS(rplidar_response_sample_rate_t & rateInfo, _u32 timeout = DEFAULT_TIMEOUT)) = 0;
-
- /// Set the RPLIDAR's motor pwm when using accessory board, currently valid for A2 and A3 only.
+ /// Set the RPLIDAR's motor pwm when using accessory board, currently valid for A2 only.
///
/// \param pwm The motor pwm value would like to set
- virtual u_result setMotorPWM(_u16 pwm) = 0;
-
- /// Set the RPLIDAR's motor rpm, currently valid for tof lidar only.
- ///
- /// \param rpm The motor rpm value would like to set
- virtual u_result setLidarSpinSpeed(_u16 rpm, _u32 timeout = DEFAULT_TIMEOUT) = 0;
+ u_result setMotorPWM(_u16 pwm);
/// Start RPLIDAR's motor when using accessory board
- virtual u_result startMotor() = 0;
+ u_result startMotor();
/// Stop RPLIDAR's motor when using accessory board
- virtual u_result stopMotor() = 0;
+ u_result stopMotor();
/// Check whether the device support motor control.
/// Note: this API will disable grab.
///
/// \param support Return the result.
/// \param timeout The operation timeout value (in millisecond) for the serial port communication.
- virtual u_result checkMotorCtrlSupport(bool & support, _u32 timeout = DEFAULT_TIMEOUT) = 0;
+ u_result checkMotorCtrlSupport(bool & support, _u32 timeout = DEFAULT_TIMEOUT);
- /// Check if the device is Tof lidar.
- /// Note: this API is effective if and only if getDeviceInfo has been called.
- ///
- /// \param support Return the result.
- /// \param timeout The operation timeout value (in millisecond) for the serial port communication.
- virtual u_result checkIfTofLidar(bool & isTofLidar, _u32 timeout = DEFAULT_TIMEOUT) = 0;
+ ///Set LPX series lidar's static IP address
+ ///
+ /// \param conf Network parameter that LPX series lidar owned
+ /// \param timeout The operation timeout value (in millisecond) for the ethernet udp communication
+ u_result setLidarIpConf(const rplidar_ip_conf_t& conf, _u32 timeout = DEFAULT_TIMEOUT);
- /// Calculate RPLIDAR's current scanning frequency from the given scan data
- /// DEPRECATED, please use getFrequency(RplidarScanMode, size_t)
- ///
- /// Please refer to the application note doc for details
- /// Remark: the calcuation will be incorrect if the specified scan data doesn't contains enough data
- ///
- /// \param inExpressMode Indicate whether the RPLIDAR is in express mode
- /// \param count The number of sample nodes inside the given buffer
- /// \param frequency The scanning frequency (in HZ) calcuated by the interface.
- /// \param is4kmode Return whether the RPLIDAR is working on 4k sample rate mode.
- DEPRECATED(virtual u_result getFrequency(bool inExpressMode, size_t count, float & frequency, bool & is4kmode)) = 0;
-
- /// Calculate RPLIDAR's current scanning frequency from the given scan data
- /// Please refer to the application note doc for details
- /// Remark: the calcuation will be incorrect if the specified scan data doesn't contains enough data
- ///
- /// \param scanMode Lidar's current scan mode
- /// \param count The number of sample nodes inside the given buffer
- virtual u_result getFrequency(const RplidarScanMode& scanMode, size_t count, float & frequency) = 0;
-
- /// Ask the RPLIDAR core system to enter the scan mode(Normal/Express, Express mode is 4k mode)
- /// A background thread will be created by the RPLIDAR driver to fetch the scan data continuously.
- /// User Application can use the grabScanData() interface to retrieved the scan data cached previous by this background thread.
- ///
- /// \param force Force the core system to output scan data regardless whether the scanning motor is rotating or not.
- /// \param timeout The operation timeout value (in millisecond) for the serial port communication.
- virtual u_result startScanNormal(bool force, _u32 timeout = DEFAULT_TIMEOUT) = 0;
-
- /// Check whether the device support express mode.
- /// DEPRECATED, please use getAllSupportedScanModes
- ///
- /// \param support Return the result.
- /// \param timeout The operation timeout value (in millisecond) for the serial port communication.
- DEPRECATED(virtual u_result checkExpressScanSupported(bool & support, _u32 timeout = DEFAULT_TIMEOUT)) = 0;
+ ///Get LPX series lidar's MAC address
+ ///
+ /// \param macAddrArray The device MAC information returned from the LPX series lidar
+ u_result getDeviceMacAddr(_u8* macAddrArray, _u32 timeoutInMs = DEFAULT_TIMEOUT);
/// Ask the RPLIDAR core system to stop the current scan operation and enter idle state. The background thread will be terminated
///
/// \param timeout The operation timeout value (in millisecond) for the serial port communication
- virtual u_result stop(_u32 timeout = DEFAULT_TIMEOUT) = 0;
-
-
- /// Wait and grab a complete 0-360 degree scan data previously received.
- /// NOTE: This method only support distance less than 16.38 meters, for longer distance, please use grabScanDataHq
- /// The grabbed scan data returned by this interface always has the following charactistics:
- ///
- /// 1) The first node of the grabbed data array (nodebuffer[0]) must be the first sample of a scan, i.e. the start_bit == 1
- /// 2) All data nodes are belong to exactly ONE complete 360-degrees's scan
- /// 3) Note, the angle data in one scan may not be ascending. You can use API ascendScanData to reorder the nodebuffer.
- ///
- /// \param nodebuffer Buffer provided by the caller application to store the scan data
- ///
- /// \param count The caller must initialize this parameter to set the max data count of the provided buffer (in unit of rplidar_response_measurement_node_t).
- /// Once the interface returns, this parameter will store the actual received data count.
- ///
- /// \param timeout Max duration allowed to wait for a complete scan data, nothing will be stored to the nodebuffer if a complete 360-degrees' scan data cannot to be ready timely.
- ///
- /// The interface will return RESULT_OPERATION_TIMEOUT to indicate that no complete 360-degrees' scan can be retrieved withing the given timeout duration.
- ///
- /// \The caller application can set the timeout value to Zero(0) to make this interface always returns immediately to achieve non-block operation.
- DEPRECATED(virtual u_result grabScanData(rplidar_response_measurement_node_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT)) = 0;
+ u_result stop(_u32 timeout = DEFAULT_TIMEOUT);
/// Wait and grab a complete 0-360 degree scan data previously received.
/// The grabbed scan data returned by this interface always has the following charactistics:
@@ -285,7 +193,7 @@ class RPlidarDriver {
/// The interface will return RESULT_OPERATION_TIMEOUT to indicate that no complete 360-degrees' scan can be retrieved withing the given timeout duration.
///
/// \The caller application can set the timeout value to Zero(0) to make this interface always returns immediately to achieve non-block operation.
- virtual u_result grabScanDataHq(rplidar_response_measurement_node_hq_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT) = 0;
+ u_result grabScanDataHq(rplidar_response_measurement_node_hq_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT);
/// Ascending the scan data according to the angle value in the scan.
///
@@ -294,16 +202,7 @@ class RPlidarDriver {
/// \param count The caller must initialize this parameter to set the max data count of the provided buffer (in unit of rplidar_response_measurement_node_t).
/// Once the interface returns, this parameter will store the actual received data count.
/// The interface will return RESULT_OPERATION_FAIL when all the scan data is invalid.
- DEPRECATED(virtual u_result ascendScanData(rplidar_response_measurement_node_t * nodebuffer, size_t count)) = 0;
-
- /// Ascending the scan data according to the angle value in the scan.
- ///
- /// \param nodebuffer Buffer provided by the caller application to do the reorder. Should be retrived from the grabScanData
- ///
- /// \param count The caller must initialize this parameter to set the max data count of the provided buffer (in unit of rplidar_response_measurement_node_t).
- /// Once the interface returns, this parameter will store the actual received data count.
- /// The interface will return RESULT_OPERATION_FAIL when all the scan data is invalid.
- virtual u_result ascendScanData(rplidar_response_measurement_node_hq_t * nodebuffer, size_t count) = 0;
+ u_result ascendScanData(rplidar_response_measurement_node_hq_t * nodebuffer, size_t count);
/// Return received scan points even if it's not complete scan
///
@@ -312,26 +211,27 @@ class RPlidarDriver {
/// \param count Once the interface returns, this parameter will store the actual received data count.
///
/// The interface will return RESULT_OPERATION_TIMEOUT to indicate that not even a single node can be retrieved since last call.
- DEPRECATED(virtual u_result getScanDataWithInterval(rplidar_response_measurement_node_t * nodebuffer, size_t & count)) = 0;
+ u_result getScanDataWithInterval(rplidar_response_measurement_node_t * nodebuffer, size_t & count);
- /// Return received scan points even if it's not complete scan.
+ /// Return received scan points even if it's not complete scan
///
- /// \param nodebuffer Buffer provided by the caller application to store the scan data. This buffer must be initialized by
- /// the caller.
+ /// \param nodebuffer Buffer provided by the caller application to store the scan data
///
- /// \param count The caller must initialize this parameter to set the max data count of the provided buffer (in unit of rplidar_response_measurement_node_t).
- /// Once the interface returns, this parameter will store the actual received data count.
+ /// \param count Once the interface returns, this parameter will store the actual received data count.
///
- /// The interface will return RESULT_OPERATION_TIMEOUT to indicate that not even a single node can be retrieved since last call.
- /// The interface will return RESULT_REMAINING_DATA to indicate that the given buffer is full, but that there remains data to be read.
- virtual u_result getScanDataWithIntervalHq(rplidar_response_measurement_node_hq_t * nodebuffer, size_t & count) = 0;
+ /// The interface will return RESULT_OPERATION_TIMEOUT to indicate that not even a single node can be retrieved since last call.
+ u_result getScanDataWithIntervalHq(rplidar_response_measurement_node_hq_t * nodebuffer, size_t & count);
+
- virtual ~RPlidarDriver() {}
+ virtual ~RPlidarDriver();
protected:
- RPlidarDriver(){}
+ RPlidarDriver();
-public:
- ChannelDevice* _chanDev;
+private:
+ sl_u32 _channelType;
+ IChannel* _channel;
+ ILidarDriver* _lidarDrv;
+
};
diff --git a/sdk/include/rplidar_protocol.h b/sdk/include/rplidar_protocol.h
index 2f8231b7..5b17bbb8 100644
--- a/sdk/include/rplidar_protocol.h
+++ b/sdk/include/rplidar_protocol.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2009 - 2014 RoboPeak Team
* http://www.robopeak.com
- * Copyright (c) 2014 - 2019 Shanghai Slamtec Co., Ltd.
+ * Copyright (c) 2014 - 2020 Shanghai Slamtec Co., Ltd.
* http://www.slamtec.com
*
*/
@@ -33,39 +33,27 @@
*/
#pragma once
-
+#include "sl_lidar_protocol.h"
// RP-Lidar Input Packets
-#define RPLIDAR_CMD_SYNC_BYTE 0xA5
-#define RPLIDAR_CMDFLAG_HAS_PAYLOAD 0x80
+#define RPLIDAR_CMD_SYNC_BYTE SL_LIDAR_CMD_SYNC_BYTE
+#define RPLIDAR_CMDFLAG_HAS_PAYLOAD SL_LIDAR_CMDFLAG_HAS_PAYLOAD
-#define RPLIDAR_ANS_SYNC_BYTE1 0xA5
-#define RPLIDAR_ANS_SYNC_BYTE2 0x5A
+#define RPLIDAR_ANS_SYNC_BYTE1 SL_LIDAR_ANS_SYNC_BYTE1
+#define RPLIDAR_ANS_SYNC_BYTE2 SL_LIDAR_ANS_SYNC_BYTE2
-#define RPLIDAR_ANS_PKTFLAG_LOOP 0x1
+#define RPLIDAR_ANS_PKTFLAG_LOOP SL_LIDAR_ANS_PKTFLAG_LOOP
-#define RPLIDAR_ANS_HEADER_SIZE_MASK 0x3FFFFFFF
-#define RPLIDAR_ANS_HEADER_SUBTYPE_SHIFT (30)
+#define RPLIDAR_ANS_HEADER_SIZE_MASK SL_LIDAR_ANS_HEADER_SIZE_MASK
+#define RPLIDAR_ANS_HEADER_SUBTYPE_SHIFT SL_LIDAR_ANS_HEADER_SUBTYPE_SHIFT
#if defined(_WIN32)
#pragma pack(1)
#endif
-typedef struct _rplidar_cmd_packet_t {
- _u8 syncByte; //must be RPLIDAR_CMD_SYNC_BYTE
- _u8 cmd_flag;
- _u8 size;
- _u8 data[0];
-} __attribute__((packed)) rplidar_cmd_packet_t;
-
-
-typedef struct _rplidar_ans_header_t {
- _u8 syncByte1; // must be RPLIDAR_ANS_SYNC_BYTE1
- _u8 syncByte2; // must be RPLIDAR_ANS_SYNC_BYTE2
- _u32 size_q30_subtype; // see _u32 size:30; _u32 subType:2;
- _u8 type;
-} __attribute__((packed)) rplidar_ans_header_t;
+typedef sl_lidar_cmd_packet_t rplidar_cmd_packet_t;
+typedef sl_lidar_ans_header_t rplidar_ans_header_t;
#if defined(_WIN32)
#pragma pack()
diff --git a/sdk/include/sl_crc.h b/sdk/include/sl_crc.h
new file mode 100644
index 00000000..184a8df9
--- /dev/null
+++ b/sdk/include/sl_crc.h
@@ -0,0 +1,43 @@
+/*
+* Slamtec LIDAR SDK
+*
+* sl_crc.h
+*
+* Copyright (c) 2020 Shanghai Slamtec Co., Ltd.
+*/
+
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#include "sl_lidar_cmd.h"
+
+namespace sl {namespace crc32 {
+ sl_u32 bitrev(sl_u32 input, sl_u16 bw);//reflect
+ void init(sl_u32 poly); // table init
+ sl_u32 cal(sl_u32 crc, void* input, sl_u16 len);
+ sl_result getResult(sl_u8 *ptr, sl_u32 len);
+}}
diff --git a/sdk/include/sl_lidar.h b/sdk/include/sl_lidar.h
new file mode 100644
index 00000000..cc672371
--- /dev/null
+++ b/sdk/include/sl_lidar.h
@@ -0,0 +1,42 @@
+/*
+* Slamtec LIDAR SDK
+*
+* sl_lidar.h
+*
+* Copyright (c) 2020 Shanghai Slamtec Co., Ltd.
+*/
+
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#include "sl_lidar_driver.h"
+
+#define SL_LIDAR_SDK_VERSION_MAJOR 2
+#define SL_LIDAR_SDK_VERSION_MINOR 0
+#define SL_LIDAR_SDK_VERSION_PATCH 0
+#define SL_LIDAR_SDK_VERSION_SEQ ((SL_LIDAR_SDK_VERSION_MAJOR << 16) | (SL_LIDAR_SDK_VERSION_MINOR << 8) | SL_LIDAR_SDK_VERSION_PATCH)
+#define SL_LIDAR_SDK_VERSION (#SL_LIDAR_SDK_VERSION_MAJOR "." #SL_LIDAR_SDK_VERSION_MINOR "." #SL_LIDAR_SDK_VERSION_PATCH)
diff --git a/sdk/include/sl_lidar_cmd.h b/sdk/include/sl_lidar_cmd.h
new file mode 100644
index 00000000..ac9ea143
--- /dev/null
+++ b/sdk/include/sl_lidar_cmd.h
@@ -0,0 +1,354 @@
+/*
+* Slamtec LIDAR SDK
+*
+* sl_lidar_cmd.h
+*
+* Copyright (c) 2020 Shanghai Slamtec Co., Ltd.
+*/
+
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#include "sl_lidar_protocol.h"
+
+ // Commands
+ //-----------------------------------------
+
+
+#define SL_LIDAR_AUTOBAUD_MAGICBYTE 0x41
+
+ // Commands without payload and response
+#define SL_LIDAR_CMD_STOP 0x25
+#define SL_LIDAR_CMD_SCAN 0x20
+#define SL_LIDAR_CMD_FORCE_SCAN 0x21
+#define SL_LIDAR_CMD_RESET 0x40
+
+// Commands with payload but no response
+#define SL_LIDAR_CMD_NEW_BAUDRATE_CONFIRM 0x90 //added in fw 1.30
+
+// Commands without payload but have response
+#define SL_LIDAR_CMD_GET_DEVICE_INFO 0x50
+#define SL_LIDAR_CMD_GET_DEVICE_HEALTH 0x52
+
+#define SL_LIDAR_CMD_GET_SAMPLERATE 0x59 //added in fw 1.17
+
+#define SL_LIDAR_CMD_HQ_MOTOR_SPEED_CTRL 0xA8
+
+
+// Commands with payload and have response
+#define SL_LIDAR_CMD_EXPRESS_SCAN 0x82 //added in fw 1.17
+#define SL_LIDAR_CMD_HQ_SCAN 0x83 //added in fw 1.24
+#define SL_LIDAR_CMD_GET_LIDAR_CONF 0x84 //added in fw 1.24
+#define SL_LIDAR_CMD_SET_LIDAR_CONF 0x85 //added in fw 1.24
+//add for A2 to set RPLIDAR motor pwm when using accessory board
+#define SL_LIDAR_CMD_SET_MOTOR_PWM 0xF0
+#define SL_LIDAR_CMD_GET_ACC_BOARD_FLAG 0xFF
+
+#if defined(_WIN32)
+#pragma pack(1)
+#endif
+
+
+// Payloads
+// ------------------------------------------
+#define SL_LIDAR_EXPRESS_SCAN_MODE_NORMAL 0
+#define SL_LIDAR_EXPRESS_SCAN_MODE_FIXANGLE 0 // won't been supported but keep to prevent build fail
+//for express working flag(extending express scan protocol)
+#define SL_LIDAR_EXPRESS_SCAN_FLAG_BOOST 0x0001
+#define SL_LIDAR_EXPRESS_SCAN_FLAG_SUNLIGHT_REJECTION 0x0002
+
+//for ultra express working flag
+#define SL_LIDAR_ULTRAEXPRESS_SCAN_FLAG_STD 0x0001
+#define SL_LIDAR_ULTRAEXPRESS_SCAN_FLAG_HIGH_SENSITIVITY 0x0002
+
+typedef struct _sl_lidar_payload_express_scan_t
+{
+ sl_u8 working_mode;
+ sl_u16 working_flags;
+ sl_u16 param;
+} __attribute__((packed)) sl_lidar_payload_express_scan_t;
+
+typedef struct _sl_lidar_payload_hq_scan_t
+{
+ sl_u8 flag;
+ sl_u8 reserved[32];
+} __attribute__((packed)) sl_lidar_payload_hq_scan_t;
+
+typedef struct _sl_lidar_payload_get_scan_conf_t
+{
+ sl_u32 type;
+ sl_u8 reserved[32];
+} __attribute__((packed)) sl_lidar_payload_get_scan_conf_t;
+
+typedef struct _sl_payload_set_scan_conf_t {
+ sl_u32 type;
+} __attribute__((packed)) sl_lidar_payload_set_scan_conf_t;
+
+
+#define DEFAULT_MOTOR_SPEED (0xFFFFu)
+
+typedef struct _sl_lidar_payload_motor_pwm_t
+{
+ sl_u16 pwm_value;
+} __attribute__((packed)) sl_lidar_payload_motor_pwm_t;
+
+typedef struct _sl_lidar_payload_acc_board_flag_t
+{
+ sl_u32 reserved;
+} __attribute__((packed)) sl_lidar_payload_acc_board_flag_t;
+
+typedef struct _sl_lidar_payload_hq_spd_ctrl_t {
+ sl_u16 rpm;
+} __attribute__((packed))sl_lidar_payload_hq_spd_ctrl_t;
+
+
+typedef struct _sl_lidar_payload_new_bps_confirmation_t {
+ sl_u16 flag; // reserved, must be 0x5F5F
+ sl_u32 required_bps;
+ sl_u16 param;
+} __attribute__((packed)) sl_lidar_payload_new_bps_confirmation_t;
+
+// Response
+// ------------------------------------------
+#define SL_LIDAR_ANS_TYPE_DEVINFO 0x4
+#define SL_LIDAR_ANS_TYPE_DEVHEALTH 0x6
+
+#define SL_LIDAR_ANS_TYPE_MEASUREMENT 0x81
+// Added in FW ver 1.17
+#define SL_LIDAR_ANS_TYPE_MEASUREMENT_CAPSULED 0x82
+#define SL_LIDAR_ANS_TYPE_MEASUREMENT_HQ 0x83
+
+
+// Added in FW ver 1.17
+#define SL_LIDAR_ANS_TYPE_SAMPLE_RATE 0x15
+//added in FW ver 1.23alpha
+#define SL_LIDAR_ANS_TYPE_MEASUREMENT_CAPSULED_ULTRA 0x84
+//added in FW ver 1.24
+#define SL_LIDAR_ANS_TYPE_GET_LIDAR_CONF 0x20
+#define SL_LIDAR_ANS_TYPE_SET_LIDAR_CONF 0x21
+#define SL_LIDAR_ANS_TYPE_MEASUREMENT_DENSE_CAPSULED 0x85
+#define SL_LIDAR_ANS_TYPE_ACC_BOARD_FLAG 0xFF
+
+#define SL_LIDAR_RESP_ACC_BOARD_FLAG_MOTOR_CTRL_SUPPORT_MASK (0x1)
+typedef struct _sl_lidar_response_acc_board_flag_t
+{
+ sl_u32 support_flag;
+} __attribute__((packed)) sl_lidar_response_acc_board_flag_t;
+
+
+#define SL_LIDAR_STATUS_OK 0x0
+#define SL_LIDAR_STATUS_WARNING 0x1
+#define SL_LIDAR_STATUS_ERROR 0x2
+
+#define SL_LIDAR_RESP_MEASUREMENT_SYNCBIT (0x1<<0)
+#define SL_LIDAR_RESP_MEASUREMENT_QUALITY_SHIFT 2
+
+#define SL_LIDAR_RESP_HQ_FLAG_SYNCBIT (0x1<<0)
+
+#define SL_LIDAR_RESP_MEASUREMENT_CHECKBIT (0x1<<0)
+#define SL_LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT 1
+
+typedef struct _sl_lidar_response_sample_rate_t
+{
+ sl_u16 std_sample_duration_us;
+ sl_u16 express_sample_duration_us;
+} __attribute__((packed)) sl_lidar_response_sample_rate_t;
+
+typedef struct _sl_lidar_response_measurement_node_t
+{
+ sl_u8 sync_quality; // syncbit:1;syncbit_inverse:1;quality:6;
+ sl_u16 angle_q6_checkbit; // check_bit:1;angle_q6:15;
+ sl_u16 distance_q2;
+} __attribute__((packed)) sl_lidar_response_measurement_node_t;
+
+//[distance_sync flags]
+#define SL_LIDAR_RESP_MEASUREMENT_EXP_ANGLE_MASK (0x3)
+#define SL_LIDAR_RESP_MEASUREMENT_EXP_DISTANCE_MASK (0xFC)
+
+typedef struct _sl_lidar_response_cabin_nodes_t
+{
+ sl_u16 distance_angle_1; // see [distance_sync flags]
+ sl_u16 distance_angle_2; // see [distance_sync flags]
+ sl_u8 offset_angles_q3;
+} __attribute__((packed)) sl_lidar_response_cabin_nodes_t;
+
+
+#define SL_LIDAR_RESP_MEASUREMENT_EXP_SYNC_1 0xA
+#define SL_LIDAR_RESP_MEASUREMENT_EXP_SYNC_2 0x5
+
+#define SL_LIDAR_RESP_MEASUREMENT_HQ_SYNC 0xA5
+
+#define SL_LIDAR_RESP_MEASUREMENT_EXP_SYNCBIT (0x1<<15)
+
+typedef struct _sl_lidar_response_capsule_measurement_nodes_t
+{
+ sl_u8 s_checksum_1; // see [s_checksum_1]
+ sl_u8 s_checksum_2; // see [s_checksum_1]
+ sl_u16 start_angle_sync_q6;
+ sl_lidar_response_cabin_nodes_t cabins[16];
+} __attribute__((packed)) sl_lidar_response_capsule_measurement_nodes_t;
+
+typedef struct _sl_lidar_response_dense_cabin_nodes_t
+{
+ sl_u16 distance;
+} __attribute__((packed)) sl_lidar_response_dense_cabin_nodes_t;
+
+typedef struct _sl_lidar_response_dense_capsule_measurement_nodes_t
+{
+ sl_u8 s_checksum_1; // see [s_checksum_1]
+ sl_u8 s_checksum_2; // see [s_checksum_1]
+ sl_u16 start_angle_sync_q6;
+ sl_lidar_response_dense_cabin_nodes_t cabins[40];
+} __attribute__((packed)) sl_lidar_response_dense_capsule_measurement_nodes_t;
+
+// ext1 : x2 boost mode
+
+#define SL_LIDAR_RESP_MEASUREMENT_EXP_ULTRA_MAJOR_BITS 12
+#define SL_LIDAR_RESP_MEASUREMENT_EXP_ULTRA_PREDICT_BITS 10
+
+typedef struct _sl_lidar_response_ultra_cabin_nodes_t
+{
+ // 31 0
+ // | predict2 10bit | predict1 10bit | major 12bit |
+ sl_u32 combined_x3;
+} __attribute__((packed)) sl_lidar_response_ultra_cabin_nodes_t;
+
+typedef struct _sl_lidar_response_ultra_capsule_measurement_nodes_t
+{
+ sl_u8 s_checksum_1; // see [s_checksum_1]
+ sl_u8 s_checksum_2; // see [s_checksum_1]
+ sl_u16 start_angle_sync_q6;
+ sl_lidar_response_ultra_cabin_nodes_t ultra_cabins[32];
+} __attribute__((packed)) sl_lidar_response_ultra_capsule_measurement_nodes_t;
+
+typedef struct sl_lidar_response_measurement_node_hq_t
+{
+ sl_u16 angle_z_q14;
+ sl_u32 dist_mm_q2;
+ sl_u8 quality;
+ sl_u8 flag;
+} __attribute__((packed)) sl_lidar_response_measurement_node_hq_t;
+
+typedef struct _sl_lidar_response_hq_capsule_measurement_nodes_t
+{
+ sl_u8 sync_byte;
+ sl_u64 time_stamp;
+ sl_lidar_response_measurement_node_hq_t node_hq[96];
+ sl_u32 crc32;
+}__attribute__((packed)) sl_lidar_response_hq_capsule_measurement_nodes_t;
+
+
+# define SL_LIDAR_CONF_SCAN_COMMAND_STD 0
+# define SL_LIDAR_CONF_SCAN_COMMAND_EXPRESS 1
+# define SL_LIDAR_CONF_SCAN_COMMAND_HQ 2
+# define SL_LIDAR_CONF_SCAN_COMMAND_BOOST 3
+# define SL_LIDAR_CONF_SCAN_COMMAND_STABILITY 4
+# define SL_LIDAR_CONF_SCAN_COMMAND_SENSITIVITY 5
+
+#define SL_LIDAR_CONF_ANGLE_RANGE 0x00000000
+#define SL_LIDAR_CONF_DESIRED_ROT_FREQ 0x00000001
+#define SL_LIDAR_CONF_SCAN_COMMAND_BITMAP 0x00000002
+#define SL_LIDAR_CONF_MIN_ROT_FREQ 0x00000004
+#define SL_LIDAR_CONF_MAX_ROT_FREQ 0x00000005
+#define SL_LIDAR_CONF_MAX_DISTANCE 0x00000060
+
+#define SL_LIDAR_CONF_SCAN_MODE_COUNT 0x00000070
+#define SL_LIDAR_CONF_SCAN_MODE_US_PER_SAMPLE 0x00000071
+#define SL_LIDAR_CONF_SCAN_MODE_MAX_DISTANCE 0x00000074
+#define SL_LIDAR_CONF_SCAN_MODE_ANS_TYPE 0x00000075
+#define SL_LIDAR_CONF_LIDAR_MAC_ADDR 0x00000079
+#define SL_LIDAR_CONF_SCAN_MODE_TYPICAL 0x0000007C
+#define SL_LIDAR_CONF_SCAN_MODE_NAME 0x0000007F
+#define SL_LIDAR_CONF_DETECTED_SERIAL_BPS 0x000000A1
+
+#define SL_LIDAR_CONF_LIDAR_STATIC_IP_ADDR 0x0001CCC0
+#define SL_LIDAR_EXPRESS_SCAN_STABILITY_BITMAP 4
+#define SL_LIDAR_EXPRESS_SCAN_SENSITIVITY_BITMAP 5
+
+typedef struct _sl_lidar_response_get_lidar_conf
+{
+ sl_u32 type;
+ sl_u8 payload[0];
+}__attribute__((packed)) sl_lidar_response_get_lidar_conf_t;
+
+typedef struct _sl_lidar_response_set_lidar_conf
+{
+ sl_u32 result;
+}__attribute__((packed)) sl_lidar_response_set_lidar_conf_t;
+
+
+typedef struct _sl_lidar_response_device_info_t
+{
+ sl_u8 model;
+ sl_u16 firmware_version;
+ sl_u8 hardware_version;
+ sl_u8 serialnum[16];
+} __attribute__((packed)) sl_lidar_response_device_info_t;
+
+typedef struct _sl_lidar_response_device_health_t
+{
+ sl_u8 status;
+ sl_u16 error_code;
+} __attribute__((packed)) sl_lidar_response_device_health_t;
+
+typedef struct _sl_lidar_ip_conf_t {
+ sl_u8 ip_addr[4];
+ sl_u8 net_mask[4];
+ sl_u8 gw[4];
+}__attribute__((packed)) sl_lidar_ip_conf_t;
+
+typedef struct _sl_lidar_response_device_macaddr_info_t {
+ sl_u8 macaddr[6];
+} __attribute__((packed)) sl_lidar_response_device_macaddr_info_t;
+
+typedef struct _sl_lidar_response_desired_rot_speed_t{
+ sl_u16 rpm;
+ sl_u16 pwm_ref;
+}__attribute__((packed)) sl_lidar_response_desired_rot_speed_t;
+
+// Definition of the variable bit scale encoding mechanism
+#define SL_LIDAR_VARBITSCALE_X2_SRC_BIT 9
+#define SL_LIDAR_VARBITSCALE_X4_SRC_BIT 11
+#define SL_LIDAR_VARBITSCALE_X8_SRC_BIT 12
+#define SL_LIDAR_VARBITSCALE_X16_SRC_BIT 14
+
+#define SL_LIDAR_VARBITSCALE_X2_DEST_VAL 512
+#define SL_LIDAR_VARBITSCALE_X4_DEST_VAL 1280
+#define SL_LIDAR_VARBITSCALE_X8_DEST_VAL 1792
+#define SL_LIDAR_VARBITSCALE_X16_DEST_VAL 3328
+
+#define SL_LIDAR_VARBITSCALE_GET_SRC_MAX_VAL_BY_BITS(_BITS_) \
+ ( (((0x1<<(_BITS_)) - SL_LIDAR_VARBITSCALE_X16_DEST_VAL)<<4) + \
+ ((SL_LIDAR_VARBITSCALE_X16_DEST_VAL - SL_LIDAR_VARBITSCALE_X8_DEST_VAL)<<3) + \
+ ((SL_LIDAR_VARBITSCALE_X8_DEST_VAL - SL_LIDAR_VARBITSCALE_X4_DEST_VAL)<<2) + \
+ ((SL_LIDAR_VARBITSCALE_X4_DEST_VAL - SL_LIDAR_VARBITSCALE_X2_DEST_VAL)<<1) + \
+ SL_LIDAR_VARBITSCALE_X2_DEST_VAL - 1)
+
+
+#if defined(_WIN32)
+#pragma pack()
+#endif
diff --git a/sdk/include/sl_lidar_driver.h b/sdk/include/sl_lidar_driver.h
new file mode 100644
index 00000000..c1dbe241
--- /dev/null
+++ b/sdk/include/sl_lidar_driver.h
@@ -0,0 +1,445 @@
+/*
+ * Slamtec LIDAR SDK
+ *
+ * Copyright (c) 2020 Shanghai Slamtec Co., Ltd.
+ * http://www.slamtec.com
+ */
+ /*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#ifndef __cplusplus
+#error "The Slamtec LIDAR SDK requires a C++ compiler to be built"
+#endif
+
+#include
+#include