Hi!
In my task i need to detect the pose of an object (a cup in my case) because i have to grasp the cup with a robot.
I'm trying to catching the point cloud of the scene with ROS and a kinect. I thought to segment my point cloud that represent the scene, because i want to keep only the point of the cup. I have implemented a code in ROS that has a subscriber to detect the sensor_msgs/PointCloud2, then i transform the PointCloud2 in a pcl::PointXYZ.
And this is the code to the segmentation part:
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
// Create the segmentation object
pcl::SACSegmentation<pcl::PointXYZ> seg;
// Optional
seg.setOptimizeCoefficients (true);
// Mandatory
seg.setModelType (pcl::SACMODEL_CYLINDER);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setDistanceThreshold (0.01);
seg.setInputCloud (cloud);
seg.segment (*inliers, *coefficients);
it seems to work with a SACMODEL_PLANE, but with SACMODEL_CYLINDER this is the error that appears:
[pcl::SACSegmentation::initSACModel] No valid model given!
[pcl::SACSegmentation::segment] Error initializing the SAC model!
Could not estimate a planar model for the given dataset.
I found the various model here http://docs.pointclouds.org/1.7.0/group__sample__consensus.html
Help me please!
P.S. And tell me if i'm trying to do the correct things for my task...
Tank You!