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

ROS Message Best Practices

asked 2017-04-10 09:55:02 -0500

Laxnpander gravatar image

Hey there guys,

I am quite new to ROS and have not been involved in bigger projects. However I am confronted with creating one on my own. Working through the tutorials and some literature some of my biggest questions are nowhere to be answered, or at least I don't know how to find them. They are basic (best practice) questions, hopefully you are not too annoyed to answer them :)

I am dealing with a lot of images. A node that is processing an image and adds a slice of information to it (like depth or pose), will I define a new message including the image and the additional informations? Or will I define a message, publishing the additional informations and recombine "image + additional data" in an subsequent node?

First way sounds wrong because of duplicated data, second way sounds annoying by always checking if message id of image is matching the corresponding id of the additional data. Do I miss a basic ros principle?

Thansk for your answer in advance, beste regards


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-10 15:16:20 -0500

NEngelhard gravatar image

I assume that you send a sensor_msgs/Image. In this case you could publish your additional information with (exactly) this timestamp and use a message_filter with the ExactTime Policy (7.2) in your subscriber. You then get a combined callback for your image and your additional data. The message_filter looks at the timestamps in the header (not the time when the message was received!) so that it's no problem if your processing takes some time. [I'm not quite sure if the ExactTimePolicy has a buffer so you should check if your processing is fast enough to keep up with the images. But at least you won't get wrong matches]

edit flag offensive delete link more


Hey, great answer thank you! Haven't heard of filters before, this might solve some problems. Is this the Standard way? Time divergence might be a Problem, my images passing through a visual slam. But I will try it, thanks again!

Laxnpander gravatar image Laxnpander  ( 2017-04-12 01:55:58 -0500 )edit

Yes, it's used fairly often. If the time stamps vary slightly, there is also an approximate time filter available.

joq gravatar image joq  ( 2017-04-12 13:21:14 -0500 )edit

Question Tools

1 follower


Asked: 2017-04-10 09:55:02 -0500

Seen: 388 times

Last updated: Apr 10 '17