feature:support save lvx file for lidar;

This commit is contained in:
Livox-SDK
2019-05-06 12:33:55 +08:00
parent 25c945da3b
commit 2765743dea
907 changed files with 10205 additions and 5141 deletions
+18 -2
View File
@@ -90,7 +90,7 @@ typedef enum {
#pragma pack(1)
#define LIVOX_SDK_MAJOR_VERSION 1
#define LIVOX_SDK_MINOR_VERSION 1
#define LIVOX_SDK_MINOR_VERSION 2
#define LIVOX_SDK_PATCH_VERSION 0
#define kBroadcastCodeSize 16
@@ -110,6 +110,14 @@ typedef struct {
uint8_t reflectivity; /**< Reflectivity */
} LivoxRawPoint;
/** Spherical coordinate format. */
typedef struct {
uint32_t depth; /**< Radial distance, Unit:mm */
uint16_t theta; /**< Polar angle, Unit:0.01rad */
uint16_t phi; /**< Azimuthal angle, Unit:0.01rad */
uint8_t reflectivity; /**< Reflectivity */
} LivoxSpherPoint;
/** Standard point cloud format */
typedef struct {
float x; /**< X axis, Unit:m */
@@ -144,7 +152,7 @@ typedef struct {
uint8_t handle; /**< Device handle. */
uint8_t slot; /**< Slot number used for connecting LiDAR. */
uint8_t id; /**< LiDAR id. */
uint32_t type; /**< Device type, refer to \ref DeviceType. */
uint8_t type; /**< Device type, refer to \ref DeviceType. */
uint16_t data_port; /**< Point cloud data UDP port. */
uint16_t cmd_port; /**< Control command UDP port. */
char ip[16]; /**< IP address. */
@@ -389,6 +397,14 @@ typedef struct {
ReturnCode ret_state_list[1]; /**< Return code */
} HubRainFogSuppressResponse;
/**
* The response body of getting hub slots' power state.
*/
typedef struct {
uint8_t ret_code; /**< Return code. */
uint16_t slot_power_state; /**< Slot power status. */
} HubQuerySlotPowerStatusResponse;
#pragma pack()
#endif // LIVOX_DEF_H_
+27 -11
View File
@@ -146,18 +146,21 @@ uint8_t QueryDeviceInformation(uint8_t handle, DeviceInformationCallback cb, voi
/**
* Callback function for receiving point cloud data.
* @param handle device handle.
* @param data device's data.
* @param data_num number of points in data.
* @param handle device handle.
* @param data device's data.
* @param data_num number of points in data.
* @param client_data user data associated with the command.
*/
typedef void (*DataCallback)(uint8_t handle, LivoxEthPacket *data, uint32_t data_num);
typedef void (*DataCallback)(uint8_t handle, LivoxEthPacket *data, uint32_t data_num, void *client_data);
/**
* 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.
* @param handle device handle.
* @param cb callback to receive point cloud data.
* @param client_data user data associated with the command.
*/
void SetDataCallback(uint8_t handle, DataCallback cb);
void SetDataCallback(uint8_t handle, DataCallback cb, void *client_data);
/**
* Function type of callback with 1 byte of response.
@@ -371,16 +374,11 @@ typedef void (*HubGetExtrinsicParameterCallback)(uint8_t status,
/**
* Get extrinsic parameters of LiDAR units connected to the Livox Hub.
* @param req the LiDAR units broadcast code list.
* @param length the request's length.
* @param cb callback for the command.
* @param client_data user data associated with the command.
* @return kStatusSuccess on successful return, see \ref ResponseStatus for other error code.
*/
uint8_t HubGetExtrinsicParameter(HubGetExtrinsicParameterRequest *req,
uint16_t length,
HubGetExtrinsicParameterCallback cb,
void *client_data);
uint8_t HubGetExtrinsicParameter(HubGetExtrinsicParameterCallback cb, void *client_data);
/**
* Turn on or off the calculation of extrinsic parameters.
@@ -418,6 +416,24 @@ uint8_t HubRainFogSuppress(HubRainFogSuppressRequest *req,
HubRainFogSuppressCallback cb,
void *client_data);
/**
* @c HubQuerySlotPowerStatus response callback function.
* @param status kStatusSuccess on successful return, kStatusTimeout on timeout, see \ref ResponseStatus 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(*HubQuerySlotPowerStatusCallback)(uint8_t status, uint8_t handle, HubQuerySlotPowerStatusResponse *response, void *client_data);
/**
* Get the power supply state of each hub slot.
* @param cb callback for the command.
* @param client_data user data associated with the command.
* @return kStatusSuccess on successful return, see \ref ResponseStatus for other error code.
*/
uint8_t HubQuerySlotPowerStatus(HubQuerySlotPowerStatusCallback cb, void *client_data);
/**
* Start LiDAR sampling.
* @param handle device handle.
+18 -8
View File
@@ -75,8 +75,8 @@ uint8_t GetConnectedDevices(DeviceInfo *devices, uint8_t *size) {
return kStatusSuccess;
}
void SetDataCallback(uint8_t handle, DataCallback cb) {
data_handler().AddDataListener(handle, cb);
void SetDataCallback(uint8_t handle, DataCallback cb, void *client_data) {
data_handler().AddDataListener(handle, cb, client_data);
}
uint8_t DeviceSampleControl(uint8_t handle, bool enable, CommonCommandCallback cb, void *data) {
@@ -292,18 +292,15 @@ uint8_t HubSetExtrinsicParameter(HubSetExtrinsicParameterRequest *req,
return result ? kStatusSuccess : kStatusFailure;
}
uint8_t HubGetExtrinsicParameter(HubGetExtrinsicParameterRequest *req,
uint16_t length,
HubGetExtrinsicParameterCallback cb,
void *client_data) {
uint8_t HubGetExtrinsicParameter(HubGetExtrinsicParameterCallback cb, void *client_data) {
if (device_manager().device_mode() != kDeviceModeHub) {
return kStatusNotSupported;
}
bool result = command_handler().SendCommand(kHubDefaultHandle,
kCommandSetHub,
kCommandIDHubGetExtrinsicParameter,
(uint8_t *)req,
length,
NULL,
0,
MakeCommandCallback<HubGetExtrinsicParameterResponse>(cb, client_data));
return result ? kStatusSuccess : kStatusFailure;
}
@@ -350,3 +347,16 @@ uint8_t HubRainFogSuppress(HubRainFogSuppressRequest *req,
MakeCommandCallback<HubRainFogSuppressResponse>(cb, client_data));
return result ? kStatusSuccess : kStatusFailure;
}
uint8_t HubQuerySlotPowerStatus(HubQuerySlotPowerStatusCallback cb, void *client_data) {
if (device_manager().device_mode() != kDeviceModeHub) {
return kStatusNotSupported;
}
bool result = command_handler().SendCommand(kHubDefaultHandle,
kCommandSetHub,
kCommandIDHubQuerySlotPowerStatus,
NULL,
0,
MakeCommandCallback<HubQuerySlotPowerStatusResponse>(cb, client_data));
return result ? kStatusSuccess : kStatusFailure;
}
@@ -164,6 +164,10 @@ typedef enum {
* Hub command set, open or close the rain and fog mode of the connected Livox LiDAR.
*/
kCommandIDHubRainFogSuppression = 7,
/**
* Hub command set, get the power supply state of each hub slot.
*/
kCommandIDHubQuerySlotPowerStatus = 8,
/**
* ******************************************************
@@ -179,6 +183,7 @@ static const uint16_t HubCommandTimeout[kCommandIDHubCommandCount] = {KDefaultTi
KDefaultTimeOut,
KDefaultTimeOut,
KDefaultTimeOut,
KDefaultTimeOut,
KDefaultTimeOut};
/**
+3 -2
View File
@@ -38,10 +38,11 @@ DataHandler &data_handler() {
return handler;
}
bool DataHandler::AddDataListener(uint8_t handle, const DataCallback &cb) {
bool DataHandler::AddDataListener(uint8_t handle, const DataCallback &cb, void *client_data) {
if (handle >= callbacks_.size()) {
return false;
}
client_data_[handle] = client_data;
callbacks_[handle] = cb;
return true;
}
@@ -107,7 +108,7 @@ void DataHandler::OnDataCallback(uint8_t handle, void *data, uint16_t size) {
//LOG_INFO(" timeStampType: {}", (uint32_t) (lidar_data->timestamp_type));
//LOG_INFO(" timeStamp: {}", (uint32_t) *(lidar_data->time_stamp));
//LOG_INFO(" dataType: {}", (uint16_t) lidar_data->data_type);
cb(handle, lidar_data, size);
cb(handle, lidar_data, size, client_data_[handle]);
}
}
+3 -3
View File
@@ -38,7 +38,7 @@ class DataHandlerImpl;
class DataHandler : public noncopyable {
public:
typedef boost::function<void(uint8_t handle, LivoxEthPacket *data, uint32_t data_num)> DataCallback;
typedef boost::function<void(uint8_t handle, LivoxEthPacket *data, uint32_t data_num, void *client_data)> DataCallback;
public:
DataHandler() : mem_pool_(NULL) {}
@@ -49,13 +49,13 @@ class DataHandler : public noncopyable {
bool AddDevice(const DeviceInfo &info);
void RemoveDevice(uint8_t handle);
bool AddDataListener(uint8_t handle, const DataCallback &cb);
// bool RemoveDataListener(uint8_t handle);
bool AddDataListener(uint8_t handle, const DataCallback &cb, void *client_data);
void OnDataCallback(uint8_t handle, void *data, uint16_t size);
private:
apr_pool_t *mem_pool_;
boost::array<DataCallback, kMaxConnectedDeviceNum> callbacks_;
boost::array<void *, kMaxConnectedDeviceNum> client_data_;
boost::scoped_ptr<DataHandlerImpl> impl_;
};
-2
View File
@@ -214,8 +214,6 @@ void DeviceManager::UpdateDeviceState(uint8_t handle, const HeartbeatResponse &r
if (handle >= devices_.size()) {
return;
}
//LOG_INFO(" Update State {}, connect {}", (uint16_t)response.state, devices_[handle].connected);
bool update = false;
DeviceInfo &info = devices_[handle].info;
if (info.state != response.state) {