0
$\begingroup$

Rosanswers logo

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.


Originally posted by skr_robo on ROS Answers with karma: 178 on 2016-07-01

Post score: 0


Original comments

Comment by dinesh on 2016-07-06:
subscribe to sensor_msgs::PointCloud2 input, where input is your camera topic than convert it to pcl::PointCloudpcl::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.

Comment by skr_robo on 2016-07-06:
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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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/WritingPublisherSubscriber(c%2B%2B)

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

Does this answer your question?


Originally posted by janindu with karma: 849 on 2016-07-04

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by skr_robo on 2016-07-06:
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.

Comment by janindu on 2016-07-06:
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.

Comment by janindu on 2016-07-06:
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

Comment by skr_robo on 2016-07-08:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.