Skip to content

Commit

Permalink
[update][框架优化]这是第一个稳定版本,版本号v3.1.1,更新点为:
Browse files Browse the repository at this point in the history
该SDK将支持在windos和linux系统下使用,目前支持与乐动激光雷达的串口进行通信和数据解析操作,已完成所支持产品的SDK功能测试和说明文档更新。
  • Loading branch information
mingdonghu committed Feb 25, 2023
1 parent 9b5e122 commit cbe9b1b
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 155 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion include/ldlidar_driver/ldlidar_datatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <iostream>
#include <vector>

#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)

Expand Down
134 changes: 61 additions & 73 deletions CMakeLists.txt → sample/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
21 changes: 6 additions & 15 deletions INSTRUCTIONS_EN.md → sample/linux/README.md
Original file line number Diff line number Diff line change
@@ -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 <lidar_typename> <serial_number>
# example:
Expand Down
22 changes: 6 additions & 16 deletions INSTRUCTIONS_CN.md → sample/linux/README_CN.md
Original file line number Diff line number Diff line change
@@ -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 <lidar_typename> <serial_number>
# example:
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions sample/windows/README.md
Original file line number Diff line number Diff line change
@@ -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" .. /
` ` `
2 changes: 1 addition & 1 deletion sample/windows/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## 方法一:命令行方式
-`sample/windows`目录下打开powershell终端,以创建`Visual Studio 15 2017 Win64`环境下的C++工程为例,运行如下命令。
```ps1
mkdir build
mkdir build # create `build` folder.
cd build
Expand Down
47 changes: 1 addition & 46 deletions sample/windows/windemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -132,50 +131,6 @@ int main(int argc, char **argv) {
delete ldlidar_drv;
ldlidar_drv = nullptr;

#if 0
CommPort cp;

std::vector<PortInfo> 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;
}

0 comments on commit cbe9b1b

Please sign in to comment.