The environment we talked about earlier is saved as a Gazebo world file called postoffice.world. You can visualize this world by copying this file into your workspace and opening Gazebo (assuming you open it from the same Terminal where the file is downloaded or copied) with this world file using the following command:
$ gazebo postoffice.world
Since we're going to concentrate on the application from now on, let's set the environment for this chapter:
- Create a new workspace and add the robot files we created in Chapter 3, Building an Industrial Mobile Manipulator, to it:
$ initros1
$ mkdir -p chapter_5_ws/src
$ cd ~/chapter_5_ws/src
$ catkin_init_workspace
$ cp -r ~/chapter_3_ws/src/robot_description ~/chapter_5_ws/src/
$ cd ~/chapter_5_ws
$ catkin_make
- Now, let's create a folder called worlds in the robot_description package and save our world file there:
$ cd ~/chapter_5_ws/src/robot_description/
$ mkdir worlds
Copy the downloaded world into the preceding folder.
- Now, let's modify the world file in our mobile_manipulator_gazebo_xacro.launch file to add the preceding world file as an argument:
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="home/robot/chapter_5_ws/src/robot_description/worlds/postoffice.world"/>
</include>
Try launching the robot. You will see that the robot is positioned in our new environment. The robot is currently positioned at the (0, 0) coordinates of the world file. If we wish to change the position of the robot, we need to add the following additional arguments to the <node> tag in the mobile_manipulator_gazebo_xacro.launch file:
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -x 1 -y 2 -z 1 -model mobile_manipulator" />
The preceding code would set the robot position (x, y, z) to (1, 2, 1). Now that the environment is set, let's learn how to modify the robot.