Let’s see how to install Gazebo 9 simulator to work with your ROS system. We are going to see how to replace the default version of Gazebo that comes with the installation of ROS and if previously existing simulations work (or not) with this new version of the simulator.
How to install Gazebo ROS (Gazebo 9) in an existing ROS environment
I presume that you already have a ROS distribution in your system. If you do, you probably installed the version of Gazebo that came by default with that ROS distribution. If you check the documentation of Gazebo, you will see that the following table corresponds to the default versions of Gazebo that automatically install with ROS:
- ROS Indigo: Gazebo 2.x
- ROS Kinetic: Gazebo 7.x
- ROS Lunar: Gazebo 7.x
Let’s see now, how can you proceed to change the default Gazebo version by the newest one (9.x as for 3rd May 2018).
First, uninstall the default Gazebo
If you want to install the latest version, you will have to remove first your default installed Gazebo (which was probably installed when you installed ROS). That is easy, because, independently of the ROS distro, the same command applies to all the distributions to remove the default Gazebo installation:
$ sudo apt-get remove ros-ROS_DISTRO-gazebo* $ sudo apt-get remove libgazebo* $ sudo apt-get remove gazebo*
(replace ROS_DISTRO by your distro name.
After having done the uninstall, no Gazebo files will be in your system, neither the ROS related packages. Let’s now install the new Gazebo 9.
Update the repository
You will need to add the osrfoundation repo to your Linux package system in order to get the new packages of Gazebo.
$ sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" /etc/apt/sources.list.d/gazebo-stable.list' $ wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
Then update the repo of packages:
$ sudo apt-get update
The integration of Gazebo with ROS is performed by means of the series of ros-<ROS_VERSION>-gazebo9 packages. The list of ROS – Gazebo packages that OpenRobotics is usually offering is the following (where in our case, we used ROS_VERSION=kinetic):
Install Gazebo 9
A very simple command will do it:
$ sudo apt-get install ros-kinetic-gazebo9-*
That command will install all dependencies. To test if everything is properly working, just type:
A window like the this should appear on your screen.
[irp posts=”8825″ name=”Launching Husarion ROSbot navigation demo in Gazebo simulation”]
Testing Gazebo with a battery of ROS based simulations
So if you are reading this post is because you are interested in the combo Gazebo / ROS. And your next question should be: will this new version work with our previously working ROS based simulations? The answer to that question is… it depends. It depends for which Gazebo version your simulation was made, and which parts of Gazebo does that simulation use. We have done the following experiments with some of our simulations.
Testing with a robotic arm simulation
Let’s do a simple example: let’s launch a Wam arm robot, which includes several models, a kinect, a laser and an arm robot with joint controllers. The simulation was created for Gazebo 7.x
First, you need to create a catkin_ws:
$ mkdir -p ~/catkin_ws/src $ cd ~/catkin_ws $ catkin_make
You can clone and compile the Wam simulation from The Construct public simulations repo with the following commands:
$ cd ~/catkin_ws/src $ git clone https://TheConstruct@bitbucket.org/theconstructcore/iri_wam.git -b kinetic $ cd .. $ catkin_make $ roslaunch iri_wam_gazebo main.launch
The result is the simulation running just showing some warnings related to xacro namespace redefinitions.
inconsistent namespace redefinitions for xmlns:xacro: old: http://ros.org/wiki/xacro new: http://www.ros.org/wiki/xacro (/home/ricardo/catkin_ws/src/iri_wam/iri_wam_description/xacro/iri_wam_1.urdf.xacro)
That warning can be resolved by changing in all the affected files, the xacro definition from this:
There was no problem executing any of those. Bear in mind that it includes joint controllers as well as a couple of sensor plugins. So no modification was required in the simulation (remember, originally created for Gazebo 7.x).
Testing with a wheeled robot simulation
Next simulation we tested was the Summit XL robot simulation by Robotnik. We used the following commands:
$ cd ~/catkin_ws/src $ git clone https://TheConstruct@bitbucket.org/theconstructcore/summit_xl.git -b kinetic $ cd .. $ catkin_make
In this case, we also had no problem when launching the simulation with the following command:
$ roslaunch sumit_xl_course_basics main.launch
Testing with a full environment simulation
In this case, we decided to test a simulation created by the Gazebo team themselves, which they used for a competition and that was created for Gazebo 8. It is also an interesting simulation because includes a complete biped robot with several sensors, in a full office environment with people moving around, and plenty of stuff. Have a look at it here.
$ cd ~/catkin_ws/src $ hg clone https://TheConstruct@bitbucket.org/osrf/servicesim $ cd .. $ catkin_make $ roslaunch servicesim servicesim.launch
The simulation worked nicely off-the-shelf.
Problems when working with ROS with Gazebo 9
Gazebo is still and will always be a standalone program completely independent from ROS. This makes the work between them is not as smooth as it could be.
No ROS controllers provided
One of the problems I see with Gazebo 9 when working with ROS is that Gazebo provides a lot of interesting robot models through their Ignition Fuel library. However, none of the models includes the ROS controllers. So in case that you want to use the models for a ROS based situation, you need to create the controllers by yourself. One example of this case is the beautiful simulation of the autonomous car environment created by the Gazebo team. The simulation is perfect for a work with autonomous cars, but the only support it has is for Gazebo topics.
Use of SDF format instead of URDF
An additional problem with the models is that they have been created in SDF format. SDF is the default format for creating models and whole simulations in Gazebo 9, but that format is not supported by ROS. This makes more difficult to use the models in Gazebo + ROS simualtions since ROS requires a URDF description of the model to show it on Rviz. (just in case you want to convert SDF models into URDF, check the following tutorial about it).
You may be thinking why to use then SDF instead of URDF for defining the simulations. One of the reasons for using SDF in Gazebo instead of URDF (as indicated by Louise Poubel in this interview of the ROS Developers Podcast) is that SDF overcomes some of the limitations of URDF, like for example the creation of closed loops in a robot model. URDF does not allow to create a robot that has a kinematic chain that splits into two at some point and then unite again. SDF handles that with easy. Watch this video to understand the problem:
Based on that, could it be that the most convenient solution would be to change ROS to support SDF instead of changing Gazebo to support URDF?
[irp posts=”9004″ name=”My Robotic Manipulator – Part #1 – Basic URDF and RViz”]
What about ROS plugins?
The ROS plugins for Gazebo 9 are the plugins that provide the access to the different sensors and actuators and other functionalities of the simulator through a ROS interface. ROS plugins packages are provided as a different set of ROS packages from the main Gazebo 9 distribution. Usually, those packages are provided some weeks after the new Gazebo version has been released. The good new is that those packages for Gazebo 9 are already available (good job Jose Luis Rivero 😉 and you already installed them at the beginning of this post.
If you where using standard plugins provided by ROS in your simulations, it is very likely that they will still work off-the-shelf. On the other side, if you have created your own plugins using the Gazebo API for that, chances are that they may not work and may need to adapt small changes done in the plugins API.
With Gazebo 9, the simulator reaches a very mature version were quite detailed simulations can be created. Just check for example the impressive simulation created by OSRF of an autonomous cars environment. Every new version we find new features, but more important than that, we find more stability (that is, less crashes).
If you want to know what features will be included in the future versions of Gazebo and when are they going to be released, just check the Gazebo roadmap.
Related and useful links
- The Construct personal robot simulations repo, with many robot simulations ready to be used for ROS Indigo + Gazebo 7 or ROS Kinetic + Gazebo 7
- [UPDATE] Listen to the interview we did to Louise Poubel, one of the leading developers of Gazebo 9. Available here at the ROS Developers Podcast.
- [UPDATE] All Gazebo ROS Q&A tutorials are available in Robot Ignite Academy now. Create an account to access all.
- Series of ROS Developers Live Classes that teach how to work with Gazebo: