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

Obtaining Point by using (column, row) coordinate.

asked 2016-07-05 01:18:33 -0500

dinesh gravatar image

updated 2022-10-06 10:12:42 -0500

ljaniec gravatar image

How to use pcl::PointCloud<pcl::PointXYZ> PCL data type to get the Euclidean points x, y, z by using its member function:

const PointT& pcl::PointCloud< PointT >::at(int column, int row)

and to save in output object:

pcl::PointCloud<pcl::PointXYZ> output;

tried so much but still didn't get how to get the real world coordinates of point cloud in PCL, if I could access the depth of point than by using the camera parameters I would have done but couldn't get that also. I tried this:

 output.PointXYZ.p = input->const PointXYZ& pcl::PointCloud::at(34,43)

to check whether it will access pixel at (34,43) position, it's no use.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-07-05 03:21:53 -0500

ahendrix gravatar image

updated 2016-07-05 03:24:14 -0500

This works for me:

void cloudCb(const sensor_msgs::PointCloud2ConstPtr & cloud) {
  pcl::PointCloud<pcl::PointXYZ> depth;
  pcl::fromROSMsg( *cloud, depth);
  int x = 0, y = 0; // set x and y
  pcl::PointXYZ p1 =, y);

That comes from a sample that uses the full ROS pointCloud2 data structure, but you should be able to do the same by subscribing to the pcl::PointCloud<pcl::PointXYZ> type.

Note that the PointCloud is already transformed into sensor-relative world coordinates; I don't need to perform any additional transformation or use the camera intrinsics to get XYZ data.

Perhaps if you described the problem better by posting the code that's giving you trouble, how you're running it, describing the desired results, and the actual results, we might be be able to provide more useful advice.

edit flag offensive delete link more


thank u for giving me proper solution for this problem, i was so worried for this problem but now i go it. thank u and u people are doing a beautiful work from their. really. next time ill try to describe the problem in more detail.

dinesh gravatar image dinesh  ( 2016-07-05 10:34:41 -0500 )edit

Question Tools

1 follower


Asked: 2016-07-05 01:18:33 -0500

Seen: 1,886 times

Last updated: Oct 06 '22