ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

lukeb88's profile - activity

2014-07-24 07:06:36 -0500 received badge  Famous Question (source)
2014-06-15 04:21:34 -0500 received badge  Notable Question (source)
2014-06-10 07:40:39 -0500 received badge  Popular Question (source)
2014-06-10 03:39:45 -0500 received badge  Enthusiast
2014-06-09 05:12:02 -0500 asked a question Segmentation of a PointCloud to find a specific object (a cup) pcl

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!

2014-05-27 22:21:02 -0500 received badge  Scholar (source)
2014-05-27 22:21:00 -0500 commented answer How to understand the depth of a pixel with the kinect

hi sudeep, now all work! thanks for your answer, it was really useful!

2014-05-27 05:02:15 -0500 received badge  Famous Question (source)
2014-05-27 03:28:08 -0500 answered a question How to understand the depth of a pixel with the kinect

No other answers?

2014-05-27 01:01:17 -0500 commented answer How to understand the depth of a pixel with the kinect

the rgb part work well! but i can't take the depth... i updated my question with my code!

2014-05-26 04:15:02 -0500 received badge  Supporter (source)
2014-05-26 04:08:40 -0500 commented answer How to understand the depth of a pixel with the kinect

i solved the last question using a subscriber that receive a sensor_msgs::PointCloud2 and then using pcl::fromROSMsg (*input, *cloud); But now my problem is that the depth it's always 0, i can't understand why...

2014-05-26 00:00:42 -0500 commented answer How to understand the depth of a pixel with the kinect

for first thanks for your answer... In Ros i'm subscribed to this: ros::Subscriber sub = nh.subscribe< pcl::PointCloud<pcl::pointxyzrgb> >("/camera/depth_registered/points", 1, callback); because i discovered that i can directly subscribe a pcl::PointCloud insted of sensor_msgs::PointCloud, So if I understand correctly i have not to convert cloud data in pcl...

2014-05-24 06:52:20 -0500 received badge  Notable Question (source)
2014-05-24 05:45:08 -0500 received badge  Nice Question (source)
2014-05-24 05:38:54 -0500 received badge  Student (source)
2014-05-24 01:59:04 -0500 received badge  Popular Question (source)
2014-05-23 03:55:13 -0500 asked a question How to understand the depth of a pixel with the kinect

Hi!

I'm new of ROS and for an university project i have to grab a cup with a robot. For first i have to understand where the cup is. I have implemented an algorithm that segment the cup from the rest of the scene, and then it calculate the kaypoints of the new image. At this point i can determinate the "central" of my keypoints, that is broadly the centre of my cup.

The problem now is that till here i have worked with openCV and with the sensor_msgs/image, but to understand the depth of my pixel (the cup position) i need the registered depth topic.

What i couldn't understand it's: How i can subscribe the /camera/depth_registered/points (sensor_msgs/PointCloud2) to extract the RGB image (for the procedure that till here i did with sensor_msgs/image) and the depth image to know the depth of my task's pixel?

thanks

Luca

UPDATE

this is my callback

void callback(const sensor_msgs::PointCloud2::ConstPtr& msg) {
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
    pcl::fromROSMsg (*msg, *cloud);

    cv::Mat imageFrame;
    if (cloud->isOrganized()) {
        imageFrame = cv::Mat(cloud->height, cloud->width, CV_8UC3); 

        for (int h=0; h<imageFrame.rows; h++) {
            for (int w=0; w<imageFrame.cols; w++) {

                pcl::PointXYZRGB point = cloud->at(w, h);

                Eigen::Vector3i rgb = point.getRGBVector3i();

                imageFrame.at<cv::Vec3b>(h,w)[0] = rgb[2];
                imageFrame.at<cv::Vec3b>(h,w)[1] = rgb[1];
                imageFrame.at<cv::Vec3b>(h,w)[2] = rgb[0];

                int i = centre_x + centre_y*cloud->width;
                depth[call_count] = (float)cloud->points[i].z;

            }
        }
}

}//end callback

like you suggested to me. i tried to put the depth of my pixel in a vector, so i thought that i could see at least some values different to 0 (for the noise of the kinect i know that it's possible that some depth values in a point could be 0 or near 0 sometimes). But in my case all values still 0.