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

Subscribing and Publishing in the same node - Comparisson

asked 2014-02-05 03:13:57 -0500

Edno gravatar image

I have written a node, with the roscpp client, that subscribes to an image topic, and than publishes to another image topic. It takes a raw image from the webcam, and then thresholds it and publish it. I have made it through two different ways.

The first one i used global variables (kind of ugly), In the second way, i made a class, which is a cleaner way. Howerver, the publish rate in the second way is slow.

the first way i called limiter1, the second limiter2.

the limiter1 node, publishes the images at a really good average, using rostopic hz the average gives me the 30hz i would expect.

the limiter2 on the other hand, publishes at a maximum of 15hz. Is this right?, i am not an expert, so is it known that using classes will decrease the efficiency? and why so much?

I do not believe that the algorithms i am using are slow (using opencv), i used the same algorithms(algorithms for the processing of the image) in both cases. If i do not use the ros::Rate::sleep function on the limiter1 node, for example, the publish rate goes to 600hz and more.

thanks for any help, if someone wishes to see the codes, i will post the two ones.

edit retag flag offensive close merge delete

Comments

1

For better feedback you might consider to share the code e.g. in a GitHub repo.

Dirk Thomas gravatar image Dirk Thomas  ( 2014-02-05 05:55:13 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-02-06 13:37:16 -0500

Edno gravatar image

I've found out that the problem is not in the way i write the code. The problem is residing in the "grabber node". It is a node that grabs a frame from the web cam and then publishes it. It is publishing at a rate of 15hz. The same happens if i use gscam, it also publishes at 15hz. Could this be something wrong with the embedded webcam in my notebook? . Using guvcview i can se that its FPS is 30. the video flow does not seem to be low, could ros be calculating it wrong? i don't know what is happening here. Even it the flow seems right, and even if i can do what i would like with it, i don't want to lose these frames. Any idea?

edit flag offensive delete link more
0

answered 2014-02-05 04:32:15 -0500

dornhege gravatar image

Are you publishing the same topic to yourself in the same node?

In that case - especially as you are dealing with possibly large image data - the bottleneck might be serialization/deserialization that happens all the time. If you pass (publish/subscribe) data as a shared_ptr this does not happen as a special case, see intraprocess publishing.

The generalization of this would be to use nodelets.

edit flag offensive delete link more

Comments

No, at the time i was publishing to a visualizer.

Edno gravatar image Edno  ( 2014-02-05 08:41:15 -0500 )edit

So, if in both cases you do the same publish calls from ROS, it might not be a ROS problem at all. Maybe you are just copying the data yourself.

dornhege gravatar image dornhege  ( 2014-02-05 22:44:10 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2014-02-05 03:13:57 -0500

Seen: 325 times

Last updated: Feb 06 '14