Running multiple instances of same node
Hi everybody. I'm slightly new to Ros so I'm sorry for any mistake in terminology or logic I will do while asking. My problem is that I've written a node that communicates with Vrep (a robot simulator) publishing some positions to a topic to which Vrep is subscribed (goal positions that the robot is following), it is also subscribed to a topic which is published by Vrep that publishes the current position of the robot.
What i want to do is to run multiple instances of this node with different topic names so to control multiple robots, but I can't figure out which is the best solution. The thing is that I also want to dynamically generate the needed number of nodes, and give as arguments to the nodes the name of the topics to which they have to subscribe/publish. Is this possible?
The only solutions I found out so far are:
- Create multiple .cpp files with the topic names hardcoded in them, one for every robot I want to control. (NOT Dynamic)
- Create multiple nodes inside a single main with appropriate callback functions defined for every robot. (Seems messy, still NOT Dynamic)
Thanks in advance.