Initial commit: Livox SDK2 source (excluding build artifacts)

This commit is contained in:
gardentech
2026-08-26 01:38:14 +09:00
commit 34a9a52cd4
221 changed files with 54102 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.0)
set(DEMO_NAME debug_point_cloud)
add_executable(${DEMO_NAME} main.cpp)
target_link_libraries(${DEMO_NAME}
PUBLIC
livox_lidar_sdk_static)
+23
View File
@@ -0,0 +1,23 @@
{
"MID360": {
"lidar_net_info" : {
"cmd_data_port": 56100,
"push_msg_port": 56200,
"point_data_port": 56300,
"imu_data_port": 56400,
"log_data_port": 56500
},
"host_net_info" : {
"cmd_data_ip" : "192.168.1.5",
"cmd_data_port": 56101,
"push_msg_ip": "192.168.1.5",
"push_msg_port": 56201,
"point_data_ip": "192.168.1.5",
"point_data_port": 56301,
"imu_data_ip" : "192.168.1.5",
"imu_data_port": 56401,
"log_data_ip" : "192.168.1.5",
"log_data_port": 56501
}
}
}
+24
View File
@@ -0,0 +1,24 @@
{
"lidar_log_path": "./",
"HAP": {
"lidar_net_info" : {
"cmd_data_port" : 56000,
"push_msg_port" : 0,
"point_data_port": 57000,
"imu_data_port" : 58000,
"log_data_port" : 59000
},
"host_net_info" : [
{
"host_ip" : "192.168.1.5",
"cmd_data_port" : 56000,
"push_msg_port" : 0,
"point_data_port": 57000,
"imu_data_port" : 58000,
"log_data_port" : 59000
}
]
}
}
+148
View File
@@ -0,0 +1,148 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2022 Livox. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
#include "livox_lidar_def.h"
#include "livox_lidar_api.h"
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <thread>
#include <chrono>
#include <iostream>
#include <string>
#include <vector>
#include <mutex>
#include <condition_variable>
#include <map>
#include <csignal>
std::condition_variable quit_condition;
std::mutex mtx;
void PointCloudCallback(uint32_t handle, const uint8_t dev_type, LivoxLidarEthernetPacket* data, void* client_data) {
if (data == nullptr) {
return;
}
printf("point cloud handle: %d, data_num: %d, data_type: %d, length: %d, frame_counter: %d\n",
handle, data->dot_num, data->data_type, data->length, data->frame_cnt);
}
void ImuDataCallback(uint32_t handle, const uint8_t dev_type, LivoxLidarEthernetPacket* data, void* client_data) {
if (data == nullptr) {
return;
}
printf("Imu data callback handle:%u, data_num:%u, data_type:%u, length:%u, frame_counter:%u.\n",
handle, data->dot_num, data->data_type, data->length, data->frame_cnt);
}
void WorkModeCallback(livox_status status, uint32_t handle,LivoxLidarAsyncControlResponse *response, void *client_data) {
if (response == nullptr) {
return;
}
printf("WorkModeCallack, status:%u, handle:%u, ret_code:%u, error_key:%u",
status, handle, response->ret_code, response->error_key);
}
void LoggerStartCallback(livox_status status, uint32_t handle, LivoxLidarLoggerResponse* response, void* client_data) {
if (status != kLivoxLidarStatusSuccess) {
printf("Start logger failed, the status :%d\n", status);
LivoxLidarStartLogger(handle, kLivoxLidarRealTimeLog, LoggerStartCallback, nullptr);
return;
}
if (response == nullptr) {
printf("Start logger failed, the response is nullptr.\n");
LivoxLidarStartLogger(handle, kLivoxLidarRealTimeLog, LoggerStartCallback, nullptr);
return;
}
if (response->ret_code != 0) {
printf("Start logger failed, the response ret_Code:%d.\n", response->ret_code);
LivoxLidarStartLogger(handle, kLivoxLidarRealTimeLog, LoggerStartCallback, nullptr);
return;
}
printf("The lidar[%u] start logger succ.\n", handle);
}
void DebugPointCloudCallback(livox_status status, uint32_t handle, LivoxLidarLoggerResponse* response, void* client_data) {
printf("--------------------------------------------------------------------------------\n");
printf("livox_status = %d, Lidar: %u response is %d\n", status, handle, response->ret_code);
printf("--------------------------------------------------------------------------------\n");
}
void LidarInfoChangeCallback(const uint32_t handle, const LivoxLidarInfo* info, void* client_data) {
if (info == nullptr) {
printf("lidar info change callback failed, the info is nullptr.\n");
return;
}
printf("LidarInfoChangeCallback Lidar handle: %u SN: %s\n", handle, info->sn);
SetLivoxLidarWorkMode(handle, kLivoxLidarNormal, WorkModeCallback, nullptr);
LivoxLidarStartLogger(handle, kLivoxLidarRealTimeLog, LoggerStartCallback, nullptr);
SetLivoxLidarDebugPointCloud(handle, true, DebugPointCloudCallback, nullptr);
// sleep(10);
// SetLivoxLidarDebugPointCloud(handle, false, DebugPointCloudCallback, nullptr);
}
void Stop(int signal) {
quit_condition.notify_all();
}
int main(int argc, const char *argv[]) {
if (argc != 2) {
printf("Params Invalid, must input config path.\n");
return -1;
}
const std::string path = argv[1];
if (!LivoxLidarSdkInit(path.c_str())) {
printf("Livox Init Failed\n");
LivoxLidarSdkUninit();
return -1;
}
// SetLivoxLidarPointCloudCallBack(PointCloudCallback, nullptr);
// SetLivoxLidarImuDataCallback(ImuDataCallback, nullptr);
SetLivoxLidarInfoChangeCallback(LidarInfoChangeCallback, nullptr);
// capture Ctrl + C signal.
std::signal(SIGINT, Stop);
std::unique_lock<std::mutex> lock(mtx);
quit_condition.wait(lock);
printf("Deivice Logger exit.\n");
LivoxLidarSdkUninit();
printf("Livox Quick Start Demo End!\n");
return 0;
}
@@ -0,0 +1,24 @@
{
"lidar_log_path": "./",
"MID360": {
"lidar_net_info" : {
"cmd_data_port" : 56100,
"push_msg_port" : 56200,
"point_data_port": 56300,
"imu_data_port" : 56400,
"log_data_port" : 56500
},
"host_net_info" : [
{
"host_ip" : "192.168.1.5",
"cmd_data_port" : 56101,
"push_msg_port" : 56201,
"point_data_port": 56301,
"imu_data_port" : 56401,
"log_data_port" : 56501
}
]
}
}
@@ -0,0 +1,24 @@
{
"lidar_log_path": "./",
"Mid360s": {
"lidar_net_info" : {
"cmd_data_port" : 56100,
"push_msg_port" : 56200,
"point_data_port": 56300,
"imu_data_port" : 56400,
"log_data_port" : 56500
},
"host_net_info" : [
{
"host_ip" : "192.168.1.5",
"cmd_data_port" : 56101,
"push_msg_port" : 56201,
"point_data_port": 56301,
"imu_data_port" : 56401,
"log_data_port" : 56501
}
]
}
}