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

Revision history [back]

No, you're on the right track, subscribing to the depth image is a good way to figure out the distance. The numbers you mention are a one-dimensional integer array (data); what you now have to do is convert that into a two-dimensional float array that is indexed by pixels and where each float specifies the depth in meters. The encoding field tells you which encoding to use.

Some pointers:

  • OpenCV seems to be a good option (see this answer) to do what you want
  • There is a horribly hackish solution here
  • REP 118 specifies the representation of depth images in ROS
  • the comments in sensor_msgs/Image are very helpful to understand what's going on