Running multiple Gazebo simulations on one ROS core
Is it possible to run multiple Gazebo simulation with one ROS core and be able to interact with all the simulation (read and sent messages)?
If so, what is needed in order for this to work?
EDIT 1
I have manage to run two simulation by putting
export GAZEBO_MASTER_URI=http://localhost:11346;
before launching the second simulation and launching each simulation in different group.
<?xml version="1.0"?>
<launch>
<!-- define arguments -->
...
<!-- startup gazebo WORLD -->
...
<group ns="$(arg group_name)">
<param name="robot_description"
command="$(find xacro)/xacro --inorder '$(find robot_gazebo)/launch/upload_robot.xacro'" />
<node name="urdf_spawner_$(arg group_name)" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
args="-urdf -model robot_$(arg group_name) -param robot_description -x $(arg robot_x) -y $(arg robot_y) -z $(arg robot_z)"/>
<include file="$(find robot_control)/launch/$(arg group_name)_control.launch" if="$(eval control)" >
</include>
</group>
</launch>
I need to use the same model. To be sure I made duplicate model and named it according to the group name. I have made separate control launches for both models and set the gazebo_ros_control controllers into different namespaces.
When I launch the first simulation, it loads as normally and all the controllers loads. As soon as I run the second simulation, however, the controllers case to exist in topic list and only 3 controller topics out of 8 expected appears on rostopic list for the second robot: the 2nd_robot/joint_states
and 2nd_robot/left_wheel/command
and 2nd_robot/right_wheel/command
(EDIT 3: This number of topics for the second robot is actually right, because I'm using the VelocityJointInterface). Only 1st_robot/joint_states
remains for the first robot.
So I have two simulations running with a robot loaded, but I can't control either of the robots (EDIT 3: I can control one of the robot, the second). How do I fix this?
EDIT 2
I have even run each Gazebo simulation on different ROS core using the multimaster-fkie
package, so each Gazebo simulation has different GAZEBO_MASTER_URI and ROS_MASTER_URI, yet the behavior is still the same.
Have you seen this ROS Answer and this repo?
edit: Didn't see that you wanted to run on one ROS Core, so reposting this as comment.
I didn't see it, and this is almost exactly how I ended up launching the two ROS cores. Just your link to repos is wrong, please fix it. It will be useful for others.
Whoops, good catch. Can't edit past 10 minutes, so here's the relevant repo: https://github.com/alidemir1/RosGazeb...