Hi all, I'm trying to run multiple independent Gazebo-ROS instances on the same machine so two or more remotely connected users can use it at the same time. I've read this answer about multiple ros masters and this one about multiple Gazebo instances.I've been following them with no success.
I've tried running two ros masters on different ports and launch a gazebo empty_world.launch on each one with different group namespaces as follows:
terminal 1: Run the first ros master: roscore -p 11312
terminal 2: Run test_A.launch: Where test_A.launch is the same as gazebo_ros empty_world.launch but adding a group ns="ns_A" and changing the node names as follows:
<launch>
<!-- these are the arguments you can pass this launch file, for example paused:=true -->
<arg name="paused" default="false"/>
<arg name="use_sim_time" default="true"/>
<arg name="gui" default="true"/>
<arg name="headless" default="false"/>
<arg name="debug" default="false"/>
<arg name="verbose" default="false"/>
<arg name="world_name" default="worlds/empty.world"/> <!-- Note: the world_name is with respect to GAZEBO_RESOURCE_PATH environmental variable -->
<!-- set use_sim_time flag -->
<group if="$(arg use_sim_time)">
<param name="/use_sim_time" value="true" />
</group>
<!-- set command arguments -->
<arg unless="$(arg paused)" name="command_arg1" value=""/>
<arg if="$(arg paused)" name="command_arg1" value="-u"/>
<arg unless="$(arg headless)" name="command_arg2" value=""/>
<arg if="$(arg headless)" name="command_arg2" value="-r"/>
<arg unless="$(arg verbose)" name="command_arg3" value=""/>
<arg if="$(arg verbose)" name="command_arg3" value="--verbose"/>
<arg unless="$(arg debug)" name="script_type" value="gzserver"/>
<arg if="$(arg debug)" name="script_type" value="debug"/>
<group ns="ns_A">
<!-- start gazebo server-->
<node name="gazebo_A" pkg="gazebo_ros" type="gzserver" respawn="false" output="screen"
args="$(arg command_arg1) $(arg command_arg2) $(arg command_arg3) $(arg world_name)" />
<!-- start gazebo client -->
<node name="gazebo_gui_A" pkg="gazebo_ros" type="gzclient" respawn="false" output="screen"></node>
</group>
</launch>
terminal 3: Run the second ros master: roscore -p 11313
terminal 4: Run test_B.launch: Where test_B.launch is the same as gazebo_ros empty_world.launch but adding a group ns="ns_B" and changing the node names as follows:
<launch>
<!-- these are the arguments you can pass this launch file, for example paused:=true -->
<arg name="paused" default="false"/>
<arg name="use_sim_time" default="true"/>
<arg name="gui" default="true"/>
<arg name="headless" default="false"/>
<arg name="debug" default="false"/>
<arg name="verbose" default="false"/>
<arg name="world_name" default="worlds/empty.world"/> <!-- Note: the world_name is with respect to GAZEBO_RESOURCE_PATH environmental variable -->
<!-- set use_sim_time flag -->
<group if="$(arg use_sim_time)">
<param name="/use_sim_time" value="true" />
</group>
<!-- set command arguments -->
<arg unless="$(arg paused)" name="command_arg1" value=""/>
<arg if="$(arg paused)" name="command_arg1" value="-u"/>
<arg unless="$(arg headless)" name="command_arg2" value=""/>
<arg if="$(arg headless)" name="command_arg2" value="-r"/>
<arg unless="$(arg verbose)" name="command_arg3" value=""/>
<arg if="$(arg verbose)" name="command_arg3" value="--verbose"/>
<arg unless="$(arg debug)" name="script_type" value="gzserver"/>
<arg if="$(arg debug)" name="script_type" value="debug"/>
<group ns="ns_B">
<!-- start gazebo server-->
<node name="gazebo_B" pkg="gazebo_ros" type="gzserver" respawn="false" output="screen"
args="$(arg command_arg1) $(arg command_arg2) $(arg command_arg3) $(arg world_name)" />
<!-- start gazebo client -->
<node name="gazebo_gui_B" pkg="gazebo_ros" type="gzclient" respawn="false" output="screen"></node>
</group>
</launch>
When I execute all this I get one instance of Gazebo running, in which I insert a box. Then, when I launch the second instance (test_B.launch) I get a new Gazebo window in which I see the box inserted on the first. In other words, as I understand it, I got another client connected to the same server, even running from different ros masters. This is the exception the second instance trows:
Exception [Master.cc:50] Unable to start server[Address already in use]. There is probably another Gazebo process running.
¿Has anyone been able to do this? ¿Can you spot any error? I'm using ROS Hydro on Ubuntu 12.04 LTS.
Thank you in advance for your help.
Originally posted by Sergio MP on ROS Answers with karma: 182 on 2014-09-19
Post score: 3