Better way for many-to-many robot communication
Hi everyone.
I am using ROS-Gazebo in my project for simulating natural swarming behaviour. I used publish/subscribe topic as a manner for simulating inter-robot communication. I feel okay for one-to-many message broadcast through publishing topic. However, I am confused about how to achieve many-to-one message reception. More specifically, I am wondering how to let one robot receive many messages through rostopic system. I cannot create one callback function for each message. In my case, it could be even 20~30 robots in simulation. Except for creating20~30 callback functions in each robot's controller, does anyone have any better idea for achieving this multi-message reception in one robot.
BTW, messages from all robots follow the same structure. I appreciate any information from you.
Jason
If messages from all robots have the same structure, they have the same type, like for example
std_msgs/String
?You could use the same callback for any topic that publishes messages of a specific type.
Thanks Ruben. Actually, even though each topic use the same data structure, it needs some specific compution for the data. I am trying to add some parameters to callback function to achieve it. I found boost::bind could be a possible solution. I am trying that.