Subscribing to a non-existing topic
Hi,
Is it possible for a node to subscribe to a topic which doesn't exist yet? This would be useful if the node publishing on this topic has to be started after the listener.
To put this into context, I have three nodes (A, B, C) and two topics (T1 and T2). Node A publishes on T1. Node B subscribes to T1 and publishes on T2. Finally, Node C only subscribes on T2.
As I have experienced, I must run node A before node B as B will not be able to subscribe on T1 because it doesn't exist until some node publishes on it. The same happens for B and C and therefore I must run the nodes in the proper order (A then B then C). This is not a problem in my case, but if there was a third topic (T3) on which C would publish and A would listen, that would create a problem.
There must be a cleaner way to solve this problem but I haven't found one in ROS documentation yet. Any idea?
Thanks!
Update: reinitializing roscore solved the problem. I'm not sure what was the cause of the problem, though.
By the way, I am using rospy.