Ask Your Question
1

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

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

lukeb88 gravatar image

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/gro...

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
3

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

rastaxe gravatar image

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

edit flag offensive delete link more
1

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

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 http://docs.pointclouds.org/1.0.1/sac... 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:

SACMODEL_CIRCLE3D, SACMODEL_CYLINDER, SACMODEL_CONE, SACMODEL_TORUS SACMODEL_PARALLEL_LINES, SACMODEL_NORMAL_PLANE, SACMODEL_NORMAL_SPHERE, SACMODEL_REGISTRATION, SACMODEL_REGISTRATION_2D SACMODEL_NORMAL_PARALLEL_PLANE SACMODEL_STICK

edit flag offensive delete link more

Comments

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

Stats

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

Seen: 3,681 times

Last updated: Jun 10 '14