Subscribing and Publishing in the same node - Comparisson
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.
For better feedback you might consider to share the code e.g. in a GitHub repo.