From 4b97e69d3bfa84f7f9567966fb0b7d1b685186ba Mon Sep 17 00:00:00 2001 From: Livox-SDK Date: Tue, 28 May 2019 17:22:21 +0800 Subject: [PATCH] fix:size initial to fix the hub lvx file generate --- README.md | 4 ++-- sample/hub_lvx_file/lvx_file.cpp | 8 +++---- sample/hub_lvx_file/main.cpp | 2 +- sample/lidar_lvx_file/lvx_file.cpp | 12 +++++----- sdk_core/CMakeLists.txt | 35 ++++++++++++++++++++++-------- sdk_core/include/livox_def.h | 2 +- 6 files changed, 40 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index bee1b65..81ff6e0 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,12 @@ The Livox LiDAR sensors can be connected to host directly or through the Livox H Livox SDK API provides a set of C style functions which can be conveniently integrated in C/C++ programs. Please refer to the [Livox SDK API Reference](https://livox-sdk.github.io/Livox-SDK/) for further information. ## 4.1 Installation -The installation procedures in Ubuntu 16.04/14.04 LTS and Windows 7/10 are shown here as examples. +The installation procedures in Ubuntu 16.04/14.04 LTS and Windows 7/10 are shown here as examples. For Ubuntu 16.04/14.04 32-bit LTS and Mac, you can get it in [Livox-SDK wiki](https://github.com/Livox-SDK/Livox-SDK/wiki). ### 4.1.1 Ubuntu 16.04/14.04 LTS #### Dependencies Livox SDK requires [CMake 3.0.0+](https://cmake.org/), [Apache Portable Runtime (APR) 1.61+](http://apr.apache.org/) and [Boost 1.54+](https://www.boost.org/) as dependencies. You can install these packages using apt: ``` -sudo apt install cmake libapr1-dev libboost-atomic-dev libboost-system-dev +sudo apt install cmake pkg-config libapr1-dev libboost-atomic-dev libboost-system-dev ``` #### Compile Livox SDK In the Livox SDK directory, run the following commands to compile the project: diff --git a/sample/hub_lvx_file/lvx_file.cpp b/sample/hub_lvx_file/lvx_file.cpp index 7a8d50a..9a8cfc4 100644 --- a/sample/hub_lvx_file/lvx_file.cpp +++ b/sample/hub_lvx_file/lvx_file.cpp @@ -23,7 +23,7 @@ // #include -#include +#include #include "lvx_file.h" #define WRITE_BUFFER_LEN 1024 * 1024 @@ -31,7 +31,7 @@ #define PACK_POINT_NUM 100 #define M_PI 3.14159265358979323846 -LvxFileHandle::LvxFileHandle() : cur_offset_(0), cur_frame_index_(0) { +LvxFileHandle::LvxFileHandle() : cur_frame_index_(0), cur_offset_(0) { } bool LvxFileHandle::InitLvxFile() { @@ -148,8 +148,8 @@ void LvxFileHandle::BasePointsHandle(LivoxEthPacket *data, LvxBasePackDetail &pa packet.point[i].y = static_cast(tmp[i].theta); packet.point[i].z = static_cast(tmp[i].phi); packet.point[i].reflectivity = tmp[i].reflectivity; - LivoxPoint temp = { packet.point[i].x * sin(packet.point[i].y) * cos(packet.point[i].z), packet.point[i].x * sin(packet.point[i].y) * sin(packet.point[i].z), packet.point[i].x * cos(packet.point[i].y) };; + LivoxPoint temp = { packet.point[i].x * std::sin(packet.point[i].y) * std::cos(packet.point[i].z), packet.point[i].x * std::sin(packet.point[i].y) * std::sin(packet.point[i].z), packet.point[i].x * std::cos(packet.point[i].y) }; packet.point[i] = temp; } } -} \ No newline at end of file +} diff --git a/sample/hub_lvx_file/main.cpp b/sample/hub_lvx_file/main.cpp index ef656cd..0e4df84 100644 --- a/sample/hub_lvx_file/main.cpp +++ b/sample/hub_lvx_file/main.cpp @@ -96,7 +96,7 @@ void OnGetLidarUnitsExtrinsicParameter(uint8_t status, uint8_t handle, HubGetExt strncpy((char *)lidar_info.hub_broadcast_code, broadcast_code_list[0].c_str(), kBroadcastCodeSize); std::unique_ptr device_list(new DeviceInfo[kMaxLidarCount]); - std::unique_ptr size(new uint8_t); + std::unique_ptr size(new uint8_t(kMaxLidarCount)); GetConnectedDevices(device_list.get(), size.get()); for (int j = 0; j < kMaxLidarCount; j++) { if (strncmp(device_list[j].broadcast_code, temp.broadcast_code, kBroadcastCodeSize) == 0) { diff --git a/sample/lidar_lvx_file/lvx_file.cpp b/sample/lidar_lvx_file/lvx_file.cpp index 553ed0c..9763f9f 100644 --- a/sample/lidar_lvx_file/lvx_file.cpp +++ b/sample/lidar_lvx_file/lvx_file.cpp @@ -23,7 +23,7 @@ // #include -#include +#include #include "lvx_file.h" #include "third_party/rapidxml/rapidxml.hpp" #include "third_party/rapidxml/rapidxml_utils.hpp" @@ -33,7 +33,7 @@ #define PACK_POINT_NUM 100 #define M_PI 3.14159265358979323846 -LvxFileHandle::LvxFileHandle() : cur_offset_(0), cur_frame_index_(0) { +LvxFileHandle::LvxFileHandle() : cur_frame_index_(0), cur_offset_(0) { } bool LvxFileHandle::InitLvxFile() { @@ -159,9 +159,9 @@ void LvxFileHandle::CalcExtrinsicPoints(LvxBasePackDetail &packet) { info.roll = static_cast(info.roll * M_PI / 180.0); info.pitch = static_cast(info.pitch * M_PI / 180.0); info.yaw = static_cast(info.yaw * M_PI / 180.0); - float rotate[3][3] = { { cos(info.pitch) * cos(info.yaw), sin(info.roll) * sin(info.pitch) * cos(info.yaw) - cos(info.roll) * sin(info.yaw), cos(info.roll) * sin(info.pitch) * cos(info.yaw) + sin(info.roll) * sin(info.yaw) }, - { cos(info.pitch) * sin(info.yaw), sin(info.roll) * sin(info.pitch) * sin(info.yaw) + cos(info.roll) * cos(info.yaw), cos(info.roll) * sin(info.pitch) * sin(info.yaw) - sin(info.roll) * cos(info.yaw) }, - { -sin(info.pitch), sin(info.roll) * cos(info.pitch), cos(info.roll) * cos(info.pitch) } }; + float rotate[3][3] = { { std::cos(info.pitch) * std::cos(info.yaw), std::sin(info.roll) * std::sin(info.pitch) * std::cos(info.yaw) - std::cos(info.roll) * std::sin(info.yaw), std::cos(info.roll) * std::sin(info.pitch) * std::cos(info.yaw) + std::sin(info.roll) * std::sin(info.yaw) }, + { std::cos(info.pitch) * std::sin(info.yaw), std::sin(info.roll) * std::sin(info.pitch) * std::sin(info.yaw) + std::cos(info.roll) * std::cos(info.yaw), std::cos(info.roll) * std::sin(info.pitch) * std::sin(info.yaw) - std::sin(info.roll) * std::cos(info.yaw) }, + { -std::sin(info.pitch), std::sin(info.roll) * std::cos(info.pitch), std::cos(info.roll) * std::cos(info.pitch) } }; float trans[3] = { static_cast(info.x), static_cast(info.y), static_cast(info.z) }; if (packet.data_type == 0) { @@ -174,7 +174,7 @@ void LvxFileHandle::CalcExtrinsicPoints(LvxBasePackDetail &packet) { } else { for (int i = 0; i < PACK_POINT_NUM; i++) { - LivoxPoint temp = { packet.point[i].x * sin(packet.point[i].y) * cos(packet.point[i].z), packet.point[i].x * sin(packet.point[i].y) * sin(packet.point[i].z), packet.point[i].x * cos(packet.point[i].y) };; + LivoxPoint temp = { packet.point[i].x * std::sin(packet.point[i].y) * std::cos(packet.point[i].z), packet.point[i].x * std::sin(packet.point[i].y) * std::sin(packet.point[i].z), packet.point[i].x * std::cos(packet.point[i].y) }; packet.point[i].x = temp.x * rotate[0][0] + temp.y * rotate[0][1] + temp.z * rotate[0][2] + trans[0]; packet.point[i].y = temp.x * rotate[1][0] + temp.y * rotate[1][1] + temp.z * rotate[1][2] + trans[1]; packet.point[i].z = temp.x * rotate[2][0] + temp.y * rotate[2][1] + temp.z * rotate[2][2] + trans[2]; diff --git a/sdk_core/CMakeLists.txt b/sdk_core/CMakeLists.txt index bdfa02b..0bfdb07 100644 --- a/sdk_core/CMakeLists.txt +++ b/sdk_core/CMakeLists.txt @@ -3,6 +3,11 @@ cmake_minimum_required(VERSION 3.0) set(SDK_LIBRARY ${PROJECT_NAME}_static) add_library(${SDK_LIBRARY} STATIC "") +set(LIVOX_SDK_MAJOR_VERSION "1") +set(LIVOX_SDK_MINOR_VERSION "2") +set(LIVOX_SDK_PATCH_VERSION "1") +set(LIVOX_SDK_VERSION_STRING "${LIVOX_SDK_MAJOR_VERSION}.${LIVOX_SDK_MINOR_VERSION}.${LIVOX_SDK_PATCH_VERSION}") + if (WIN32) find_path(APR_INCLUDE_DIRS apr.h) find_library(APR_LIBRARIES libapr-1) @@ -18,18 +23,30 @@ if (APR_FOUND) target_include_directories(${SDK_LIBRARY} PUBLIC ${APR_INCLUDE_DIRS}) - target_link_libraries(${SDK_LIBRARY} - PUBLIC - ${APR_LIBRARIES}) + if (APR_LIBRARY_DIRS AND NOT APPLE) + target_link_libraries(${SDK_LIBRARY} + PUBLIC + ${APR_LIBRARY_DIRS}/libapr-1.so) + else () + target_link_libraries(${SDK_LIBRARY} + PUBLIC + ${APR_LIBRARIES}) + endif () endif () find_package(Boost 1.54 REQUIRED COMPONENTS system) -if (Boost_FOUND AND Boost_VERSION LESS 106900) - target_link_libraries(${SDK_LIBRARY} - PUBLIC - Boost::boost - Boost::system) -endif () +if(Boost_FOUND) + if (Boost_VERSION LESS 106900) + target_link_libraries(${SDK_LIBRARY} + PUBLIC + Boost::boost + Boost::system) + else() + target_link_libraries(${SDK_LIBRARY} + PUBLIC + Boost::boost) + endif() +endif() target_include_directories(${SDK_LIBRARY} PUBLIC diff --git a/sdk_core/include/livox_def.h b/sdk_core/include/livox_def.h index bd37e7b..dccad49 100644 --- a/sdk_core/include/livox_def.h +++ b/sdk_core/include/livox_def.h @@ -91,7 +91,7 @@ typedef enum { #define LIVOX_SDK_MAJOR_VERSION 1 #define LIVOX_SDK_MINOR_VERSION 2 -#define LIVOX_SDK_PATCH_VERSION 0 +#define LIVOX_SDK_PATCH_VERSION 1 #define kBroadcastCodeSize 16