1 Commits

Author SHA1 Message Date
Livox-SDK e91b6feb13 fix:size initial to fix the hub lvx file generate 2019-05-28 17:22:21 +08:00
6 changed files with 40 additions and 23 deletions
+2 -2
View File
@@ -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:
+4 -4
View File
@@ -23,7 +23,7 @@
//
#include <time.h>
#include <math.h>
#include <cmath>
#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<float>(tmp[i].theta);
packet.point[i].z = static_cast<float>(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;
}
}
}
}
+1 -1
View File
@@ -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<DeviceInfo[]> device_list(new DeviceInfo[kMaxLidarCount]);
std::unique_ptr<uint8_t> size(new uint8_t);
std::unique_ptr<uint8_t> 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) {
+6 -6
View File
@@ -23,7 +23,7 @@
//
#include <time.h>
#include <math.h>
#include <cmath>
#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<float>(info.roll * M_PI / 180.0);
info.pitch = static_cast<float>(info.pitch * M_PI / 180.0);
info.yaw = static_cast<float>(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<float>(info.x), static_cast<float>(info.y), static_cast<float>(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];
+26 -9
View File
@@ -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
+1 -1
View File
@@ -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