diff --git a/README.md b/README.md index 173dac7..0ac9c85 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,25 @@ This SDK is only applicable to the LiDAR products sold by Shenzhen LDROBOT Co., | LDROBOT LiDAR LD14 | 2D Triangle| --- -## Instructions -- [EN](./INSTRUCTIONS.en.md) -- [CN](./INSTRUCTIONS.cn.md) +## Get SDK +- download package file or use git. +```bash +$ cd ~ + +$ mkdir ldlidar_ws + +$ cd ldlidar_ws + +$ git clone https://github.com/ldrobotSensorTeam/ldlidar_sdk.git +``` + +--- +## Introduction to linux application example +- [EN](./sample/linux/README.md) +- [CN](./sample/linux/README_CN.md) + +--- + +## Introduction to windows application example +- [EN](./sample/windows/README.md) +- [CN](./sample/windows/README_CN.md) diff --git a/include/ldlidar_driver/ldlidar_datatype.h b/include/ldlidar_driver/ldlidar_datatype.h index 9de366b..c40ac12 100644 --- a/include/ldlidar_driver/ldlidar_datatype.h +++ b/include/ldlidar_driver/ldlidar_datatype.h @@ -26,7 +26,7 @@ #include #include -#define LDLiDAR_SDK_VERSION_NUMBER "3.1.0" +#define LDLiDAR_SDK_VERSION_NUMBER "3.1.1" #define ANGLE_TO_RADIAN(angle) ((angle)*3141.59 / 180000) diff --git a/CMakeLists.txt b/sample/linux/CMakeLists.txt similarity index 70% rename from CMakeLists.txt rename to sample/linux/CMakeLists.txt index 2e7efd0..03bef0b 100644 --- a/CMakeLists.txt +++ b/sample/linux/CMakeLists.txt @@ -1,73 +1,61 @@ -cmake_minimum_required(VERSION 2.8.3) -project(ldlidar) - -message(STATUS "operation system is ${CMAKE_SYSTEM}") -if(CMAKE_SYSTEM_NAME MATCHES "Linux") - message(STATUS "current platform: Linux ") -elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") - message(STATUS "current platform: Windows") -elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - message(STATUS "current platform: FreeBSD") -else() - message(STATUS "other platform: ${CMAKE_SYSTEM_NAME}") -endif (CMAKE_SYSTEM_NAME MATCHES "Linux") - - -if(${CMAKE_BUILD_TYPE} MATCHES "Release") - set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -std=c++11 -Wall") - message(STATUS "Mode: Release") - message(STATUS "optional:-std=c++11 -Wall") -elseif(${CMAKE_BUILD_TYPE} MATCHES "Debug") - set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -std=c++11 -Wall -Wextra -g2 -ggdb") - message(STATUS "Mode: Debug") - message(STATUS "optional:-std=c++11 -Wall -Wextra -g2 -ggdb") -else() - set(CMAKE_BUILD_TYPE "Debug") - set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -std=c++11 -Wall -Wextra -g2 -ggdb") - message(STATUS "Mode: Debug") - message(STATUS "optional:-std=c++11 -Wall -Wextra -g2 -ggdb") -endif() - -########### -## Build ## -########### - -## Specify additional locations of header files -## Your package locations should be listed before other locations -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/include/ -) - -file(GLOB LDLIDAR_DRIVER_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/ldlidar_driver/*.cpp) - -add_executable(${PROJECT_NAME} - ${CMAKE_CURRENT_SOURCE_DIR}/sample/linux/demo.cpp -) - -add_library(ldlidar_driver_static STATIC - ${LDLIDAR_DRIVER_SOURCE} -) - -add_library(ldlidar_driver_shared SHARED - ${LDLIDAR_DRIVER_SOURCE} -) - -# rename library name -set_target_properties (ldlidar_driver_static PROPERTIES OUTPUT_NAME "ldlidar_driver") -set_target_properties (ldlidar_driver_shared PROPERTIES OUTPUT_NAME "ldlidar_driver") - -# binary file link to library -target_link_libraries(${PROJECT_NAME} ldlidar_driver_static pthread) - -########### -## Install ## -########### - -INSTALL(TARGETS ldlidar_driver_static ldlidar_driver_shared - ARCHIVE DESTINATION lib/ldlidar_driver - LIBRARY DESTINATION share/ldlidar_driver -) - -INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/include - DESTINATION include -) +cmake_minimum_required(VERSION 2.8.3) +project(ldlidar) + +if(${CMAKE_BUILD_TYPE} MATCHES "Release") + set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -std=c++11 -Wall") + message(STATUS "Mode: Release") + message(STATUS "optional:-std=c++11 -Wall") +elseif(${CMAKE_BUILD_TYPE} MATCHES "Debug") + set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -std=c++11 -Wall -Wextra -g2 -ggdb") + message(STATUS "Mode: Debug") + message(STATUS "optional:-std=c++11 -Wall -Wextra -g2 -ggdb") +else() + set(CMAKE_BUILD_TYPE "Debug") + set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -std=c++11 -Wall -Wextra -g2 -ggdb") + message(STATUS "Mode: Debug") + message(STATUS "optional:-std=c++11 -Wall -Wextra -g2 -ggdb") +endif() + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../../include/ +) + +file(GLOB LDLIDAR_DRIVER_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../../src/ldlidar_driver/*.cpp) + +add_executable(${PROJECT_NAME} + demo.cpp +) + +add_library(ldlidar_driver_static STATIC + ${LDLIDAR_DRIVER_SOURCE} +) + +add_library(ldlidar_driver_shared SHARED + ${LDLIDAR_DRIVER_SOURCE} +) + +# rename library name +set_target_properties (ldlidar_driver_static PROPERTIES OUTPUT_NAME "ldlidar_driver") +set_target_properties (ldlidar_driver_shared PROPERTIES OUTPUT_NAME "ldlidar_driver") + +# binary file link to library +target_link_libraries(${PROJECT_NAME} ldlidar_driver_static pthread) + +########### +## Install ## +########### + +INSTALL(TARGETS ldlidar_driver_static ldlidar_driver_shared + ARCHIVE DESTINATION lib/ldlidar_driver + LIBRARY DESTINATION share/ldlidar_driver +) + +INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/include + DESTINATION include +) diff --git a/INSTRUCTIONS_EN.md b/sample/linux/README.md similarity index 74% rename from INSTRUCTIONS_EN.md rename to sample/linux/README.md index 36df448..9b1c70f 100644 --- a/INSTRUCTIONS_EN.md +++ b/sample/linux/README.md @@ -1,32 +1,23 @@ -## get SDK sound code -```bash -$ cd ~ - -$ mkdir ldlidar_ws - -$ cd ldlidar_ws - -$ git clone https://github.com/ldrobotSensorTeam/ldlidar_sdk.git -``` -## system setup +# 1.system setup - Connect the LiDAR to your system motherboard via an onboard serial port or usB-to-serial module (for example, CP2102 module). - Set the -x permission for the serial port device mounted by the lidar in the system (for example, /dev/ttyUSB0),In actual use, the LiDAR can be set according to the actual mounted status of your system, you can use 'ls -l /dev' command to view. ``` bash -$ cd ~/ldlidar_ws/ldlidar_sdk +$ cd ~/ldlidar_ws/ldlidar_sdk/sample/linux $ sudo chmod 777 /dev/ttyUSB0 ``` -## build +# 2.build ``` bash -$ cd ~/ldlidar_ws/ldlidar_sdk +$ cd ~/ldlidar_ws/ldlidar_sdk/sample/linux + $ ./auto_build.sh ``` -## run +# 3.run ``` bash $ ./build/ldlidar # example: diff --git a/INSTRUCTIONS_CN.md b/sample/linux/README_CN.md similarity index 72% rename from INSTRUCTIONS_CN.md rename to sample/linux/README_CN.md index 236b113..9368ed6 100644 --- a/INSTRUCTIONS_CN.md +++ b/sample/linux/README_CN.md @@ -1,33 +1,23 @@ -## 获取SDK源码 -```bash -$ cd ~ - -$ mkdir ldlidar_ws - -$ cd ldlidar_ws - -$ git clone https://github.com/ldrobotSensorTeam/ldlidar_sdk.git -``` - -## 系统设置 +# 1.系统设置 - 第一步,通过板载串口或者USB转串口模块(例如,cp2102模块)的方式,使激光雷达连接到你的系统主板. - 第二步,设置激光雷达在系统中挂载的串口设备-x权限,根据激光雷达在你的系统中的实际挂载情况来设置,可以使用`ls -l /dev`命令查看,(以/dev/ttyUSB0为例). ``` bash -$ cd ~/ldlidar_ws/ldlidar_sdk +$ cd ~/ldlidar_ws/ldlidar_sdk/sample/linux $ sudo chmod 777 /dev/ttyUSB0 ``` -## 编译 +# 2.编译 ```bash -$ cd ~/ldlidar_ws/ldlidar_sdk +$ cd ~/ldlidar_ws/ldlidar_sdk/sample/linux + $ ./auto_build.sh ``` -## 运行 +# 3.运行 ``` bash $ ./build/ldlidar # example: diff --git a/auto_build.sh b/sample/linux/auto_build.sh similarity index 100% rename from auto_build.sh rename to sample/linux/auto_build.sh diff --git a/clean_build.sh b/sample/linux/clean_build.sh similarity index 100% rename from clean_build.sh rename to sample/linux/clean_build.sh diff --git a/sample/windows/README.md b/sample/windows/README.md new file mode 100644 index 0000000..0c69050 --- /dev/null +++ b/sample/windows/README.md @@ -0,0 +1,12 @@ +# Use CMake to generate visual studio C++ projects +> Prerequisites The visual studio IDE and CMake Tool must be installed on the PC. + +## Method 1: Command line mode +- Open the powershell terminal in the 'sample/windows' directory and run the following command to create a C++ project in the' Visual Studio 15 2017 Win64 'environment as an example. +```ps1 +mkdir build + +cd build + +cmake -G "Visual Studio 15 2017 Win64" .. / +` ` ` \ No newline at end of file diff --git a/sample/windows/README_CN.md b/sample/windows/README_CN.md index 3ef08fa..cdca5cf 100644 --- a/sample/windows/README_CN.md +++ b/sample/windows/README_CN.md @@ -4,7 +4,7 @@ ## 方法一:命令行方式 - 在`sample/windows`目录下打开powershell终端,以创建`Visual Studio 15 2017 Win64`环境下的C++工程为例,运行如下命令。 ```ps1 -mkdir build +mkdir build # create `build` folder. cd build diff --git a/sample/windows/windemo.cpp b/sample/windows/windemo.cpp index d8dab7b..1e65042 100644 --- a/sample/windows/windemo.cpp +++ b/sample/windows/windemo.cpp @@ -104,12 +104,11 @@ int main(int argc, char **argv) { LOG_INFO_LITE("speed(Hz):%f, size:%d,stamp_begin:%lu, stamp_end:%lu", lidar_scan_freq, laser_scan_points.size(), laser_scan_points.front().stamp, laser_scan_points.back().stamp); // output 2d point cloud data -#if 0 for (auto point : laser_scan_points) { LOG_INFO_LITE("stamp(ns):%lu,angle:%f,distance(mm):%d,intensity:%d", point.stamp, point.angle, point.distance, point.intensity); } -#endif + break; } case ldlidar::LidarStatus::DATA_TIME_OUT: { @@ -132,50 +131,6 @@ int main(int argc, char **argv) { delete ldlidar_drv; ldlidar_drv = nullptr; -#if 0 - CommPort cp; - - std::vector info; - - - CommPort::availablePorts(info); - - - PortParams pp; - pp.baudrate = (BaudRate)921600; - - cp.setPortParams(pp); - - printf("available port:\n\n"); - int n = 0; - for (auto p : info) - { - printf("[%d] %s, %s,\n", n++, p.name.c_str(), p.description.c_str()); - } - - printf("\nplease select port:\n"); - - scanf_s("%d", &n); - - if (n > info.size()) - { - return -1; - } - - - // cp.setReadCallback(); - - cp.open(info[n].name); - - printf("set address\n"); - - - while (1); - - cp.close(); -#endif - - system("pause"); return 0; } \ No newline at end of file