27 #ifndef LIVOX_ROS_DRIVER_LDS_H_ 28 #define LIVOX_ROS_DRIVER_LDS_H_ 37 #include <condition_variable> 41 #include "livox_def.h" 74 const double PI = 3.14159265358979323846;
139 char broadcast_code[16];
238 {100, 1318,
sizeof(LivoxRawPoint), 1},
242 {48, 1362,
sizeof(LivoxDualExtendRawPoint), 2},
243 {48, 786,
sizeof(LivoxDualExtendSpherPoint), 2},
244 {1, 42,
sizeof(LivoxImuPoint), 1},
245 {30, 1278,
sizeof(LivoxTripleExtendRawPoint), 3},
246 {30, 678,
sizeof(LivoxTripleExtendSpherPoint), 3}};
271 std::vector<std::string> &bd_code_list);
296 return product_type_info_pair_table[product_type].
point_interval *
301 return product_type_info_pair_table[product_type].
line_num;
317 return data_type_info_pair_table[data_type].
echo_num;
321 dst_point->
x = raw_point->x;
322 dst_point->
y = raw_point->y;
323 dst_point->
z = raw_point->z;
324 dst_point->
reflectivity = (float)raw_point->reflectivity;
328 LivoxRawPoint *raw_point) {
329 dst_point->
x = raw_point->x / 1000.0f;
330 dst_point->
y = raw_point->y / 1000.0f;
331 dst_point->
z = raw_point->z / 1000.0f;
332 dst_point->
reflectivity = (float)raw_point->reflectivity;
336 LivoxSpherPoint *raw_point) {
337 double radius = raw_point->depth / 1000.0;
338 double theta = raw_point->theta / 100.0 / 180 *
PI;
339 double phi = raw_point->phi / 100.0 / 180 *
PI;
340 dst_point->
x = radius * sin(theta) * cos(phi);
341 dst_point->
y = radius * sin(theta) * sin(phi);
342 dst_point->
z = radius * cos(theta);
343 dst_point->
reflectivity = (float)raw_point->reflectivity;
348 LivoxDualExtendSpherPoint *raw_point) {
349 double radius1 = raw_point->depth1 / 1000.0;
350 double radius2 = raw_point->depth2 / 1000.0;
351 double theta = raw_point->theta / 100.0 / 180 *
PI;
352 double phi = raw_point->phi / 100.0 / 180 *
PI;
353 dst_point1->
x = radius1 * sin(theta) * cos(phi);
354 dst_point1->
y = radius1 * sin(theta) * sin(phi);
355 dst_point1->
z = radius1 * cos(theta);
356 dst_point1->
reflectivity = (float)raw_point->reflectivity1;
358 dst_point2->
x = radius2 * sin(theta) * cos(phi);
359 dst_point2->
y = radius2 * sin(theta) * sin(phi);
360 dst_point2->
z = radius2 * cos(theta);
361 dst_point2->
reflectivity = (float)raw_point->reflectivity2;
367 LivoxTripleExtendSpherPoint *raw_point) {
368 double radius1 = raw_point->depth1 / 1000.0;
369 double radius2 = raw_point->depth2 / 1000.0;
370 double radius3 = raw_point->depth3 / 1000.0;
371 double theta = raw_point->theta / 100.0 / 180 *
PI;
372 double phi = raw_point->phi / 100.0 / 180 *
PI;
373 dst_point1->
x = radius1 * sin(theta) * cos(phi);
374 dst_point1->
y = radius1 * sin(theta) * sin(phi);
375 dst_point1->
z = radius1 * cos(theta);
376 dst_point1->
reflectivity = (float)raw_point->reflectivity1;
378 dst_point2->
x = radius2 * sin(theta) * cos(phi);
379 dst_point2->
y = radius2 * sin(theta) * sin(phi);
380 dst_point2->
z = radius2 * cos(theta);
381 dst_point2->
reflectivity = (float)raw_point->reflectivity2;
383 dst_point3->
x = radius3 * sin(theta) * cos(phi);
384 dst_point3->
y = radius3 * sin(theta) * sin(phi);
385 dst_point3->
z = radius3 * cos(theta);
386 dst_point3->
reflectivity = (float)raw_point->reflectivity3;
394 return ((x != 0.0
f) || (y != 0.0
f) || (z != 0.0
f));
403 std::unique_lock<std::mutex> lock(
mutex_);
409 std::unique_lock<std::mutex> lock(
mutex_);
410 cv_.wait(lock, [=] {
return count_ > 0; });
420 std::condition_variable
cv_;
432 void StorageRawPacket(
uint8_t handle, LivoxEthPacket* eth_packet);
436 void ResetLds(
uint8_t data_src);
438 bool IsAllQueueEmpty();
439 bool IsAllQueueReadStop();
442 virtual void PrepareExit(
void);
443 void UpdateLidarInfoByEthPacket(
LidarDevice *p_lidar, \
444 LivoxEthPacket* eth_packet);
uint32_t GetPointInterval(uint32_t product_type)
bool IsFilePathValid(const char *path_str)
float TranslationVector[3]
bool enable_high_sensitivity
const uint32_t kMaxEthPacketQueueSize
const int64_t kDeviceDisconnectThreshold
const uint32_t kMaxSourceLidar
uint32_t points_per_second
uint32_t receive_packet_count
const uint32_t kDeviceTypeLidarMid70
const uint32_t KEthPacketHeaderLength
const int64_t kMaxPacketTimeGap
bool IsTripleFloatNoneZero(float x, float y, float z)
uint32_t loss_packet_count
ExtrinsicParameter extrinsic_parameter
uint32_t GetEchoNumPerPoint(uint32_t data_type)
uint32_t GetLaserLineNumber(uint32_t product_type)
const ProductTypePointInfoPair product_type_info_pair_table[kMaxProductType]
void ParseCommandlineInputBdCode(const char *cammandline_str, std::vector< std::string > &bd_code_list)
int64_t last_imu_timestamp
float RotationMatrix[3][3]
uint32_t GetPointsPerPacket(uint32_t data_type)
uint8_t * LivoxImuDataProcess(uint8_t *point_buf, LivoxEthPacket *eth_packet)
uint32_t points_per_packet
uint8_t *(* PointConvertHandler)(uint8_t *point_buf, LivoxEthPacket *eth_packet, ExtrinsicParameter &extrinsic, uint32_t line_num)
void ZeroPointDataOfStoragePacket(StoragePacket *storage_packet)
volatile uint32_t get_bits
const uint32_t kPointXYZRTRSize
bool enable_high_sensitivity
uint32_t extrinsic_parameter_source
uint32_t extrinsic_parameter_source
uint32_t GetPacketNumPerSec(uint32_t product_type, uint32_t data_type)
const uint32_t kMaxPointPerEthPacket
void PointExtrisincCompensation(PointXyz *dst_point, const PointXyz &src_point, ExtrinsicParameter &extrinsic)
volatile bool request_exit_
uint64_t GetStoragePacketTimestamp(StoragePacket *packet, uint8_t data_src)
const uint32_t kMaxProductType
unsigned __int64 uint64_t
volatile uint32_t set_bits
const int64_t kPacketTimeGap
const uint64_t kRosTimeMax
void RawPointConvert(LivoxPointXyzr *dst_point, LivoxPoint *raw_point)
LidarPacketStatistic statistic_info
volatile uint32_t packet_interval
uint32_t GetPacketInterval(uint32_t product_type, uint32_t data_type)
uint32_t raw_point_length
const DataTypePointInfoPair data_type_info_pair_table[kMaxPointDataType]
uint64_t RawLdsStampToNs(LdsStamp ×tamp, uint8_t timestamp_type)
const int kPathStrMaxSize
const uint32_t kPointXYZRSize
const int kPathStrMinSize
void EulerAnglesToRotationMatrix(EulerAngle euler, RotationMatrix matrix)
const uint32_t KCartesianPointSize
bool IsTripleIntNoneZero(int32_t x, int32_t y, int32_t z)
const uint32_t kMinEthPacketQueueSize
const uint32_t KSphericalPointSzie
const uint32_t kImuEthPacketQueueSize
uint8_t * LivoxPointToPxyzrtl(uint8_t *point_buf, LivoxEthPacket *eth_packet, ExtrinsicParameter &extrinsic, uint32_t line_num)
volatile uint32_t onetime_publish_packets
uint32_t GetEthPacketLen(uint32_t data_type)
PointConvertHandler GetConvertHandler(uint8_t data_type)
uint32_t CalculatePacketQueueSize(uint32_t interval_ms, uint8_t product_type, uint8_t data_type)
volatile LidarConnectState connect_state
volatile uint32_t packet_interval_max
std::condition_variable cv_
const int64_t kNsPerSecond
uint32_t GetPointLen(uint32_t data_type)