ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Segmentation of a PointCloud to find a specific object (a cup) pcl

asked 2014-06-09 05:12:02 -0600

lukeb88 gravatar image


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

Help me please!

P.S. And tell me if i'm trying to do the correct things for my task...

Tank You!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-06-10 03:05:18 -0600

rastaxe gravatar image

I suggest to follow this tutorial . They use pcl::SACSegmentationFromNormals instead of pcl::SACSegmentation. For me it works!

edit flag offensive delete link more

answered 2016-09-08 20:24:09 -0600

sosx gravatar image

I know this is an old thread but just to clarify, this error happens because they never actually implemented a cylinder model in this module. You can check the code in here in line #134 you can find the handler for different models and cylinder as well as others aren't defined and go to the default which throws your error.

All the unsuported models are:


edit flag offensive delete link more


Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-06-09 05:12:02 -0600

Seen: 4,212 times

Last updated: Jun 10 '14