Livox SDK API  V1.1.0
livox_sdk.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "livox_def.h"

Go to the source code of this file.

Typedefs

typedef void(* DeviceBroadcastCallback) (const BroadcastDeviceInfo *info)
 
typedef void(* DeviceStateUpdateCallback) (const DeviceInfo *device, DeviceEvent type)
 
typedef void(* DeviceInformationCallback) (uint8_t status, uint8_t handle, DeviceInformationResponse *response, void *client_data)
 
typedef void(* DataCallback) (uint8_t handle, LivoxEthPacket *data, uint32_t data_num)
 
typedef void(* CommonCommandCallback) (uint8_t status, uint8_t handle, uint8_t response, void *client_data)
 
typedef void(* ErrorMessageCallback) (uint8_t handle, ErrorMessage *message)
 
typedef void(* GetDeviceIPInformationCallback) (uint8_t status, uint8_t handle, GetDeviceIPModeResponse *response, void *client_data)
 
typedef void(* HubQueryLidarInformationCallback) (uint8_t status, uint8_t handle, HubQueryLidarInformationResponse *response, void *client_data)
 
typedef void(* HubSetModeCallback) (uint8_t status, uint8_t handle, HubSetModeResponse *response, void *client_data)
 
typedef void(* HubQueryLidarStatusCallback) (uint8_t status, uint8_t handle, HubQueryLidarStatusResponse *response, void *client_data)
 
typedef void(* HubSetExtrinsicParameterCallback) (uint8_t status, uint8_t handle, HubSetExtrinsicParameterResponse *response, void *client_data)
 
typedef void(* HubGetExtrinsicParameterCallback) (uint8_t status, uint8_t handle, HubGetExtrinsicParameterResponse *response, void *client_data)
 
typedef void(* HubRainFogSuppressCallback) (uint8_t status, uint8_t handle, HubRainFogSuppressResponse *response, void *client_data)
 
typedef void(* LidarGetExtrinsicParameterCallback) (uint8_t status, uint8_t handle, LidarGetExtrinsicParameterResponse *response, void *client_data)
 

Functions

void GetLivoxSdkVersion (LivoxSdkVersion *version)
 
bool Init ()
 
bool Start ()
 
void Uninit ()
 
void SaveLoggerFile ()
 
void SetBroadcastCallback (DeviceBroadcastCallback cb)
 
void SetDeviceStateUpdateCallback (DeviceStateUpdateCallback cb)
 Add a callback for device connection or working state changing event. More...
 
uint8_t AddHubToConnect (const char *broadcast_code, uint8_t *handle)
 
uint8_t AddLidarToConnect (const char *broadcast_code, uint8_t *handle)
 
uint8_t GetConnectedDevices (DeviceInfo *devices, uint8_t *size)
 
uint8_t QueryDeviceInformation (uint8_t handle, DeviceInformationCallback cb, void *client_data)
 
void SetDataCallback (uint8_t handle, DataCallback cb)
 
uint8_t HubStartSampling (CommonCommandCallback cb, void *client_data)
 
uint8_t HubStopSampling (CommonCommandCallback cb, void *client_data)
 
uint8_t HubGetLidarHandle (uint8_t slot, uint8_t id)
 
uint8_t SetCartesianCoordinate (uint8_t handle, CommonCommandCallback cb, void *client_data)
 
uint8_t SetSphericalCoordinate (uint8_t handle, CommonCommandCallback cb, void *client_data)
 
uint8_t SetErrorMessageCallback (uint8_t handle, ErrorMessageCallback cb)
 
uint8_t SetStaticDynamicIP (uint8_t handle, SetDeviceIPModeRequest *req, CommonCommandCallback cb, void *client_data)
 
uint8_t GetDeviceIPInformation (uint8_t handle, GetDeviceIPInformationCallback cb, void *client_data)
 
uint8_t HubQueryLidarInformation (HubQueryLidarInformationCallback cb, void *client_data)
 
uint8_t HubSetMode (HubSetModeRequest *req, uint16_t length, HubSetModeCallback cb, void *client_data)
 
uint8_t HubQueryLidarStatus (HubQueryLidarStatusCallback cb, void *client_data)
 
uint8_t HubControlSlotPower (HubControlSlotPowerRequest *req, CommonCommandCallback cb, void *client_data)
 
uint8_t HubSetExtrinsicParameter (HubSetExtrinsicParameterRequest *req, uint16_t length, HubSetExtrinsicParameterCallback cb, void *client_data)
 
uint8_t HubGetExtrinsicParameter (HubGetExtrinsicParameterRequest *req, uint16_t length, HubGetExtrinsicParameterCallback cb, void *client_data)
 
uint8_t HubExtrinsicParameterCalculation (bool enable, CommonCommandCallback cb, void *client_data)
 
uint8_t HubRainFogSuppress (HubRainFogSuppressRequest *req, uint16_t length, HubRainFogSuppressCallback cb, void *client_data)
 
uint8_t LidarStartSampling (uint8_t handle, CommonCommandCallback cb, void *client_data)
 
uint8_t LidarStopSampling (uint8_t handle, CommonCommandCallback cb, void *client_data)
 
uint8_t LidarSetMode (uint8_t handle, LidarMode mode, CommonCommandCallback cb, void *client_data)
 
uint8_t LidarSetExtrinsicParameter (uint8_t handle, LidarSetExtrinsicParameterRequest *req, CommonCommandCallback cb, void *client_data)
 
uint8_t LidarGetExtrinsicParameter (uint8_t handle, LidarGetExtrinsicParameterCallback cb, void *client_data)
 
uint8_t LidarRainFogSuppress (uint8_t handle, bool enable, CommonCommandCallback cb, void *client_data)
 

Typedef Documentation

◆ CommonCommandCallback

typedef void(* CommonCommandCallback) (uint8_t status, uint8_t handle, uint8_t response, void *client_data)

Function type of callback with 1 byte of response.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 170 of file livox_sdk.h.

◆ DataCallback

typedef void(* DataCallback) (uint8_t handle, LivoxEthPacket *data, uint32_t data_num)

Callback function for receiving point cloud data.

Parameters
handledevice handle.
datadevice's data.
data_numnumber of points in data.

Definition at line 153 of file livox_sdk.h.

◆ DeviceBroadcastCallback

typedef void(* DeviceBroadcastCallback) (const BroadcastDeviceInfo *info)

SetBroadcastCallback response callback function.

Parameters
infoinformation of the broadcast device, becomes invalid after the function returns.

Definition at line 68 of file livox_sdk.h.

◆ DeviceInformationCallback

typedef void(* DeviceInformationCallback) (uint8_t status, uint8_t handle, DeviceInformationResponse *response, void *client_data)

Function type of callback that queries device's information.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 133 of file livox_sdk.h.

◆ DeviceStateUpdateCallback

typedef void(* DeviceStateUpdateCallback) (const DeviceInfo *device, DeviceEvent type)

SetDeviceStateUpdateCallback response callback function.

Parameters
deviceinformation of the connected device.
typethe update type that indicates connection/disconnection of the device or change of working state.

Definition at line 82 of file livox_sdk.h.

◆ ErrorMessageCallback

typedef void(* ErrorMessageCallback) (uint8_t handle, ErrorMessage *message)

Callback of the error status message.

Parameters
handledevice handle.
responseresponse from the device.

Definition at line 219 of file livox_sdk.h.

◆ GetDeviceIPInformationCallback

typedef void(* GetDeviceIPInformationCallback) (uint8_t status, uint8_t handle, GetDeviceIPModeResponse *response, void *client_data)

Callback function that gets device's IP information.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 250 of file livox_sdk.h.

◆ HubGetExtrinsicParameterCallback

typedef void(* HubGetExtrinsicParameterCallback) (uint8_t status, uint8_t handle, HubGetExtrinsicParameterResponse *response, void *client_data)

HubGetExtrinsicParameter response callback function.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 367 of file livox_sdk.h.

◆ HubQueryLidarInformationCallback

typedef void(* HubQueryLidarInformationCallback) (uint8_t status, uint8_t handle, HubQueryLidarInformationResponse *response, void *client_data)

HubQueryLidarInformation response callback function.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 272 of file livox_sdk.h.

◆ HubQueryLidarStatusCallback

typedef void(* HubQueryLidarStatusCallback) (uint8_t status, uint8_t handle, HubQueryLidarStatusResponse *response, void *client_data)

HubQueryLidarStatus response callback function.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 313 of file livox_sdk.h.

◆ HubRainFogSuppressCallback

typedef void(* HubRainFogSuppressCallback) (uint8_t status, uint8_t handle, HubRainFogSuppressResponse *response, void *client_data)

HubRainFogSuppress response callback function.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 403 of file livox_sdk.h.

◆ HubSetExtrinsicParameterCallback

typedef void(* HubSetExtrinsicParameterCallback) (uint8_t status, uint8_t handle, HubSetExtrinsicParameterResponse *response, void *client_data)

HubSetExtrinsicParameter response callback function.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 341 of file livox_sdk.h.

◆ HubSetModeCallback

typedef void(* HubSetModeCallback) (uint8_t status, uint8_t handle, HubSetModeResponse *response, void *client_data)

HubSetMode response callback function.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 293 of file livox_sdk.h.

◆ LidarGetExtrinsicParameterCallback

typedef void(* LidarGetExtrinsicParameterCallback) (uint8_t status, uint8_t handle, LidarGetExtrinsicParameterResponse *response, void *client_data)

LidarGetExtrinsicParameter response callback function.

Parameters
statuskStatusSuccess on successful return, kStatusTimeout on timeout, see ResponseStatus for other error code.
handledevice handle.
responseresponse from the device.
client_datauser data associated with the command.

Definition at line 472 of file livox_sdk.h.

Function Documentation

◆ AddHubToConnect()

uint8_t AddHubToConnect ( const char *  broadcast_code,
uint8_t *  handle 
)

Add a broadcast code to the connecting list and only devices with broadcast code in this list will be connected. The broadcast code is unique for every device.

Parameters
broadcast_codedevice's broadcast code.
handledevice handle. For Livox Hub, the handle is always 31; for LiDAR units connected to the Livox Hub, the corresponding handle is (slot-1)*3+id-1.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ AddLidarToConnect()

uint8_t AddLidarToConnect ( const char *  broadcast_code,
uint8_t *  handle 
)

Add a broadcast code to the connecting list and only devices with broadcast code in this list will be connected. The broadcast code is unique for every device.

Parameters
broadcast_codedevice's broadcast code.
handledevice handle. The handle is the same as the order calling AddLidarToConnect starting from 0.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ GetConnectedDevices()

uint8_t GetConnectedDevices ( DeviceInfo devices,
uint8_t *  size 
)

Get all connected devices' information.

Parameters
deviceslist of connected devices' information.
sizenumber of devices connected.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ GetDeviceIPInformation()

uint8_t GetDeviceIPInformation ( uint8_t  handle,
GetDeviceIPInformationCallback  cb,
void *  client_data 
)

Get device's IP mode.

Parameters
handledevice handle.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ GetLivoxSdkVersion()

void GetLivoxSdkVersion ( LivoxSdkVersion version)

Return SDK's version information in a numeric form.

Parameters
versionPointer to a version structure for returning the version information.

◆ HubControlSlotPower()

uint8_t HubControlSlotPower ( HubControlSlotPowerRequest req,
CommonCommandCallback  cb,
void *  client_data 
)

Toggle the power supply of designated slots.

Parameters
reqrequest whether to enable or disable the power of designated slots.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ HubExtrinsicParameterCalculation()

uint8_t HubExtrinsicParameterCalculation ( bool  enable,
CommonCommandCallback  cb,
void *  client_data 
)

Turn on or off the calculation of extrinsic parameters.

Parameters
enablethe request whether enable or disable calculating the extrinsic parameters.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ HubGetExtrinsicParameter()

uint8_t HubGetExtrinsicParameter ( HubGetExtrinsicParameterRequest req,
uint16_t  length,
HubGetExtrinsicParameterCallback  cb,
void *  client_data 
)

Get extrinsic parameters of LiDAR units connected to the Livox Hub.

Parameters
reqthe LiDAR units broadcast code list.
lengththe request's length.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ HubGetLidarHandle()

uint8_t HubGetLidarHandle ( uint8_t  slot,
uint8_t  id 
)

Get the LiDAR unit handle used in the Livox Hub data callback function from slot and id.

Parameters
slotLivox Hub's slot.
idLivox Hub's id.
Returns
LiDAR unit handle.

◆ HubQueryLidarInformation()

uint8_t HubQueryLidarInformation ( HubQueryLidarInformationCallback  cb,
void *  client_data 
)

Query the information of LiDARs connected to the hub.

Parameters
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ HubQueryLidarStatus()

uint8_t HubQueryLidarStatus ( HubQueryLidarStatusCallback  cb,
void *  client_data 
)

Get the state of LiDAR units connected to the Livox Hub.

Parameters
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ HubRainFogSuppress()

uint8_t HubRainFogSuppress ( HubRainFogSuppressRequest req,
uint16_t  length,
HubRainFogSuppressCallback  cb,
void *  client_data 
)

Toggling the rain and fog mode for lidars connected to the hub.

Parameters
reqthe request whether open or close the rain and fog mode.
lengththe request's length.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ HubSetExtrinsicParameter()

uint8_t HubSetExtrinsicParameter ( HubSetExtrinsicParameterRequest req,
uint16_t  length,
HubSetExtrinsicParameterCallback  cb,
void *  client_data 
)

Set extrinsic parameters of LiDAR units connected to the Livox Hub.

Parameters
reqthe parameters to write.
lengththe request's length.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ HubSetMode()

uint8_t HubSetMode ( HubSetModeRequest req,
uint16_t  length,
HubSetModeCallback  cb,
void *  client_data 
)

Set the mode of LiDAR unit connected to the Livox Hub.

Parameters
reqmode configuration of LiDAR units.
lengthlength of req.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ HubStartSampling()

uint8_t HubStartSampling ( CommonCommandCallback  cb,
void *  client_data 
)

Start hub sampling.

Parameters
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ HubStopSampling()

uint8_t HubStopSampling ( CommonCommandCallback  cb,
void *  client_data 
)

Stop the Livox Hub's sampling.

Parameters
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ Init()

bool Init ( )

Initialize the SDK.

Returns
true if successfully initialized, otherwise false.

◆ LidarGetExtrinsicParameter()

uint8_t LidarGetExtrinsicParameter ( uint8_t  handle,
LidarGetExtrinsicParameterCallback  cb,
void *  client_data 
)

Get LiDAR extrinsic parameters.

Parameters
handledevice handle.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ LidarRainFogSuppress()

uint8_t LidarRainFogSuppress ( uint8_t  handle,
bool  enable,
CommonCommandCallback  cb,
void *  client_data 
)

Enable and disable the rain/fog suppression.

Parameters
handledevice handle.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ LidarSetExtrinsicParameter()

uint8_t LidarSetExtrinsicParameter ( uint8_t  handle,
LidarSetExtrinsicParameterRequest req,
CommonCommandCallback  cb,
void *  client_data 
)

Set LiDAR extrinsic parameters.

Parameters
handledevice handle.
paramthe parameters to write.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ LidarSetMode()

uint8_t LidarSetMode ( uint8_t  handle,
LidarMode  mode,
CommonCommandCallback  cb,
void *  client_data 
)

Set LiDAR mode.

Note
Successful callback function status only means LiDAR successfully starting the changing process of mode. You need to observe the actually change of mode in DeviceStateUpdateCallback function.
Parameters
handledevice handle.
modethe mode to change.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ LidarStartSampling()

uint8_t LidarStartSampling ( uint8_t  handle,
CommonCommandCallback  cb,
void *  client_data 
)

Start LiDAR sampling.

Parameters
handledevice handle.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ LidarStopSampling()

uint8_t LidarStopSampling ( uint8_t  handle,
CommonCommandCallback  cb,
void *  client_data 
)

Stop LiDAR sampling.

Parameters
handledevice handle.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ QueryDeviceInformation()

uint8_t QueryDeviceInformation ( uint8_t  handle,
DeviceInformationCallback  cb,
void *  client_data 
)

Command to query device's information.

Parameters
handledevice handle.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ SaveLoggerFile()

void SaveLoggerFile ( )

Save the log file.

◆ SetBroadcastCallback()

void SetBroadcastCallback ( DeviceBroadcastCallback  cb)

Set the callback of listening device broadcast message. When broadcast message is received from Livox Hub/LiDAR, cb is called.

Parameters
cbcallback for device broadcast.

◆ SetCartesianCoordinate()

uint8_t SetCartesianCoordinate ( uint8_t  handle,
CommonCommandCallback  cb,
void *  client_data 
)

Command to change point cloud coordinate system to cartesian coordinate.

Parameters
handledevice handle.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ SetDataCallback()

void SetDataCallback ( uint8_t  handle,
DataCallback  cb 
)

Set the callback to receive point cloud data. Only one callback is supported for a specific device. Set the point cloud data callback before beginning sampling.

Parameters
cbcallback to receive point cloud data.

◆ SetDeviceStateUpdateCallback()

void SetDeviceStateUpdateCallback ( DeviceStateUpdateCallback  cb)

Add a callback for device connection or working state changing event.

Note
Livox SDK supports two hardware connection modes. 1: Directly connecting to the LiDAR device; 2. Connecting to the LiDAR device(s) via the Livox Hub. In the first mode, connection/disconnection of every LiDAR unit is reported by this callback. In the second mode, only connection/disconnection of the Livox Hub is reported by this callback. If you want to get information of the LiDAR unit(s) connected to hub, see HubQueryLidarInformation.
3 conditions can trigger this callback:
  1. Connection and disconnection of device.
  2. A change of device working state.
  3. An error occurs.
Parameters
cbcallback for device connection/disconnection.

◆ SetErrorMessageCallback()

uint8_t SetErrorMessageCallback ( uint8_t  handle,
ErrorMessageCallback  cb 
)

Add error status callback for the device.

Parameters
handledevice handle.
cbcallback for the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ SetSphericalCoordinate()

uint8_t SetSphericalCoordinate ( uint8_t  handle,
CommonCommandCallback  cb,
void *  client_data 
)

Change point cloud coordinate system to spherical coordinate.

Parameters
handledevice handle.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ SetStaticDynamicIP()

uint8_t SetStaticDynamicIP ( uint8_t  handle,
SetDeviceIPModeRequest req,
CommonCommandCallback  cb,
void *  client_data 
)

Set device's IP mode.

Parameters
handledevice handle.
reqrequest sent to device.
cbcallback for the command.
client_datauser data associated with the command.
Returns
kStatusSuccess on successful return, see ResponseStatus for other error code.

◆ Start()

bool Start ( )

Start the device scanning routine which runs on a separate thread.

Returns
true if successfully started, otherwise false.

◆ Uninit()

void Uninit ( )

Uninitialize the SDK.