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

Exchange data between subscribers. How to perform efficiently?

asked 2019-03-21 13:12:37 -0600

JeyP4 gravatar image

updated 2019-03-22 05:15:00 -0600

Hello I am a beginner, so knows a little about ROS network. I am looking for a method to efficiently exchange data between subscribers, which are in a single node.

Image that describes problem statement is attached below

I Sub- ros::Subscriber sub1 = nh.subscribe("/rgb/image_rect_color/compressed", 1, imageCallback); decodes image and push_back to a queue. Queue has two elements time-stamp & cv::Mat, queue length is lets say 3.

II Sub- ros::Subscriber sub2 = nh.subscribe("/depth/compressed", 1, depthCallback); decodes the depth. By the time depth is decoded hopefully its corresponding image would also be ready in the I sub. So sub2 will access it straightforward(less to no waiting).

Whole is idea is to process parallelly. How to make queue and make it access in sub2's callback and to access the image with same time-stamps? Any suggestion is most welcome.

Thank you image description

edit retag flag offensive close merge delete

Comments

1

Please attach your image directly to the question. I've given you sufficient karma for that.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-21 13:17:45 -0600 )edit

I have attached the image. Thank you

JeyP4 gravatar image JeyP4  ( 2019-03-22 02:18:28 -0600 )edit

In any case I'd recommend using image_transport for subscribing to image topics, not regular Subscribers.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-22 11:49:53 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-21 13:16:15 -0600

gvdhoorn gravatar image

updated 2019-03-21 13:16:49 -0600

Take a look at message_filters, in particular, the Policy-Based Synchronizers.

to access the image with same time-stamps?

if they really have the exact same timestamp, use an ExactTime policy.

edit flag offensive delete link more

Comments

Thank you. My concern is decoding image in waiting time. (No wasting of time). Since image comes 10 ms before depth. I want to perform image decoding in that 10ms, In the same node.

JeyP4 gravatar image JeyP4  ( 2019-03-21 15:04:09 -0600 )edit

I'm not sure what you're asking.

By using message_filters, you'll get a single callback for both the depth image and the rgb image. No other callbacks will be called, until you have processed the current pair.

So unless I misunderstand you, that would seem to do exactly what you're after: synced availability of depth and rgb at the same point in time.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-21 15:07:50 -0600 )edit

image description

JeyP4 gravatar image JeyP4  ( 2019-03-22 02:34:00 -0600 )edit

The time synchroniser approach will create a single callback that only gets called when both messages have been received. So the two subscribers will be synchronised automatically by message_filters. You will not have two callbacks, but only one. In that single callback, you'll decode both the depth and the rgb image pair that have the same timestamp.

Do you want to make sure that you're using two timestamp-matched messages (ie: depth and rgb), or are you more concerned with "optimal" processor utilisation?

gvdhoorn gravatar image gvdhoorn  ( 2019-03-22 05:24:13 -0600 )edit

If I use 'message_filters', in its callback it will lets say first decode 'rgb' and then it will decode 'depth'. In this case processing time would be the sum of both decoding. And I wont be able to utilise the time gap between 'rgb' msg & 'depth' msg. i.e., the 10-4 = 6ms. I hope you got what I mean, and please correct me if I am wrong..

JeyP4 gravatar image JeyP4  ( 2019-03-22 09:51:37 -0600 )edit

If you really want to decode rgb in the time that you're waiting for the depth image then message_filters will not allow you to do that.

You'd have to implement the synchronisation yourself.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-22 11:48:49 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-03-21 13:12:37 -0600

Seen: 172 times

Last updated: Mar 22 '19