使用点云检测表面上的空圆形/矩形

问题描述 投票:0回答:1

我正在使用 Intel Realsense L515 激光雷达来获取点云。我需要检测表面(即桌子或墙壁)上的空白区域(没有物体阻挡它),以便机械臂有足够的空间在该点向表面施加压力。

到目前为止,我已经在 PCL 中分割了点云,以便找到一个平面,首先检测表面。 之后,我尝试在该区域的任意位置分割一个 10-20 厘米的圆圈,以尝试找到一个可供机器人操作的空白空间。

https://i.stack.imgur.com/ElwEF.jpg

然而,正如你所看到的,圆圈(黄点)是空心的,而不是一个完整的圆盘(因此里面可能有物体),并且它上面有孔,所以它并不是桌子上真正的空地方,因为孔是由平面分割阶段消除的对象创建(在本例中,这是我的脚位于圆圈中间)。

有没有办法获得平面上真实的非物体杂乱区域?

当前代码:

//Plane segmentation processing start
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
// Create the plane segmentation object
pcl::SACSegmentation<pcl::PointXYZ> seg;
// Optional
seg.setOptimizeCoefficients (true);
// Mandatory
seg.setModelType (pcl::SACMODEL_PLANE);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setDistanceThreshold (0.005);

// Create the filtering object
pcl::ExtractIndices<pcl::PointXYZ> extract;

// Segment the largest planar component from the remaining cloud
seg.setInputCloud(cloud);
pcl::ScopeTime scopeTime("Test loop plane");
{
    seg.segment(*inliers, *coefficients);
}
if (inliers->indices.size() == 0)
{
    std::cerr << "Could not estimate a planar model for the given dataset." << std::endl;
}

// Extract the inliers
extract.setInputCloud(cloud);
extract.setIndices(inliers);
extract.setNegative(false);
extract.filter(*cloud_p);
std::cerr << "PointCloud representing the planar component: " << cloud_p->width * cloud_p->height << " data points." << std::endl;

//Circle segmentation processing start
pcl::ModelCoefficients::Ptr coefficients_c (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers_c (new pcl::PointIndices);
// Create the circle segmentation object
pcl::SACSegmentation<pcl::PointXYZ> seg_c;
// Optional
seg_c.setOptimizeCoefficients (true);
// Mandatory
seg_c.setModelType (pcl::SACMODEL_CIRCLE2D);
seg_c.setMethodType (pcl::SAC_RANSAC);
seg_c.setDistanceThreshold (0.01);
seg_c.setRadiusLimits(0.1,0.2);

// Create the filtering object
pcl::ExtractIndices<pcl::PointXYZ> extract_c;

// Segment a circle component from the remaining cloud
seg_c.setInputCloud(cloud_p);
pcl::ScopeTime scopeTime2("Test loop circle");
{
    seg_c.segment(*inliers_c, *coefficients_c);
}
if (inliers_c->indices.size() == 0)
{
    std::cerr << "Could not estimate a circle model for the given dataset." << std::endl;
}
std::cerr << "Circle coefficients: \nCenter coordinates: " << coefficients_c->values[0] << " " << coefficients_c->values[1] << " " << coefficients_c->values[2] << " ";

// Extract the inliers
extract_c.setInputCloud(cloud_p);
extract_c.setIndices(inliers_c);
extract_c.setNegative(false);
extract_c.filter(*cloud_c);
std::cerr << "PointCloud representing the circle component: " << cloud_c->width * cloud_c->height << " data points." << std::endl;
c++ point-cloud-library point-clouds robotics realsense
1个回答
0
投票

你完成这个项目了吗?我正在尝试做同样的事情,但就我而言,它是找到桌子上的空白空间,以便机器人可以放下物体。

提前致谢

© www.soinside.com 2019 - 2024. All rights reserved.