Annex 3: Gazebo 3D simulator

Gazebo GUI

Up until now we have been using the ArbotiX fake simulator to test our ROS nodes before trying things out on a real robot.

The fake simulator is fast and easy to use but it has its limitations:

  • For one thing, it does not simulate the actual physics (e.g. inertia, force, damping, friction, etc), nor does it provide a way to simulate objects in the world.
  • Sometimes we would also like to simulate the data returned from sensors such as a laser scanner or depth camera as the robot moves around a simulated environment.

Enter Gazebo, the sophisticated open source 3D simulator originally developed by Nate Koenig and Andrew Howard in 2002 as part of the Player project founded by Brian Gerkey, Richard Vaughan and Andrew Howard at the University of Southern California at Los Angeles. In 2011, Gazebo became an independent project under Willow Garage where it played an integral role in the development of ROS and the PR2 robot.

Gazebo is now actively developed by the Open Source Robotics Foundation (OSRF) where Gerkey and Koenig serve as CEO and CTO respectively.

Gazebo not only provides a state-of-the-art physics engine, it also enables the creation of complex 3-dimensional virtual environments (called "worlds") for a simulated robot to play around in. If someone has created a fully configured Gazebo model of the robot we are interested in, then we can test a number of real-world properties such as the robot's momentum and inertia when trying to stop or accelerate, or the friction between a gripper and an object being grasped.

We can also test bump sensors when running into things, cliff sensors when nearing an edge, or even perform a full blown SLAM experiment with a simulated laser to create a map of the robot's simulated environment. Gazebo can also be used to prototype a new robot before it is even built, or learn how to operate a virtual copy of an expensive robot.

Installing Gazebo

sudo apt-get install ros-indigo-gazebo-ros \
ros-indigo-gazebo-ros-pkgs ros-indigo-gazebo-msgs \
ros-indigo-gazebo-plugins ros-indigo-gazebo-ros-control

Also install the required dependencies:

sudo apt-get install ros-indigo-control-toolbox

Turn on graphics acceleration:

unset LIBGL_ALWAYS_SOFTWARE

Or turn off hardware acceleration if problems arise:

export LIBGL_ALWAYS_SOFTWARE=1

Start server after installation:

gzserver

Start the client in another terminal:

gzclient

Close the two terminals and START SERVER AND CLIENT TOGETHER:

gazebo

Launch GAZEBO with an empty world:

roslaunch gazebo_ros empty_world.launch

Install the Kobuki ROS Packages:

sudo apt-get install ros-indigo-kobuki-*
sudo apt-get install ros-indigo-grasping-msgs ros-indigo-moveit-python
git clone https://github.com/pirobot/ubr1_preview
cd ~/catkin_ws
catkin_make

 

When the GUI window appears, click on the Insert tab and wait until the connection to the online database is complete. You should then be able to open the list of models under the section labeled http://gazebosim.org/models and select the Cinder Block:

INSERT → Cinder block

After selecting the Cinder Block, move the mouse anywhere into the empty scene and the block will appear under the cursor. Click the left mouse to place the block into the scene.

Note how the Cinder Block now also appears under the cached models listed under /home/yourname/.gazebo/models on the Insert tab. This confirms that the model is now locally available and will be loaded automatically by any world that requires it later
on.

Testing the Kobuki Robot in Gazebo

The Kobuki Gazebo package comes with a world that includes a collection of tables with the robot and a number of cinder blocks sitting on top. To bring up Gazebo with the Kobuki and this world terminate any running Gazebo instances and run the following launch file:

roslaunch kobuki_gazebo kobuki_playground.launch
rostopic list

Move the robot forward at 0.2 meters per second:

rostopic pub -r 10 /mobile_base/commands/velocity \
geometry_msgs/Twist '{linear: {x: 0.2}}'

 

You should see the robot move across the table and fall off the edge where we created the gap. To keep the poor robot from bouncing around on the floor (or driving out of the scene if it landed on its wheels), type Ctrl-C to kill the rostopic command,  and then click on the Edit menu in the Gazebo GUI and select Reset Model Poses.

EDIT → Reset Model Poses