Introduce intermediate node programmatically?
Hi there,
I'm fairly new to ROS and I'm exploring the possibilities and I have come up with a scenario that I have not quite figured out if it is possible.
Consider a situation where you have two nodes: a publisher (my_publisher) and a subscriber (my_subscriber). I want to be able to control the communication between those two nodes (use-cases could be for logging but also for cutting the communication all together). My solution proposal is to introduce an "intermediate" node that could relay the communication and using the remapping functionality in launch files to redirect the subscriber to the new topic.
The transformation is displayed as followed:
This is not a problem if you manually create a node but lets say you have many nodes and don't want to manually add the topic to the intermediate node, then you would do this programmatically. I have looked at the getPublishedTopics method from the Master API ( http://wiki.ros.org/ROS/Master_API ) - it does return the name of the topic but the topic message type is also returned as a string however I need a reference to the class in order to publish a new topic. Is there a way to get that or can the goal be achieved in an entirely other way?
Thanks,
Just a comment: you mention 'logging' as being one use-case for why runtime rewiring could be used. That is true, but in a pub/sub system really not required. Pub/sub relations between nodes are not p2p channels, where only one publisher and one subscriber can see the data, all subscribers ..
.. can see the same data. Logging should then be as simple as creating a subscriber that writes out incoming msgs to disk. In fact, this is how rosbag works.
@gvdhoorn - That's right, logging might not be the best example as a use-case. I'm more generally interested in controlling the communication between the two nodes. Lets say I want to filter out some messages based on the values in them ; the ability to entire block communication is what going for.
Afaik, such node graph orchestration is not possible right now. Nodes control their subscriptions, not an outside system. Remapping is also an 'off-line' affair (ie: not something that can be changed after the configuration phase). But let's see what others can come up with.