I believe I have found a threading issue with the recontruct() function but could use some advice. According to QHull's website:
With care, you may create multiple Qhull instances, but only one thread may use qh_qh, qh_qhstat, and qhmem at a time (i.e., most of libqhull, the original C program). only one instance may be active at time.
When I create 12 threads using #pragma omp parallel for schedule(dynamic) I get qhull errors despite allocating 12 different wrapper classes like so:
Error:
QH6205 qhull error (qh_initqhull_start): qh_qh already defined. Call qh_save_qhull() first
Wrapper function:
std::vector<tf::Point> TestStability::convexHull(const std::vector<tf::Point>& points) const
{
std::vector<tf::Point> hull;
pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_points(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ> chull_points;
pcl::ConvexHull<pcl::PointXYZ> chull;
if (points.empty()){
ROS_ERROR("convexHull on empty set of points!");
return hull;
}
for (unsigned i = 0; i < points.size(); ++i){
pcl_points->points.push_back(pcl::PointXYZ(points[i].x(), points[i].y(), 0.0));
}
chull.setDimension(2);
chull.setInputCloud(pcl_points);
std::vector<pcl::Vertices> polygons;
chull.reconstruct(chull_points, polygons);
if (polygons.size() == 0){
ROS_ERROR("Convex hull polygons are empty");
return hull;
} else if (polygons.size() > 1){
ROS_WARN("Convex hull polygons are larger than 1");
}
for (unsigned i = 0; i < polygons[0].vertices.size(); ++i){
int idx = polygons[0].vertices[i];
tf::Point p(chull_points.points[idx].x,
chull_points.points[idx].y,
chull_points.points[idx].z);
hull.push_back(p);
}
return hull;
}
The qhull error occurs when calling:
chull.reconstruct(chull_points, polygons);
Did you ever solve this issue? It seems Qhull has a new version that supports Multithreading
No I did not, I've since moved on from this project. My solution was just to use a mutex for calling this... not that great.
Well..I do need it for my code:
Reentrant Qhull was updated to support multiple threads sometime mid last year:
http://www.qhull.org/html/qh-code.htm
Will maybe need to look into replacing the routines used in PCL with libqhull_r routines
I obtain exactly the same issue when I try to compute boundary in parallel section...
This is really an old issue. Briefly, I try to replace every header from libqhull by libqhull_r (as it is avaible in the package I installed on my ubuntu 16.04). As excepted, it doesn't work as is. Some prototype as changed, so it doesn't compile anymore. Wait and see.
Related issue: #1618.
Related pull request: #1565.
Thanks body.
Closing this as a duplicate of #1618. Please reopen if needed.