mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-03 16:27:46 +08:00
point_cloud_xyz: doing radius filtering AFTER voxel filtering to gain a lot of performance
This commit is contained in:
@@ -270,32 +270,31 @@ private:
|
|||||||
|
|
||||||
void processAndPublish(pcl::PointCloud<pcl::PointXYZ>::Ptr & pclCloud, const std_msgs::Header & header)
|
void processAndPublish(pcl::PointCloud<pcl::PointXYZ>::Ptr & pclCloud, const std_msgs::Header & header)
|
||||||
{
|
{
|
||||||
if(pclCloud->size())
|
if(pclCloud->size() && (minDepth_ != 0.0 || maxDepth_ > minDepth_))
|
||||||
{
|
|
||||||
if(minDepth_ != 0.0 || maxDepth_ > minDepth_)
|
|
||||||
{
|
{
|
||||||
pclCloud = rtabmap::util3d::passThrough(pclCloud, "z", minDepth_, maxDepth_>minDepth_?maxDepth_:std::numeric_limits<float>::max());
|
pclCloud = rtabmap::util3d::passThrough(pclCloud, "z", minDepth_, maxDepth_>minDepth_?maxDepth_:std::numeric_limits<float>::max());
|
||||||
}
|
}
|
||||||
else if(noiseFilterRadius_ > 0.0 && noiseFilterMinNeighbors_ > 0)
|
|
||||||
{
|
|
||||||
// remvoe NaN values
|
|
||||||
pclCloud = rtabmap::util3d::removeNaNFromPointCloud(pclCloud);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pclCloud->size() && noiseFilterRadius_ > 0.0 && noiseFilterMinNeighbors_ > 0)
|
|
||||||
{
|
|
||||||
pcl::IndicesPtr indices = rtabmap::util3d::radiusFiltering(pclCloud, noiseFilterRadius_, noiseFilterMinNeighbors_);
|
|
||||||
pcl::PointCloud<pcl::PointXYZ>::Ptr tmp(new pcl::PointCloud<pcl::PointXYZ>);
|
|
||||||
pcl::copyPointCloud(*pclCloud, *indices, *tmp);
|
|
||||||
pclCloud = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pclCloud->size() && voxelSize_ > 0.0)
|
if(pclCloud->size() && voxelSize_ > 0.0)
|
||||||
{
|
{
|
||||||
pclCloud = rtabmap::util3d::voxelize(pclCloud, voxelSize_);
|
pclCloud = rtabmap::util3d::voxelize(pclCloud, voxelSize_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do radius filtering after voxel filtering ( a lot faster)
|
||||||
|
if(pclCloud->size() && noiseFilterRadius_ > 0.0 && noiseFilterMinNeighbors_ > 0)
|
||||||
|
{
|
||||||
|
if(voxelSize_ <= 0.0 && !(minDepth_ != 0.0 || maxDepth_ > minDepth_))
|
||||||
|
{
|
||||||
|
// remove NaN values
|
||||||
|
pclCloud = rtabmap::util3d::removeNaNFromPointCloud(pclCloud);
|
||||||
|
}
|
||||||
|
|
||||||
|
pcl::IndicesPtr indices = rtabmap::util3d::radiusFiltering(pclCloud, noiseFilterRadius_, noiseFilterMinNeighbors_);
|
||||||
|
pcl::PointCloud<pcl::PointXYZ>::Ptr tmp(new pcl::PointCloud<pcl::PointXYZ>);
|
||||||
|
pcl::copyPointCloud(*pclCloud, *indices, *tmp);
|
||||||
|
pclCloud = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
sensor_msgs::PointCloud2 rosCloud;
|
sensor_msgs::PointCloud2 rosCloud;
|
||||||
pcl::toROSMsg(*pclCloud, rosCloud);
|
pcl::toROSMsg(*pclCloud, rosCloud);
|
||||||
rosCloud.header.stamp = header.stamp;
|
rosCloud.header.stamp = header.stamp;
|
||||||
|
|||||||
@@ -310,32 +310,31 @@ private:
|
|||||||
|
|
||||||
void processAndPublish(pcl::PointCloud<pcl::PointXYZRGB>::Ptr & pclCloud, const std_msgs::Header & header)
|
void processAndPublish(pcl::PointCloud<pcl::PointXYZRGB>::Ptr & pclCloud, const std_msgs::Header & header)
|
||||||
{
|
{
|
||||||
if(pclCloud->size())
|
if(pclCloud->size() && (minDepth_ != 0.0 || maxDepth_ > minDepth_))
|
||||||
{
|
|
||||||
if(minDepth_ != 0.0 || maxDepth_ > minDepth_)
|
|
||||||
{
|
{
|
||||||
pclCloud = rtabmap::util3d::passThrough(pclCloud, "z", minDepth_, maxDepth_>minDepth_?maxDepth_:std::numeric_limits<float>::max());
|
pclCloud = rtabmap::util3d::passThrough(pclCloud, "z", minDepth_, maxDepth_>minDepth_?maxDepth_:std::numeric_limits<float>::max());
|
||||||
}
|
}
|
||||||
else if(noiseFilterRadius_ > 0.0 && noiseFilterMinNeighbors_ > 0)
|
|
||||||
{
|
|
||||||
// remvoe NaN values
|
|
||||||
pclCloud = rtabmap::util3d::removeNaNFromPointCloud(pclCloud);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pclCloud->size() && noiseFilterRadius_ > 0.0 && noiseFilterMinNeighbors_ > 0)
|
|
||||||
{
|
|
||||||
pcl::IndicesPtr indices = rtabmap::util3d::radiusFiltering(pclCloud, noiseFilterRadius_, noiseFilterMinNeighbors_);
|
|
||||||
pcl::PointCloud<pcl::PointXYZRGB>::Ptr tmp(new pcl::PointCloud<pcl::PointXYZRGB>);
|
|
||||||
pcl::copyPointCloud(*pclCloud, *indices, *tmp);
|
|
||||||
pclCloud = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pclCloud->size() && voxelSize_ > 0.0)
|
if(pclCloud->size() && voxelSize_ > 0.0)
|
||||||
{
|
{
|
||||||
pclCloud = rtabmap::util3d::voxelize(pclCloud, voxelSize_);
|
pclCloud = rtabmap::util3d::voxelize(pclCloud, voxelSize_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do radius filtering after voxel filtering ( a lot faster)
|
||||||
|
if(pclCloud->size() && noiseFilterRadius_ > 0.0 && noiseFilterMinNeighbors_ > 0)
|
||||||
|
{
|
||||||
|
if(voxelSize_ <= 0.0 && !(minDepth_ != 0.0 || maxDepth_ > minDepth_))
|
||||||
|
{
|
||||||
|
// remove NaN values
|
||||||
|
pclCloud = rtabmap::util3d::removeNaNFromPointCloud(pclCloud);
|
||||||
|
}
|
||||||
|
|
||||||
|
pcl::IndicesPtr indices = rtabmap::util3d::radiusFiltering(pclCloud, noiseFilterRadius_, noiseFilterMinNeighbors_);
|
||||||
|
pcl::PointCloud<pcl::PointXYZRGB>::Ptr tmp(new pcl::PointCloud<pcl::PointXYZRGB>);
|
||||||
|
pcl::copyPointCloud(*pclCloud, *indices, *tmp);
|
||||||
|
pclCloud = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
sensor_msgs::PointCloud2 rosCloud;
|
sensor_msgs::PointCloud2 rosCloud;
|
||||||
pcl::toROSMsg(*pclCloud, rosCloud);
|
pcl::toROSMsg(*pclCloud, rosCloud);
|
||||||
rosCloud.header.stamp = header.stamp;
|
rosCloud.header.stamp = header.stamp;
|
||||||
|
|||||||
Reference in New Issue
Block a user