<add> 1.Added point cloud confidence and optimized point cloud processing

2.Modified USB handling logic and added a set of new error messages
This commit is contained in:
oliveiratang
2025-08-08 21:45:56 +08:00
parent eb750f9fe0
commit 24accb60ec
9 changed files with 300 additions and 104 deletions
+54 -16
View File
@@ -498,33 +498,71 @@ void process_pair(const ImageConstPtr &rgb_msg, const PointCloud2ConstPtr &pcd_m
// Set point cloud fields
sensor_msgs::PointCloud2Modifier modifier(*msg);
modifier.setPointCloud2Fields(
4,
5,
"x", 1, sensor_msgs::PointField::FLOAT32,
"y", 1, sensor_msgs::PointField::FLOAT32,
"z", 1, sensor_msgs::PointField::FLOAT32,
"intensity", 1, sensor_msgs::PointField::UINT8
"intensity", 1, sensor_msgs::PointField::UINT8,
"confidence", 1, sensor_msgs::PointField::UINT16
);
modifier.resize(msg->height * msg->width);
// Fill point cloud data
sensor_msgs::PointCloud2Iterator<float> iter_x(*msg, "x");
sensor_msgs::PointCloud2Iterator<float> iter_y(*msg, "y");
sensor_msgs::PointCloud2Iterator<float> iter_z(*msg, "z");
sensor_msgs::PointCloud2Iterator<uint8_t> iter_intensity(*msg, "intensity");
sensor_msgs::PointCloud2Iterator<uint16_t> iter_confidence(*msg, "confidence");
float* xyz_data = static_cast<float*>(cloud.pAddr);
uint16_t* intensity_data = static_cast<uint16_t*>(stream->imageList[2].pAddr);
float* xyz_data_f = static_cast<float*>(cloud.pAddr);
int total_points = cloud.height * cloud.width;
//std::cout << stream->imageCount << std::endl;
int valid_points = 0;
if (stream->imageCount == 4) {
uint8_t* intensity_data = static_cast<uint8_t*>(stream->imageList[2].pAddr);
uint16_t* confidence_data = static_cast<uint16_t*>(stream->imageList[3].pAddr);
for (int i = 0; i < total_points; ++i) {
float* pf = xyz_data + i * 4;
*iter_x = pf[2] / 1000.0f; ++iter_x;
*iter_y = -pf[0] / 1000.0f; ++iter_y;
*iter_z = pf[1] / 1000.0f; ++iter_z;
*iter_intensity = static_cast<uint8_t>(intensity_data[i] >> 8); ++iter_intensity;
if (confidence_data[i] < 35) {
continue;
}
// XYZ point
*iter_x = xyz_data_f[i * 3 + 2] / 1000.0f; ++iter_x;
*iter_y = -xyz_data_f[i * 3 + 0] / 1000.0f; ++iter_y;
*iter_z = xyz_data_f[i * 3 + 1] / 1000.0f; ++iter_z;
*iter_intensity = intensity_data[i]; ++iter_intensity;
*iter_confidence = confidence_data[i]; ++iter_confidence;
valid_points++;
}
} else {
uint16_t* intensity_data = static_cast<uint16_t*>(stream->imageList[2].pAddr);
for (int i = 0; i < total_points; ++i) {
*iter_x = xyz_data_f[i * 4 + 2] / 1000.0f; ++iter_x;
*iter_y = -xyz_data_f[i * 4 + 0] / 1000.0f; ++iter_y;
*iter_z = xyz_data_f[i * 4 + 1] / 1000.0f; ++iter_z;
float intensity = (intensity_data[i] - 10) * 255.0f / (12500 - 10);
if (intensity > 255) {
*iter_intensity = 255;
} else if (intensity < 0) {
*iter_intensity = 0;
} else {
*iter_intensity = static_cast<uint8_t>(intensity);
}
++iter_intensity;
*iter_confidence = 0;
++iter_confidence;
valid_points++;
}
}
{
std::lock_guard<std::mutex> lock(pcd_queue_mutex_);
@@ -847,7 +885,7 @@ private:
rgb_pub_ = node_->create_publisher<ros::Image>("odin1/image", 10);
cloud_pub_ = node_->create_publisher<ros::PointCloud2>("odin1/cloud_raw", 10);
xyzrgbacloud_pub_ = node_->create_publisher<ros::PointCloud2>("odin1/cloud_slam", 10);
odom_publisher_ = node_->create_publisher<ros::Odometry>("odin1/odometry_map", 10);
odom_publisher_ = node_->create_publisher<ros::Odometry>("odin1/odometry", 10);
rgbcloud_pub_ = node_->create_publisher<sensor_msgs::msg::PointCloud2>("odin1/cloud_render", 10);
compressed_rgb_pub_ = node_->create_publisher<sensor_msgs::msg::CompressedImage>("odin1/image/compressed", 10);
#endif
@@ -858,7 +896,7 @@ private:
rgb_pub_ = nh.advertise<ros::Image>("odin1/image", 10);
cloud_pub_ = nh.advertise<ros::PointCloud2>("odin1/cloud_raw", 10);
xyzrgbacloud_pub_ = nh.advertise<ros::PointCloud2>("odin1/cloud_slam", 10);
odom_publisher_ = nh.advertise<ros::Odometry>("odin1/odometry_map", 10);
odom_publisher_ = nh.advertise<ros::Odometry>("odin1/odometry", 10);
rgbcloud_pub_ = nh.advertise<sensor_msgs::PointCloud2>("odin1/cloud_render", 10);
compressed_rgb_pub_ = nh.advertise<sensor_msgs::CompressedImage>("odin1/image/compressed", 10);
}
@@ -945,4 +983,4 @@ private:
#define SENDODOM "sendodom" /* send odometry data */
#define SENDDTOF "senddtof" /* send raw cloud data */
#define SENDCLOUDSLAM "sendcloudslam" /* send rgb cloud data */
#define EXIT "q" /* exit sample */
#define EXIT "q" /* exit sample */
+28 -24
View File
@@ -110,17 +110,6 @@ int lidar_open_device(device_handle device);
* @param device Handle to the device to close
* @return int 0 on success, negative error code on failure
*/
int lidar_get_calib_file(device_handle device, const char* path);
/**
* @brief Get device calibration parameters
*
* Retrieves the current calibration parameters from the device.
*
* @param device Handle to the target device
* @param param Pointer to receive the calibration parameters
* @return int 0 on success, negative error code on failure
*/
int lidar_close_device(device_handle device);
/**
@@ -176,18 +165,22 @@ int lidar_activate_stream_type(device_handle device, int type);
*/
int lidar_deactivate_stream_type(device_handle device, int type);
/**
* @brief Perform over-the-air firmware update
*
* Updates the device firmware using the specified file.
*
* @param device Handle to the target device
* @param type Type of OTA update to perform
* @param filepath Path to the firmware file
* @param process_cb Callback function to report update progress
* @return int 0 on success, negative error code on failure
*/
int lidar_ota_update(device_handle device, lidar_ota_type_e type, const char* filepath, void(*process_cb)(float process));
// /**
// * @brief Perform over-the-air firmware update
// *
// * Updates the device firmware using the specified file.
// *
// * @param device Handle to the target device
// * @param type Type of OTA update to perform
// * @param filepath Path to the firmware file
// * @param process_cb Callback function to report update progress
// * @return int 0 on success, negative error code on failure
// */
// int lidar_ota_update(device_handle device, char* filepath, void(*process_cb)(float process));
int ONLY_FOR_DEV_DONT_PUB_2adb(device_handle device);
int lidar_get_calib_file(device_handle device, const char* path);
/**
* @brief Get device calibration parameters
@@ -220,8 +213,19 @@ int lidar_set_calibration(device_handle device, const lidar_calibration_t *param
*/
void lidar_log_set_level(lidar_log_level_e level);
/**
* @brief Get the version information of the LiDAR device
*
* Retrieves version information including firmware, system, and application versions.
*
* @param device Handle to the target device
* @param version struct Pointer to receive the version information
* @return int 0 on success, negative error code on failure
*/
int lidar_get_version(device_handle device);
#ifdef __cplusplus
}
#endif
#endif // LIDAR_API_H
#endif // LIDAR_API_H
+7
View File
@@ -123,6 +123,13 @@ typedef struct {
void *user_data;
} lidar_data_callback_info_t;
typedef struct {
char mcu_version[64];
char sys_version[64];
char slam_version[64];
char dev_app_version[64];
char host_app_version[64];
} lidar_version_t;
#ifdef __cplusplus
}