Tutorials/1.9/Installing gazebo ros Packages

The set of ROS packages for interfacing with Gazebo are contained within a new meta package (catkin's version of stacks) named gazebo_ros_pkgs. See Overview of new ROS integration for background information before continuing here.

These instructions are for using the latest stand-alone version of Gazebo (version 1.9) with ROS Hydro using catkin. ROS Groovy is somewhat compatible with gazebo_ros_pkgs but requires more of the components be installed from source and is not an official target of gazebo_ros_pkgs.


 * 1) Prerequisites

You should understand the basic concepts of ROS and have gone through the ROS Tutorials.

We recommend for these ROS integration tutorials you install ros-hydro-desktop-full so that you have all the necessary packages.
 * 1) Install ROS

See the ROS installation page for more details. Be sure to source your ROS setup.bash script by following the instructions on the ROS installation page.


 * 1) Remove ROS's Old Version of Gazebo ROS Integration

If you have previously installed ROS's version of Gazebo through the ROS debians, remove them now by running either of these:

sudo apt-get remove ros-fuerte-simulator-gazebo ros-groovy-simulator-gazebo


 * 1) Install Gazebo

You can install Gazebo either from source or from pre-build Ubuntu debians.

See Install Gazebo 1.9. If installing from source, be sure to build the gazebo_1.9 branch.


 * 1) Test that stand-alone Gazebo works

Before attempting to install the gazebo_ros_pkgs, make sure the stand-alone Gazebo works by running in terminal:

gazebo

You should see the GUI open with an empty world. Also, test adding a model by clicking on the "Insert" tab on the left and selecting a model to add (then clicking on the simulation to select where to place the model).


 * 1) Test that you have the right version of Gazebo

To see where you install Gazebo, and if it is in the correct location, run:

which gzserver which gzclient

If you installed from source to the default location it should say: /usr/local/bin/gzserver /usr/local/bin/gzclient

If you installed from debian it should say: /usr/bin/gzserver /usr/bin/gzclient


 * 1) Install gazebo_ros_pkgs

Choose the method you would prefer. Installing from source means you can more easily debug and submit bug patches ;-)


 * 1) Install Pre-Built Debians

The gazebo_ros_pkgs are available in ROS Hydro as debians for Ubuntu. To install, first ensure you have ROS Hydro properly setup with ROS's package repository and key. Then:

sudo apt-get install ros-hydro-gazebo-ros-pkgs ros-hydro-gazebo-ros-control

If this installation method worked for you, jump to the next step.


 * 1) Install from Source (on Ubuntu)

If you are running an earlier version of ROS (Groovy, Fuerte, Electric) you will need to install gazebo_ros_pkgs from source. Installing from source is also useful if you want to develop new plugins or submit patches.


 * 1) Setup A Catkin Workspace

These instructions require the use of the catkin build system.

If you do not have a catkin workspace setup, try the following commands:

mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src catkin_init_workspace cd ~/catkin_ws catkin_make

Then add to your .bashrc file a source to the setup scripts:

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

For more details see the Create A Catkin Workspace tutorial.


 * 1) Clone the Github Repositories

Make sure git is installed on your Ubuntu machine

sudo apt-get install git

Choose the ROS distro you are targeting:


 * 1) ROS Hydro

sudo apt-get install -y gazebo

Download the source code from the gazebo_ros_pkgs Github repo: cd ~/catkin_ws/src git clone https://github.com/ros-simulation/gazebo_ros_pkgs.git

You are highly encouraged to fork our code and submit a pull request if you find fixes or features that you'd like to add.

Check for any missing dependencies using rosdep: rosdep update rosdep check --from-paths. --ignore-src --rosdistro hydro

You can automatically install the missing dependencies using rosdep via debian install: rosdep install --from-paths. --ignore-src --rosdistro hydro -y

Now jump to the build step.


 * 1) ROS Groovy

ROS Groovy and earlier distros are not officially supported but maintenance support is available for Groovy.

Download the source code from the gazebo_ros_pkgs Github repo: cd ~/catkin_ws/src git clone https://github.com/ros-simulation/gazebo_ros_pkgs.git

''Note: the groovy-devel branch has been deleted because the breaking API changes in PCL have been resolved. The hydro-devel branch now works with Groovy.''

You are highly encouraged to fork our code and submit a pull request if you find fixes or features that you'd like to add.

You will also need the ros_control and ros_controllers packages installed on your system from source - they are new in ROS Hydro. If you do not already have these, install them from source:

git clone https://github.com/ros-controls/ros_control.git git clone https://github.com/ros-controls/ros_controllers.git -b groovy-backported-hydro git clone https://github.com/ros-controls/control_toolbox.git git clone https://github.com/ros-controls/realtime_tools.git

Check for any missing dependencies using rosdep: rosdep update rosdep check --from-paths. --ignore-src --rosdistro groovy

You can automatically install the missing dependencies using rosdep via debian install: rosdep install --from-paths. --ignore-src --rosdistro groovy -y


 * 1) Build the gazebo_ros_pkgs

To build the Gazebo ROS integration packages, run the following commands:

cd ~/catkin_ws/ catkin_make

See answers.gazebosim.org for issues or questions with building these packages.

Be sure to always source the appropriate ROS setup file, which for Hydro is done like so:
 * 1) Testing Gazebo with ROS Integration

source /opt/ros/hydro/setup.bash

You might want to add that line to your `~/.bashrc`.

Assuming your ROS and Gazebo environment have been properly setup and built, you should now be able to run Gazebo through a simple rosrun command, after launching roscore if needed:

Source the catkin setup.bash if it's not already in your .bashrc

source ~/catkin_ws/devel/setup.bash

roscore & rosrun gazebo_ros gazebo

The Gazebo GUI should appear with nothing inside the viewing window.



To verify that the proper ROS connections are setup, view the available ROS topics:

rostopic list

You should see within the lists topics such as:

/gazebo/link_states /gazebo/model_states /gazebo/parameter_descriptions /gazebo/parameter_updates /gazebo/set_link_state /gazebo/set_model_state

You can also verify the Gazebo services exist:

rosservice list

You should see within the list services such as:

/gazebo/apply_body_wrench /gazebo/apply_joint_effort /gazebo/clear_body_wrenches /gazebo/clear_joint_forces /gazebo/delete_model /gazebo/get_joint_properties /gazebo/get_link_properties /gazebo/get_link_state /gazebo/get_loggers /gazebo/get_model_properties /gazebo/get_model_state /gazebo/get_physics_properties /gazebo/get_world_properties /gazebo/pause_physics /gazebo/reset_simulation /gazebo/reset_world /gazebo/set_joint_properties /gazebo/set_link_properties /gazebo/set_link_state /gazebo/set_logger_level /gazebo/set_model_configuration /gazebo/set_model_state /gazebo/set_parameters /gazebo/set_physics_properties /gazebo/spawn_gazebo_model /gazebo/spawn_sdf_model /gazebo/spawn_urdf_model /gazebo/unpause_physics /rosout/get_loggers /rosout/set_logger_level


 * 1) Other ROS Ways To Start Gazebo

There are several rosrun commands for starting Gazebo:
 * rosrun gazebo_ros gazebo : Launched both the server and client together
 * rosrun gazebo_ros gzserver : Launches the Gazebo server only
 * rosrun gazebo_ros gzclient : Launches the Gazebo client only
 * rosrun gazebo_ros debug : Launches the Gazebo server only, in debug mode using GDB

Additionally, you can start Gazebo using roslaunch


 * 1) Next Steps

You are now ready to launch robot models (URDFs) into Gazebo demo worlds in the tutorial Using roslaunch Files to Spawn Models.