Subscribing to a topic whenever it publishes without affecting the execution of program
Hello,
I'm writing a project with C++ in ROS indigo installed in Ubuntu.
In my project, I do some processes in one node and publish the result data and in an other node, want to subscribe to this data and use it in order to do further works. My problem is that, the first node currently works much more slower than the second node. The result is that the second node waits for the data publishing by the first one. I want to write the second node in a way that it continue working with the last data received and whenever a new data published, use the new one.
I tried to use subscribe and callback method described in ROS tutorials, but the program waits for publishing the data from first node.
Any idea to manage it?
Thanks.
If the second node doesn't have any data from the first node, what work can it do? In any case, you can place the task to be done outside the callback method. That should allow a process to run independent of the subscription. The rate of that process can be controlled using ros spin
Thanks for your answer. I think you mean the way that proposed by PeterBlackerThe3rd. As I commented there, it does not work.