建立新環境 - tychien/gazebo_tutorial_zh GitHub Wiki
make sure you have installed the gazebo_ros package.
$ cd $HOME/catkin_ws/src
$ catkin_create_pkg my_simulations
$ mkdir launch world
$ cd launch
$ vim my_world.launch
In the my_world.launch :
<?xml version="1.0" encoding="UTF-8"?> <!--#defining a XML file-->
<launch> <!--open a tag called launch because this is also a launch file for ROS-->
<!-- overwriting these args --> <!--define some arguments-->
<arg name="debug" default="false" />
<arg name="gui" default="true"/>
<arg name="pause" default="true"/> <!--the simulation is going to start it paused-->
<arg name="world" default="$(find my_simulations)/world/empty_world.world" /> <!--define the world name look into our my_simulations package-->
<!-- include gazebo_ros launcher -->
<include file="$(find gazebo_ros)/launch/empty_world.launch"> <!--include this launch file from gazebo_ros package-->
<arg name="world_name" value="$(arg world)"/> <!--use the arguments that we have defined before-->
<arg name="debug" value="$(arg debug)" />
<arg name="gui" value="$(arg gui)" />
<arg name="paused" value="$(arg pause)"/>
<arg name="use_sim_time" value="true"/> <!--all the other ROS nodes are going to use the simulation time as reference.-->
</include>
</launch>
Save your file :wq
$ cd ..
$ cd world
$ vim empty_world.world
in your empty_world.world
<?xml version="1.0" ?> <!--we are defining a xml file-->
<sdf version="1.5">
<world name="default">
<!-- A global light source -->
<include> <!--include some models like sun plane -->
<uri>model://sun</uri>
</include>
<!-- A ground plane -->
<include>
<uri>model://ground_plane</uri>
</include>
</world>
</sdf>
Save your file and quit :wq
then launch it!
$ roslaunch my_simulations my_world.launch