# How to get the distance in meter from PointCloud Data? Hello, I am pretty new with ROS and Robotino. I am using ROS-Indigo, Ubuntu 14.4 and Robotino by Festo. I am subscribing the ros topic /distance_sensor :

ros::Subscriber sub = n.subscribe("/distance_sensors",1, distacne_sensor_Callback);
void distacne_sensor_Callback(const sensor_msgs::PointCloudConstPtr& msg)
{
for (i=0;i<msg->points.size();i++) {
ROS_INFO("X : %f",  msg->points[i].x);
ROS_INFO("Y : %f",  msg->points[i].y);
ROS_INFO("Z : %f",  msg->points[i].z);
}


I am getting the x,y,z values for each of the 9 distance sensors. How can I get the distance in meter using these data? I need to use these for obstacle detection. Can anyone give me any idea on this issue? Thank is advance.

edit retag close merge delete

Sort by » oldest newest most voted points[i] gives you information about the ith point from the frame of the sensor. That is, if

points[i] = {
x : 0.2
y : 1.2
z : 0.6
}


that means that ith point is at (0.2,1.2,0.6) in the frame of the sensor. Assuming the sensor is fixed to the body of your robot, you can use a static transformation to transform that information to your base_link frame. You can read up on transforms here : http://wiki.ros.org/tf

I hope you are clear. If not, let me know.

more

Thanks for your response. I already go through the link and understand the point and x,y,z coordinate. But i need to detect obstacle based on distance sensor data. Robotino has 9 sensors in the circle base of the robot. Each of them are 40' angular distance. I need help to calculate the distance.

I'm not clear on one thing. When you say PointCloud data are published to the topic /distance_sensors, do you mean it actually publishes the locations of the actual distance senors wrt the robot? If that is the case then there should be a different topic that publishes your distance sensor readings

Does the (x,y,z) coordinates from the point cloud give the real world distances? After reading this,my understanding was the coordinates are used to create a projected image.

I also read that earlier.I got the obstacle distance from kinect depth image. Actually Z is not the distance. Z is the distance from the camera to the center point of the image plane. That is why we need to calculate the tangent of the point to get the actual distance.

I actually tried this same approach to find distance from the distance sensors. But I am not sure if it is appropriate for getting distance from distance sensor. It is working for sensor 7 and but for the other sensor it is not working properly. Expecting help from guys who have worked with robotino