Setting up the environment in Gazebo

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
Gazebo might take a while to load all of the necessary models from the internet, due to which it may take time to launch. Hence, provide around 10 minutes of settling time once the preceding command has been entered.

Since we're going to concentrate on the application from now on, let's set the environment for this chapter:

  1. Create a new workspace and add the robot files we created in Chapter 3Building 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
  1. 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.

  1. 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.30.162