Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello, instead of creating three separate launch files for each of your models, you might want to create a .world file containing all your models and then use a single .launch to start the simulation Please refer to the "creating a custom world file" part of this tutorial for more information.

Basically, your .world file can be something like this:

<?xml version="1.0" ?>
<sdf version="1.4">
<world name="default">
<include>
<uri>model://person_standing</uri>
  <name>person_standing</name>
  <pose>5 7 0 0 0 0</pose>
</include>  
</world>
</sdf>

Then create a launch file to start the simulation as well as spawn any custom models using the spawn_model method. Something like this:

 <launch>

  <!-- This launch file launches a world as described in the .world file. It then spawns a custom robot model -->


 <!-- Generate the world based on the empty world and change only the below-mentioned arguments -->

 <include file="$(find gazebo_ros)/launch/empty_world.launch">

<arg name="world_name" value="$(find pkg_name)/worlds/custom_world.world"/>
<arg name="paused" value="true"/>
<arg name="use_sim_time" value="true"/>
<arg name="gui" value="true"/>
<arg name="recording" value="false"/>
<arg name="debug" value="false"/>
</include>

<!-- Spawn a custom model into Gazebo -->  
<param name="robot_description" command="cat '$(find pkg_name)/urdf/model_name.urdf'"/>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" output="screen" args="-urdf -param robot_description -x 0 -y 0 -z 0 -model test_robot"/>

</launch>

Hello, instead of creating three separate launch files for each of your models, you might want to create a .world file containing all your models and then use a single .launch to start the simulation Please refer to the "creating a custom world file" part of this tutorial for more information.

Basically, your .world file can be something like this:

<?xml version="1.0" ?>
<sdf version="1.4">
<world name="default">
<include>
<uri>model://person_standing</uri>
  <name>person_standing</name>
  <pose>5 7 0 0 0 0</pose>
</include>  
</world>
</sdf>

Then create a launch file to start the simulation as well as spawn any custom models using the spawn_model method. Something like this:

 <launch>

  <!-- This launch file launches a world as described in the .world file. It then spawns a custom robot model -->


 <!-- Generate the world based on the empty world and change only the below-mentioned arguments -->

 <include file="$(find gazebo_ros)/launch/empty_world.launch">

<arg name="world_name" value="$(find pkg_name)/worlds/custom_world.world"/>
<arg name="paused" value="true"/>
<arg name="use_sim_time" value="true"/>
<arg name="gui" value="true"/>
<arg name="recording" value="false"/>
<arg name="debug" value="false"/>
</include>

<!-- Spawn a custom model into Gazebo -->  
<param name="robot_description" command="cat '$(find pkg_name)/urdf/model_name.urdf'"/>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" output="screen" args="-urdf -param robot_description -x 0 -y 0 -z 0 -model test_robot"/>

 </launch>

</launch>