Skip to content

Commit

Permalink
[update][框架优化]完成基于lidar sdk的windows应用示例开发与测试,并对现框架源码进行通用化优化
Browse files Browse the repository at this point in the history
  • Loading branch information
mingdonghu committed Feb 21, 2023
1 parent 5eab49e commit 9b5e122
Show file tree
Hide file tree
Showing 14 changed files with 1,049 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.json
build/**
src/test_sys/build/**
sample/windows/build/**
9 changes: 0 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ else()
message(STATUS "other platform: ${CMAKE_SYSTEM_NAME}")
endif (CMAKE_SYSTEM_NAME MATCHES "Linux")

if(WIN32)
message(STATUS "Now is windows")
elseif(APPLE)
message(STATUS "Now is Apple systens.")
elseif(UNIX)
message(STATUS "Now is UNIX-like OS's.")
endif()
message(STATUS "###################################")


if(${CMAKE_BUILD_TYPE} MATCHES "Release")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -std=c++11 -Wall")
Expand Down
2 changes: 2 additions & 0 deletions include/ldlidar_driver/ldlidar_datatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <iostream>
#include <vector>

#define LDLiDAR_SDK_VERSION_NUMBER "3.1.0"

#define ANGLE_TO_RADIAN(angle) ((angle)*3141.59 / 180000)

// lidar error code definition
Expand Down
22 changes: 22 additions & 0 deletions include/ldlidar_driver/lipkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum {
POINT_PER_PACK = 12,
};

#ifdef __linux__
typedef struct __attribute__((packed)) {
uint16_t distance;
uint8_t intensity;
Expand All @@ -54,6 +55,27 @@ typedef struct __attribute__((packed)) {
uint16_t timestamp;
uint8_t crc8;
} LiDARFrameType;
#else

#pragma pack(1)
typedef struct {
uint16_t distance;
uint8_t intensity;
} LidarPointStructType;

typedef struct {
uint8_t header;
uint8_t ver_len;
uint16_t speed;
uint16_t start_angle;
LidarPointStructType point[POINT_PER_PACK];
uint16_t end_angle;
uint16_t timestamp;
uint8_t crc8;
} LiDARFrameType;
#pragma pack()

#endif

class LiPkg {
public:
Expand Down
22 changes: 15 additions & 7 deletions include/ldlidar_driver/log_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#ifndef __LOGMODULE_H_
#define __LOGMODULE_H_


#define LINUX

#define ENABLE_LOG_DIS_OUTPUT

#define ENABLE_CONSOLE_LOG_DISPALY
Expand All @@ -32,7 +31,7 @@
#include <chrono>
#include <stdlib.h>

#ifndef LINUX
#ifndef __linux__
#include <windows.h>
#else
//#include <pthread.h>
Expand Down Expand Up @@ -108,16 +107,25 @@ class LogPrint :public ILogRealization {
}
};

#ifndef LINUX
#ifndef __linux__
class LogOutputString :public ILogRealization {
public:
virtual void Initializion(const char* path = NULL) {
return ;
}

virtual void LogPrintInf(const char* str) {
OutputDebugString((LPCTSTR)str);
OutputDebugString("\r\n");
//OutputDebugString((LPCTSTR)str); // 将字符串发送到调试器进行显示。
//OutputDebugString("\r\n");

printf("%s\r\n", str); // 将字符串发送到控制台显示
}

virtual void LogPrintData(const char* str) {
//OutputDebugString((LPCTSTR)str); // 将字符串发送到调试器进行显示。
//OutputDebugString("\r\n");

printf("%s\r\n", str); // 将字符串发送到控制台显示
}

ILOGFREE(LogOutputString)
Expand Down Expand Up @@ -186,7 +194,7 @@ class LogModule {

static LogModule* s_plog_module_;

#ifndef LINUX
#ifndef __linux__
CRITICAL_SECTION mutex_lock_;
#else
pthread_mutex_t mutex_lock_;
Expand Down
20 changes: 20 additions & 0 deletions sample/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.5)

project (ldlidar_driver_win LANGUAGES CXX)

include_directories(
${PROJECT_SOURCE_DIR}/
${PROJECT_SOURCE_DIR}/../../include
)

add_executable(demo
${PROJECT_SOURCE_DIR}/windemo.cpp
${PROJECT_SOURCE_DIR}/ldlidar_driver_win.cpp
${PROJECT_SOURCE_DIR}/commport.cpp
${PROJECT_SOURCE_DIR}/../../src/ldlidar_driver/lipkg.cpp
${PROJECT_SOURCE_DIR}/../../src/ldlidar_driver/log_module.cpp
${PROJECT_SOURCE_DIR}/../../src/ldlidar_driver/sl_transform.cpp
${PROJECT_SOURCE_DIR}/../../src/ldlidar_driver/slbf.cpp
${PROJECT_SOURCE_DIR}/../../src/ldlidar_driver/tofbf.cpp
)
target_compile_features(demo PUBLIC cxx_std_11)
12 changes: 12 additions & 0 deletions sample/windows/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 使用CMake生成visual studio C++ 工程
> 前提条件,PC上需要提前安装有visual studio IDE 和 CMake Tool。
## 方法一:命令行方式
-`sample/windows`目录下打开powershell终端,以创建`Visual Studio 15 2017 Win64`环境下的C++工程为例,运行如下命令。
```ps1
mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" ../
```
Loading

0 comments on commit 9b5e122

Please sign in to comment.