Ask Your Question
1

How to segment/extract a sphere using pcl_ros?

asked 2011-03-06 02:29:38 -0500

Pi Robot gravatar image

updated 2016-10-24 09:01:49 -0500

ngrennan gravatar image

UPDATE:

After much trial and error, I have given up on trying to get this to work with a chain of nodelets. It is so much easier to do using the C++ examples from http://www.pointclouds.org so I will pursue that approach instead. To extract a sphere, I just modified the cylinder example found at http://www.pointclouds.org/documentat...

[Original question now follows.]

Hello,

I am able to successfully extract planes from a Kinect depth image using Diamondback under Ubuntu 10.04 and using the following launch file:

<launch>
  <node pkg="nodelet" type="nodelet" name="pcl_manager" args="manager" output="screen" />

  <!-- Run a Voxel Grid filter -->
  <node pkg="nodelet" type="nodelet" name="voxel_grid" args="load pcl/VoxelGrid pcl_manager" output="screen">
    <remap from="~input" to="/camera/depth/points" />
    <rosparam>
      filter_field_name: z
      filter_limit_min: 0.5
      filter_limit_max: 1.5
      filter_limit_negative: False
      leaf_size: 0.01
    </rosparam>
  </node>

  <!-- Run a Planar Segmentation filter -->
  <node pkg="nodelet" type="nodelet" name="sac_plane" args="load pcl/SACSegmentation pcl_manager" output="screen">
    <remap from="~input" to="/voxel_grid/output" />
    <rosparam>
      model_type: 0
      distance_threshold: 0.01
    </rosparam>
  </node>

  <!-- Then Extract the Inlier Points -->
  <node pkg="nodelet" type="nodelet" name="extract_plane" args="load pcl/ExtractIndices pcl_manager" output="screen">
    <remap from="~input" to="/voxel_grid/output" />
    <remap from="/extract_plane/indices" to="/sac_plane/inliers" />
  </node>
</launch>

And now I would like to extract a sphere (a 6" ball sitting on a table about 1 meter away from the Kinect) using a similar technique. I was hoping it would be as easy as changing the SAC model_type from 0 to 4 but the following launch file generates the error and warning:

[ERROR] [1299428614.657650314]: [pcl::SampleConsensusModelSphere::optimizeModelCoefficients] Not enough inliers found to support a model (0)! Returning the same coefficients.
[ WARN] [1299428614.657849802]: [/sac_sphere::input_indices_callback] No inliers found!

Here is the launch file I tried for extracting a sphere:

<launch>
  <node pkg="nodelet" type="nodelet" name="pcl_manager" args="manager" output="screen" />

  <!-- Run a Voxel Grid filter -->
  <node pkg="nodelet" type="nodelet" name="voxel_grid" args="load pcl/VoxelGrid pcl_manager" output="screen">
    <remap from="~input" to="/camera/depth/points" />
    <rosparam>
      filter_field_name: z
      filter_limit_min: 0.5
      filter_limit_max: 1.5
      filter_limit_negative: False
      leaf_size: 0.01
    </rosparam>
  </node>

  <!-- Run a Sphere Segmentation filter -->
  <node pkg="nodelet" type="nodelet" name="sac_sphere" args="load pcl/SACSegmentation pcl_manager" output="screen">
    <remap from="~input" to="/voxel_grid/output" />
    <rosparam>
      model_type: 4
      distance_threshold: 0.01
    </rosparam>
  </node>

  <!-- Then Extract the Inlier Points -->
  <node pkg="nodelet" type="nodelet" name="extract_sphere" args="load pcl/ExtractIndices pcl_manager" output="screen">
    <remap from="~input" to="/voxel_grid/output" />
    <remap from="/extract_sphere/indices" to="/sac_sphere/inliers" />
  </node>

</launch>

I am using VGA/30Hz resolution for both RGB and depth. The sphere is a 6" ball sitting on a table about 1 meter away from the Kinect. I have tried different leaf sizes from 0.01 to 0.0001 meters with the same result. I have also tried different distance_thresholds from 1.0 to 0.0001 with the same result. Both the raw depth image and voxel_grid image look very "sphere-like" in RViz. However ... (more)

edit retag flag offensive close merge delete

Comments

hi can you help me to detect planes ?? im struck ...

kk gravatar imagekk ( 2013-07-12 04:21:27 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2011-05-24 05:50:51 -0500

Some of the SAC methods only work when a large percentage of the points are part of the target model. You might want to try using a different method, though I don't know enough to suggest a specific method. Examples are RANSAC, RRANSAC, MLESAC, MSAC, etc.

Also, the number of iterations might be important. I'm unaware of what the default number is, but if it's low, pumping it up might help (but will slow things down).

edit flag offensive delete link more

Comments

After much trial and error, I have given up on trying to get this to work with a chain of nodelets. It is so much easier to do using the C++ examples from http://www.pointclouds.org so I will pursue that approach instead. To extract a sphere, I just modified the cylinder example found at http://www.pointclouds.org/documentation/tutorials/cylinder_segmentation.php#cylinder-segmentation.
Pi Robot gravatar imagePi Robot ( 2011-05-29 03:42:23 -0500 )edit
Please edit the original question and post an update with your answer, or please add an answer and accept it.
Vincent Rabaud gravatar imageVincent Rabaud ( 2011-06-17 12:16:08 -0500 )edit
0

answered 2011-05-23 13:08:43 -0500

mdixon gravatar image

I don't have a lot of experience with ROS nodelets, but I think I can help a little bit in this case. I believe the sphere segmentation algorithm is expecting surface normals in addition to to the 3D points. Try adding another nodelet and setting it as the "normals" input for your segmentation filter, like this:

<!-- snip -->

<!-- Estimate surface normals -->
<node pkg="nodelet" type="nodelet" name="normal_estimation" args="load pcl/NormalEstimation pcl_manager" output="screen">
  <remap from="~input" to="/voxel_grid/output" />
  <rosparam>
    spatial_locator: 0
    k_search: 0
    radius_search: 0.02
  </rosparam>
</node>

<!-- Run a Sphere Segmentation filter -->
<node pkg="nodelet" type="nodelet" name="sac_sphere" args="load pcl/SACSegmentation pcl_manager" output="screen">
  <remap from="~input" to="/voxel_grid/output" />
  <remap from="~normals" to="/normal_estimation/output" />
  <rosparam>
    model_type: 4
    distance_threshold: 0.01
  </rosparam>
</node>


<!-- snip -->

I don't really have a good set-up for testing this, so I'm not sure if the parameters I picked will work under your conditions, but this will at least get the segmentation node to return something. Hope this helps.

edit flag offensive delete link more

Comments

Thanks for tip! I'll give it a try later today and report back my results.
Pi Robot gravatar imagePi Robot ( 2011-05-24 01:21:25 -0500 )edit
0

answered 2011-03-06 06:24:35 -0500

fergs gravatar image

How large is this sphere you are trying to extract? If it is a small ball, your voxel_grid (leaf_size) might be too course to find the object.

edit flag offensive delete link more

Comments

Hey Fergs--good question. I've edited my original question with some of the leaf sizes and distance thresholds I have tried. (Look at the bottom of the post above.) In short, no combination of parameters gets rid of the error and I get a blank point cloud on the /extract_sphere/output topic.
Pi Robot gravatar imagePi Robot ( 2011-03-06 06:53:55 -0500 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2011-03-06 02:29:38 -0500

Seen: 2,207 times

Last updated: Jun 17 '11