ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
It seems ( see the comments of the question ) that your real issue is about managing messages.
I will answer each of your points :
Initially I was trying to run only this code, so it was not calling callback. But when I wrote a Publisher file separately & tried to subscribe it, It worked. So now I have merged both the files & this is what I found when I first wrote publisher & then subscribe it dint work, but vice-versa worked
I must say that i didn't really understood this.
Is it necessary to subscribe first ??
Yes, this is the way "messages_filter" works : 1/ You subscribe to existing topics 2/ You sync them with your desired policy 3/ You can write a callback with your multiple message as arguments. Callback in which you do whatever you want.
My actual intension is to call a callback & publish from the callback function. Is this possible using Approximate Time policy??
I just want to say that this question (and the previous one) show that you have some trouble understanding how ROS globally works, we have all been there but you may want to read once more the tutorials ;)
So yes you can publish from the callback function, you can do nearly everything from the callbacl function. One classic ROS node architecture is to have a very small main in which you just create a class element and then you ros::spin. In the class there will be the creation of one or multiples subscriber(s) and everything the node is doing is computed in the callbacks. This way of doing things link an action to a message reception. For exemple, each time you have an image you lanuch your image processing treatment. Or each time you receive your odometry, you update your robot position in your node .....