激光雷达点云处理:直通滤波、体素降采样、欧式聚类、boundingbox

本文记录了一位ROS新手在处理点云数据时的实践经历,包括使用PCL库的直通滤波器对点云进行Z轴和Y轴的卡阈值过滤,以及应用VoxelGrid滤波器进行下采样。通过编写ROS节点,实现了点云的预处理,并展示了最终效果。尽管boundingbox效果一般,但作者表示将继续努力优化。
摘要由CSDN通过智能技术生成

       初接触ROS的小白一枚,借鉴PCL官方以及Adam大佬的内容,好不容易跑通了这一套处理点云的代码,在此做一下记录。

一、直通滤波:

PCL官方提供的代码使用通过过滤点云库 0.0 文档过滤点云云 (pcl.readthedocs.io)

以及借鉴的一篇CSDN文章(5条消息) PCL点云滤波:直通滤波PassThrough(简单卡阈值留点)和适用场景_手口一斤-CSDN博客

对z轴、y轴上的点云进行直通滤波:

void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud_msg)
{
  // Container for original & filtered data
  pcl::PCLPointCloud2* cloud = new pcl::PCLPointCloud2;
  pcl::PCLPointCloud2ConstPtr cloudPtr(cloud);
  pcl::PCLPointCloud2* cloud_filtered = new pcl::PCLPointCloud2;
  pcl::PCLPointCloud2ConstPtr passPtr(cloud_filtered);

  // Convert to PCL data type
  pcl_conversions::toPCL(*cloud_msg, *cloud);

  // Perform the actual filtering
  pcl::PassThrough<pcl::PCLPointCloud2> pass;
    // build the filter
  pass.setInputCloud (cloudPtr);
  pass.setFilterFieldName ("y");
  pass.setFilterLimits (-5.0, 16.0);
    // apply filter
  pass.filter (*cloud_filtered);


 // Perform the actual filtering
  pcl::PassThrough<pcl::PCLPointCloud2> passz;
    // build the filter
  passz.setInputCloud (passPtr);
  passz.setFilterFieldName ("z");
  passz.setFilterLimits (-0.9, 20.0);
    // apply filter
  passz.filter (*cloud_filtered);


// Convert to ROS data type
  sensor_msgs::PointCloud2 cloud_pt;
  pcl_conversions::moveFromPCL(*cloud_filtered, cloud_pt);


  // Publish the data
  pub.publish (cloud_pt);
}

二、降采样

PCL官方提供的代码使用 VoxelGrid 过滤器对点云进行下采样 - 点云库 0.0 文档 (pcl.readthedocs.io)

void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud_msg)
{
  // Container for original & filtered data
  pcl::PCLPointCloud2* cloud = new pcl::PCLPointCloud2;
  pcl::PCLPointCloud2ConstPtr cloudPtr(cloud);
  pcl::PCLPointCloud2 cloud_filtered;

  // Convert to PCL data type
  pcl_conversions::toPCL(*cloud_msg, *cloud);

  // Perform the actual filtering
    pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
    // build the filter
    sor.setInputCloud (cloudPtr);
    sor.setLeafSize (0.5, 0.5, 0.5);
    // apply filter
    sor.filter (cloud_filtered);

  // Convert to ROS data type
  sensor_msgs::PointCloud2 cloud_vog;
  pcl_conversions::moveFromPCL(cloud_filtered, cloud_vog);

  // Publish the data
  pub.publish (cloud_vog);
}

三、欧式聚类和boundingbox

借鉴了Adam大佬的一篇博客(5条消息) 无人驾驶汽车系统入门(二十五)——基于欧几里德聚类的激光雷达点云分割及ROS实现_AdamShan的博客-CSDN博客

 四、总结

编写launch文件运行上述cpp文件的几个节点,最后出来的效果如上图。

 受实验环境影响,boundingbox的效果一般。

还需要继续努力呀!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值