diff --git a/README.md b/README.md index a7a2844..39ad03d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -# Official Q&A site - -https://groups.google.com/forum/#!forum/livox-lidars - # 1 Introduction Livox SDK is the software development kit designed for all Livox products. It is developed based on C/C++ following Livox SDK Communication Protocol, and provides easy-to-use C style API. With Livox SDK, users can quickly connect to Livox products and receive point cloud data. @@ -41,7 +37,8 @@ sudo apt install cmake libapr1-dev libboost-atomic-dev libboost-system-dev #### Compile Livox SDK In the Livox SDK directory, run the following commands to compile the project: ``` -cd build +git clone https://github.com/Livox-SDK/Livox-SDK.git +cd Livox-SDK/build cmake .. make sudo make install @@ -97,4 +94,4 @@ After compiling the Livox SDK as shown in section 4.1.2, you can find `hub_sampl # 5 Support You can get support from Livox with the following methods: * Send email to dev@livoxtech.com with a clear description of your problem and your setup -* Github Issues +* Github Issues \ No newline at end of file diff --git a/sample/hub/main.c b/sample/hub/main.c index e2748e4..ba4c4fb 100644 --- a/sample/hub/main.c +++ b/sample/hub/main.c @@ -57,6 +57,10 @@ void GetLidarData(uint8_t handle, LivoxEthPacket *data, uint32_t data_num) { ++receive_packet_count; if (0 == (receive_packet_count % 10000)) { printf("receive packet count %d %d\n", data->id, receive_packet_count); + + /** Parsing the timestamp and the point cloud data. */ + uint64_t cur_timestamp = *((uint64_t *)(data->timestamp)); + LivoxRawPoint *p_point_data = (LivoxRawPoint *)data->data; } printf("receive packet from %d \n", (uint16_t) HubGetLidarHandle(data->slot, data->id)); } @@ -191,15 +195,24 @@ void OnDeviceBroadcast(const BroadcastDeviceInfo *info) { } int main(int argc, const char *argv[]) { + printf("Livox SDK initializing.\n"); + /** Initialize Livox-SDK. */ if (!Init()) { - return -1; + return -1; } + printf("Livox SDK has been initialized.\n"); + + LivoxSdkVersion _sdkversion; + GetLivoxSdkVersion(&_sdkversion); + printf("Livox SDK version %d.%d.%d .\n", _sdkversion.major, _sdkversion.minor, _sdkversion.patch); memset(devices, 0, sizeof(devices)); SetBroadcastCallback(OnDeviceBroadcast); SetDeviceStateUpdateCallback(OnDeviceChange); if (Start()) { + printf("Start discovering device.\n"); + #ifdef WIN32 Sleep(20000); #else diff --git a/sample/lidar/main.c b/sample/lidar/main.c index 42a233e..436987c 100644 --- a/sample/lidar/main.c +++ b/sample/lidar/main.c @@ -47,19 +47,24 @@ typedef struct { DeviceItem devices[kMaxLidarCount]; uint32_t data_recveive_count[kMaxLidarCount]; -#define BROADCAST_CODE_LIST_SIZE 3 -char *broadcast_code_list[BROADCAST_CODE_LIST_SIZE] = { - "000000000000002", - "000000000000003", - "000000000000004" +char *broadcast_code_list[] = { + "000000000000002", + "000000000000003", + "000000000000004" }; +#define BROADCAST_CODE_LIST_SIZE (sizeof(broadcast_code_list) / sizeof(intptr_t)) + /** Receiving point cloud data from Livox LiDAR. */ void GetLidarData(uint8_t handle, LivoxEthPacket *data, uint32_t data_num) { if (data) { data_recveive_count[handle] += data_num; if (data_recveive_count[handle] % 10000 == 0) { printf("receive packet count %d %d\n", handle, data_recveive_count[handle]); + + /** Parsing the timestamp and the point cloud data. */ + uint64_t cur_timestamp = *((uint64_t *)(data->timestamp)); + LivoxRawPoint *p_point_data = (LivoxRawPoint *)data->data; } } } @@ -165,10 +170,16 @@ void OnDeviceBroadcast(const BroadcastDeviceInfo *info) { } int main(int argc, const char *argv[]) { + printf("Livox SDK initializing.\n"); /** Initialize Livox-SDK. */ if (!Init()) { return -1; } + printf("Livox SDK has been initialized.\n"); + + LivoxSdkVersion _sdkversion; + GetLivoxSdkVersion(&_sdkversion); + printf("Livox SDK version %d.%d.%d .\n", _sdkversion.major, _sdkversion.minor, _sdkversion.patch); memset(devices, 0, sizeof(devices)); memset(data_recveive_count, 0, sizeof(data_recveive_count)); @@ -186,6 +197,7 @@ int main(int argc, const char *argv[]) { Uninit(); return -1; } + printf("Start discovering device.\n"); #ifdef WIN32 Sleep(30000); diff --git a/sdk_core/include/livox_def.h b/sdk_core/include/livox_def.h index b621ac1..53bc9cb 100644 --- a/sdk_core/include/livox_def.h +++ b/sdk_core/include/livox_def.h @@ -89,8 +89,19 @@ typedef enum { #pragma pack(1) +#define LIVOX_SDK_MAJOR_VERSION 1 +#define LIVOX_SDK_MINOR_VERSION 0 +#define LIVOX_SDK_PATCH_VERSION 0 + #define kBroadcastCodeSize 16 +/** The numeric version information struct. */ +typedef struct { + int major; /**< major number */ + int minor; /**< minor number */ + int patch; /**< patch number */ +} LivoxSdkVersion; + /** Cartesian coordinate format. */ typedef struct { int32_t x; /**< X axis, Unit:mm */ @@ -99,7 +110,7 @@ typedef struct { uint8_t reflectivity; /**< Reflectivity */ } LivoxRawPoint; -/** standard point cloud format */ +/** Standard point cloud format */ typedef struct { float x; /**< X axis, Unit:m */ float y; /**< X axis, Unit:m */ diff --git a/sdk_core/include/livox_sdk.h b/sdk_core/include/livox_sdk.h index 1d38de4..0b8a38b 100644 --- a/sdk_core/include/livox_sdk.h +++ b/sdk_core/include/livox_sdk.h @@ -33,6 +33,12 @@ extern "C" { #include #include "livox_def.h" +/** +* Return SDK's version information in a numeric form. +* @param version Pointer to a version structure for returning the version information. +*/ +void GetLivoxSdkVersion(LivoxSdkVersion *version); + /** * Initialize the SDK. * @return true if successfully initialized, otherwise false. diff --git a/sdk_core/src/base/network_util.cpp b/sdk_core/src/base/network_util.cpp index 2c636da..6ffca23 100644 --- a/sdk_core/src/base/network_util.cpp +++ b/sdk_core/src/base/network_util.cpp @@ -78,7 +78,7 @@ bool FindLocalIP(const struct sockaddr_in &client_addr, uint32_t &local_ip) { IP_ADAPTER_INFO *pAdapter = reinterpret_cast(pAdapterInfo.get()); if (NO_ERROR == dlRetVal && pAdapter != NULL) { - while (pAdapterInfo) { + while (pAdapter) { std::string str_ip = pAdapter->IpAddressList.IpAddress.String; std::string str_mask = pAdapter->IpAddressList.IpMask.String; ULONG host_ip = inet_addr(const_cast(str_ip.c_str())); diff --git a/sdk_core/src/livox_sdk.cpp b/sdk_core/src/livox_sdk.cpp index d8653cf..10227c9 100644 --- a/sdk_core/src/livox_sdk.cpp +++ b/sdk_core/src/livox_sdk.cpp @@ -30,6 +30,14 @@ using namespace livox; IOThread *g_thread = NULL; +void GetLivoxSdkVersion(LivoxSdkVersion *version) { + if (version != NULL) { + version->major = LIVOX_SDK_MAJOR_VERSION; + version->minor = LIVOX_SDK_MINOR_VERSION; + version->patch = LIVOX_SDK_PATCH_VERSION; + } +} + bool Init() { bool result = false; do { @@ -59,7 +67,6 @@ bool Init() { result = false; break; } - result = true; } while (0);