Can this package be used to tell a rosmaster to communicate only with one gazebo simualtion so that I can have more simulations in total with different rosmasters?
Yes.
The Multimaster-FKIE package connects the different ROS masters, checks for the activity on the master and copies all the messages it finds to all of the connected ROS Masters (connects nodes of the different ROS masters based on the topics they subscribe or publish to). The Multimaster-FKIE package provides an ignore list where you can specify the topics or the nodes that are not to be connected with other ROS masters.
By default the [/rosout, "/master_sync node", "remote /master_discovery node", "/node_manager", /zeroconf] nodes and the ['/rosout', '/rosout_agg'] topics are ignored. But you can add your own on top of that.
I have successfully run two simulations on two different ROS masters by adding the ['/gazebo','/tf','/clock'] topics into the ~ignore_topics list.
Here are some notes I wrote for myself when exploring the Multimaster-FKIE package:
Running Multiple Simulations Using Multiple ROS-Masters
multimaster-FKIE package
The multimaster-FKIE package provides two main nodes
master_discovery
master_sync
The master_discovery
node broadcasts the messages over the network and scans the network for broadcasts of other master_discovery
nodes. It then publishes the communication of other master_discovery
nodes to its own ROS-Master. The master_sync
connects to the discovered master_discovery
nodes and requests the actual ROS state and registers the topics and services of the other ROS-Master.
It is possible to set whether to synchronize or ingore for each node, topic or service. This way certain topics or nodes can be private for the ROS-Master and will not be communicated to the other ROS-Masters.
source:ros.wiki.org
Simulation A and B example
There are two ROS-Masters running at different ports (11311 and 11312). Both ROS-Masters run a master_discovery
node and a master_sync
node. The /gazebo
, /gazebo_gui
, /tf
and clock
topics are set private for each ROS-Master.
The Gazebo simulation A is launched at the port 11345 and connected to the ROS-Master at the port 11311.
The Gazebo simulation B is launched at the port 11346 and connected to the ROS-Master at the port 11312.
How to install
install multimaster-fkie
sudo apt-get install ros-kinetic-multimaster-fkie
check if multicast allowed
cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
if output 0, multicast is allowed
allow multicast temporarily
sudo sh -c "echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts"
allow multicast permanently
edit the /etc/sysctl.conf
and add following line
net.ipv4.icmp_echo_ignore_broadcasts=0
and execute command
sudo service procps restart
Check which multicast groups are defined in a computer
netstat -g
Running The Simulations A and B
First terminal
tab 1
roscore
tab 2
find the group
netstat -g
run the master_discovery
rosrun master_discovery_fkie master_discovery _mcast_group:=224.0.0.251
tab 3
run master_sync
rosrun master_sync_fkie master_sync _ignore_nodes:=['/gazebo*','/tf*','/clock'] _ignore_topics:=['/gazebo*','/tf*','/clock']
Here the ignore nodes might be redundant but I didn't want to take chances. You can experiment.
tab 4 and more
source ~/catkin_ws/devel/setup.bash
Run Simulation ... (more)