feat:support Tele
This commit is contained in:
@@ -109,4 +109,3 @@ install(TARGETS ${SDK_LIBRARY}
|
||||
PUBLIC_HEADER DESTINATION include
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib)
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ typedef enum {
|
||||
|
||||
#define LIVOX_SDK_MAJOR_VERSION 2
|
||||
#define LIVOX_SDK_MINOR_VERSION 1
|
||||
#define LIVOX_SDK_PATCH_VERSION 0
|
||||
#define LIVOX_SDK_PATCH_VERSION 1
|
||||
|
||||
#define kBroadcastCodeSize 16
|
||||
|
||||
@@ -473,6 +473,62 @@ typedef struct {
|
||||
StatusUnion error_union; /**< LiDAR work state. */
|
||||
} HeartbeatResponse;
|
||||
|
||||
/**
|
||||
* The error code of Getting/Setting Device's Parameters.
|
||||
*/
|
||||
typedef enum {
|
||||
kKeyNoError = 0, /**< No Error. */
|
||||
kKeyNotSupported = 1, /**< The key is not supported. */
|
||||
kKeyExecFailed = 2, /**< Execution failed. */
|
||||
kKeyNotSupportedWritingState = 3, /**< The key cannot be written. */
|
||||
kKeyValueError = 4, /**< Wrong value. */
|
||||
kKeyValueLengthError = 5, /**< Wrong value length. */
|
||||
kKeyNoEnoughMemory = 6, /**< Reading parameter length limit. */
|
||||
kKeyLengthError = 7, /**< The number of parameters does not match. */
|
||||
} KeyErrorCode;
|
||||
|
||||
/**
|
||||
* The response body of setting device's parameter.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t ret_code; /**< Return code. */
|
||||
uint16_t error_param_key; /**< Error Key. */
|
||||
uint8_t error_code; /**< Error code, refer to \ref KeyErrorCode. */
|
||||
} DeviceParameterResponse;
|
||||
|
||||
/**
|
||||
* Keys of device's parameters.
|
||||
*/
|
||||
typedef enum {
|
||||
kKeyDefault = 0, /**< Default key name. */
|
||||
kKeyHighSensetivity = 1, /**< Key to get/set LiDAR' Sensetivity. */
|
||||
} DeviceParamKeyName;
|
||||
|
||||
/**
|
||||
* Key and value of device's parameters.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t key; /*< Key, refer to \ref DeviceParamKeyName. */
|
||||
uint16_t length; /*< Length of value */
|
||||
uint8_t value[1]; /*< Value */
|
||||
} KeyValueParam;
|
||||
|
||||
/**
|
||||
* The response body of getting device's parameter.
|
||||
*/
|
||||
typedef struct {
|
||||
DeviceParameterResponse rsp; /*< Return code. */
|
||||
KeyValueParam kv; /*< Key and value of device's parameters. */
|
||||
} GetDeviceParameterResponse;
|
||||
|
||||
/**
|
||||
* The request body for the command of getting device's parameters.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t param_num; /*< Number of key. */
|
||||
uint16_t key[1]; /*< Key, refer to \ref DeviceParamKeyName. */
|
||||
} GetDeviceParameterRequest;
|
||||
|
||||
/**
|
||||
* The request body for the command of setting Livox LiDAR's parameters.
|
||||
*/
|
||||
|
||||
@@ -317,6 +317,59 @@ livox_status GetDeviceIpInformation(uint8_t handle, GetDeviceIpInformationCallba
|
||||
*/
|
||||
livox_status RebootDevice(uint8_t handle, uint16_t timeout, CommonCommandCallback cb, void * client_data);
|
||||
|
||||
/**
|
||||
* @c SetDeviceParameters' response callback function.
|
||||
* @param status kStatusSuccess on successful return, kStatusTimeout on timeout, see \ref LivoxStatus for other
|
||||
* error code.
|
||||
* @param handle device handle.
|
||||
* @param response response from the device.
|
||||
* @param client_data user data associated with the command.
|
||||
*/
|
||||
typedef void (*SetDeviceParametersCallback)(livox_status status,
|
||||
uint8_t handle,
|
||||
DeviceParameterResponse *response,
|
||||
void *client_data);
|
||||
|
||||
/**
|
||||
* LiDAR Enable HighSensitivity.
|
||||
* @param handle device handle.
|
||||
* @param cb callback for the command.
|
||||
* @param client_data user data associated with the command.
|
||||
* @return kStatusSuccess on successful return, see \ref LivoxStatus for other error code.
|
||||
*/
|
||||
livox_status LidarEnableHighSensitivity(uint8_t handle, SetDeviceParametersCallback cb, void *client_data);
|
||||
|
||||
/**
|
||||
* LiDAR Disable HighSensitivity.
|
||||
* @param handle device handle.
|
||||
* @param cb callback for the command.
|
||||
* @param client_data user data associated with the command.
|
||||
* @return kStatusSuccess on successful return, see \ref LivoxStatus for other error code.
|
||||
*/
|
||||
livox_status LidarDisableHighSensitivity(uint8_t handle, SetDeviceParametersCallback cb, void *client_data);
|
||||
|
||||
/**
|
||||
* @c GetDeviceParameters' response callback function.
|
||||
* @param status kStatusSuccess on successful return, kStatusTimeout on timeout, see \ref LivoxStatus for other
|
||||
* error code.
|
||||
* @param handle device handle.
|
||||
* @param response response from the device.
|
||||
* @param client_data user data associated with the command.
|
||||
*/
|
||||
typedef void (*GetDeviceParametersCallback)(livox_status status,
|
||||
uint8_t handle,
|
||||
GetDeviceParameterResponse *response,
|
||||
void *client_data);
|
||||
|
||||
/**
|
||||
* LiDAR Get HighSensitivity State.
|
||||
* @param handle device handle.
|
||||
* @param cb callback for the command.
|
||||
* @param client_data user data associated with the command.
|
||||
* @return kStatusSuccess on successful return, see \ref LivoxStatus for other error code.
|
||||
*/
|
||||
livox_status LidarGetHighSensitivityState(uint8_t handle, GetDeviceParametersCallback cb, void *client_data);
|
||||
|
||||
/**
|
||||
* @c HubQueryLidarInformation response callback function.
|
||||
* @param status kStatusSuccess on successful return, kStatusTimeout on timeout, see \ref LivoxStatus for other
|
||||
|
||||
@@ -226,6 +226,27 @@ bool ParseRmcTime(const char* rmc, uint16_t rmc_len, LidarSetUtcSyncTimeRequest*
|
||||
return true;
|
||||
}
|
||||
|
||||
livox_status SetDeviceParameters(uint8_t handle, uint8_t *req, uint16_t length, SetDeviceParametersCallback cb, void *client_data) {
|
||||
|
||||
livox_status result = command_handler().SendCommand(handle,
|
||||
kCommandSetGeneral,
|
||||
kCommandIDGeneralSetDeviceParam,
|
||||
req,
|
||||
length,
|
||||
MakeCommandCallback<DeviceParameterResponse>(cb, client_data));
|
||||
return result;
|
||||
}
|
||||
|
||||
livox_status GetDeiveParameter(uint8_t handle, GetDeviceParameterRequest *req, GetDeviceParametersCallback cb, void *client_data) {
|
||||
livox_status result = command_handler().SendCommand(handle,
|
||||
kCommandSetGeneral,
|
||||
kCommandIDGeneralGetDeviceParam,
|
||||
(uint8_t *)req,
|
||||
sizeof(GetDeviceParameterRequest),
|
||||
MakeCommandCallback<GetDeviceParameterResponse>(cb, client_data));
|
||||
return result;
|
||||
}
|
||||
|
||||
livox_status LidarStartSampling(uint8_t handle, CommonCommandCallback cb, void *client_data) {
|
||||
if (device_manager().device_mode() != kDeviceModeLidar) {
|
||||
return kStatusNotSupported;
|
||||
@@ -369,6 +390,48 @@ livox_status RebootDevice(uint8_t handle, uint16_t timeout, CommonCommandCallbac
|
||||
return result;
|
||||
}
|
||||
|
||||
livox_status LidarEnableHighSensitivity(uint8_t handle, SetDeviceParametersCallback cb, void *client_data) {
|
||||
if (!device_manager().IsLidarTele(handle)) {
|
||||
return kStatusNotSupported;
|
||||
}
|
||||
|
||||
uint8_t req_buff[kMaxCommandBufferSize] = {0};
|
||||
uint16_t req_len = 0;
|
||||
KeyValueParam * kv = (KeyValueParam *)&req_buff[0];
|
||||
kv->key = static_cast<uint16_t>(kKeyHighSensetivity);
|
||||
kv->length = 1;
|
||||
kv->value[0] = static_cast<uint8_t>(true);
|
||||
req_len = sizeof(KeyValueParam);
|
||||
|
||||
return SetDeviceParameters(handle, req_buff, req_len, cb, client_data);
|
||||
}
|
||||
|
||||
livox_status LidarDisableHighSensitivity(uint8_t handle, SetDeviceParametersCallback cb, void *client_data) {
|
||||
if (!device_manager().IsLidarTele(handle)) {
|
||||
return kStatusNotSupported;
|
||||
}
|
||||
uint8_t req_buff[kMaxCommandBufferSize] = {0};
|
||||
uint16_t req_len = 0;
|
||||
KeyValueParam * kv = (KeyValueParam *)&req_buff[0];
|
||||
kv->key = static_cast<uint16_t>(kKeyHighSensetivity);
|
||||
kv->length = 1;
|
||||
kv->value[0] = static_cast<uint8_t>(false);
|
||||
req_len = sizeof(KeyValueParam);
|
||||
|
||||
return SetDeviceParameters(handle, req_buff, req_len, cb, client_data);
|
||||
}
|
||||
|
||||
livox_status LidarGetHighSensitivityState(uint8_t handle, GetDeviceParametersCallback cb, void *client_data) {
|
||||
if (!device_manager().IsLidarTele(handle)) {
|
||||
return kStatusNotSupported;
|
||||
}
|
||||
|
||||
GetDeviceParameterRequest req;
|
||||
req.param_num = 1;
|
||||
req.key[0] = static_cast<uint16_t>(kKeyHighSensetivity);
|
||||
return GetDeiveParameter(handle, &req, cb, client_data);
|
||||
}
|
||||
|
||||
livox_status LidarSetMode(uint8_t handle, LidarMode mode, CommonCommandCallback cb, void *client_data) {
|
||||
if (device_manager().device_mode() != kDeviceModeLidar) {
|
||||
return kStatusNotSupported;
|
||||
|
||||
@@ -84,7 +84,18 @@ typedef enum {
|
||||
* General command set, reboot a device.
|
||||
*/
|
||||
kCommandIDGeneralRebootDevice = 0x0a,
|
||||
|
||||
/**
|
||||
* Set device's parameters.
|
||||
*/
|
||||
kCommandIDGeneralSetDeviceParam = 0x0b,
|
||||
/**
|
||||
* Get device's parameters.
|
||||
*/
|
||||
kCommandIDGeneralGetDeviceParam = 0x0c,
|
||||
/**
|
||||
* Reset device's all parameters.
|
||||
*/
|
||||
kCommandIDGeneralResetDeviceParam = 0x0d,
|
||||
/**
|
||||
* ******************************************************
|
||||
* Don't add command id after kCommandIDGeneralCommandCount.
|
||||
@@ -102,7 +113,9 @@ static const uint16_t GeneralCommandTimeout[kCommandIDGeneralCommandCount] = {KD
|
||||
KDefaultTimeOut,
|
||||
KDefaultTimeOut,
|
||||
KDefaultTimeOut,
|
||||
KDefaultTimeOut};
|
||||
KDefaultTimeOut,
|
||||
KDefaultTimeOut,
|
||||
KDefaultTimeOut,};
|
||||
|
||||
/** Enum that represents the command id. */
|
||||
typedef enum {
|
||||
@@ -167,7 +180,7 @@ static const uint16_t LidarCommandTimeout[kCommandIDLidarCommandCount] = {KDefau
|
||||
KDefaultTimeOut,
|
||||
KDefaultTimeOut,
|
||||
KDefaultTimeOut,
|
||||
KDefaultTimeOut};
|
||||
KDefaultTimeOut,};
|
||||
|
||||
/** Enum that represents the command id. */
|
||||
typedef enum {
|
||||
|
||||
@@ -301,6 +301,15 @@ bool DeviceManager::IsLidarMid40(uint8_t handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DeviceManager::IsLidarTele(uint8_t handle) {
|
||||
DeviceInfo lidar_info;
|
||||
bool found = device_manager().FindDevice(handle, lidar_info);
|
||||
if ( found && lidar_info.type == kDeviceTypeLidarTele) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DeviceManager::GetLidarFirmwareVersion(uint8_t handle, uint32_t &firmware_version) {
|
||||
if (handle > devices_.size()) {
|
||||
return false;
|
||||
|
||||
@@ -103,6 +103,7 @@ class DeviceManager : public noncopyable {
|
||||
void GetConnectedDevices(std::vector<DeviceInfo> &devices);
|
||||
bool AddListeningDevice(const std::string &broadcast_code, DeviceMode mode, uint8_t &handle);
|
||||
bool IsLidarMid40(uint8_t handle);
|
||||
bool IsLidarTele(uint8_t handle);
|
||||
bool GetLidarFirmwareVersion(uint8_t handle, uint32_t &firmware_version);
|
||||
|
||||
private:
|
||||
@@ -159,4 +160,4 @@ void DeviceRemove(uint8_t handle,DeviceEvent device_event);
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // LIVOX_DEVICE_MANAGER_H_
|
||||
#endif // LIVOX_DEVICE_MANAGER_H_
|
||||
Reference in New Issue
Block a user