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

Is this the right way to obtain depth information?

asked 2016-07-01 16:36:51 -0600

skr_robo gravatar image

updated 2022-05-29 12:50:17 -0600

lucasw gravatar image

Hello, I am trying to find the closest object to a zed camera. I am using the package: zed_wrapper. I need to find the depth (z value) of each pixel in the scene. My understanding is that the topic:

/camera/depth/image_rect_color

will provide me the required information. The command rostopic type /camera/depth/image_rect_color returned

sensor_msgs/Image

which I believe is the msg type for depth images. The command rosmsg show sensor_msgs/Image returned

std_msgs/Header header
 uint32 seq
 time stamp
 string frame_id
uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data

I believe that the last field:

uint8[] data

gives the actual info.

I believe that at this point, I should write a subscriber. Do I have enough information to write a subscriber? Is there any other way I can get this information without writing a subscriber? Kindly help. Thank You.

edit retag flag offensive close merge delete

Comments

subscribe to sensor_msgs::PointCloud2 input, where input is your camera topic than convert it to pcl::PointCloud<pcl::pointxyzrgb> cloud, then make struct: PointXYZRGB p1, then access the z value as depth = p1.z where p1 = cloud.at(x,y), where (x,y) is pixel position of depth image.

dinesh gravatar image dinesh  ( 2016-07-06 03:08:25 -0600 )edit

I am not looking to subscribe to point cloud at this stage. I just need depth values. I believe zed provides separate topic for depth alone without relying on topics related to point cloud.

skr_robo gravatar image skr_robo  ( 2016-07-06 11:19:30 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-07-04 19:56:20 -0600

janindu gravatar image

If you want to process this data, yes you need to write a subscriber. And yes, if you know the topic name and the message type, that's enough to write a subscriber (for fine tuning you might need information like publishing frequency etc).

You can follow the ROS tutorial to write the subscriber : http://wiki.ros.org/ROS/Tutorials/Wri...

You can see what each field in the message represents here : http://docs.ros.org/api/sensor_msgs/h...

Does this answer your question?

edit flag offensive delete link more

Comments

Thanks for the help. Is there anywhere I can know for sure that the topic I am subscribing to is right i.e. some source that says so and so topic gives depth, without relying on the name of the topic. I mean any page similar to the one to identify fields of the messages.

skr_robo gravatar image skr_robo  ( 2016-07-06 11:27:33 -0600 )edit

In Zed-ros-wrapper docs it only says which topics are published by the node and assuming that the developers are not intentionally trying to mislead us (LOL) I think we can rely on the topic name.

janindu gravatar image janindu  ( 2016-07-06 17:52:41 -0600 )edit

I browsed the code and from the first glance, in line 365 the depth topic is defined. So yes, /camera/depth/image_rect_color looks like the topic you want to subscribe to. Also please read the comment in line 24

janindu gravatar image janindu  ( 2016-07-06 17:56:33 -0600 )edit

Thank You so much for your help. I am sorry if I asked too much. I am relatively new to this. I am grateful for all the info.

skr_robo gravatar image skr_robo  ( 2016-07-08 10:41:41 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-01 16:36:51 -0600

Seen: 910 times

Last updated: May 29 '22