On the previous tutorial we covered where to find the source code for Gazebo and other dependencies.
This tutorial will go through the process of getting your own copy of the code running.
We previously showed that Gazebo's source code lives on a git repository on GitHub. But even though everyone in the world is able to see and copy that code, only the Gazebo core team has write access to it.
In order to modify the code, you'll need to get your own copy, which is called a "fork". You can fork Gazebo as follows:
Note: Throughout these tutorials, substitute
<yourname>with your GitHub account username.
Great, now you have a copy of the code, but it's not very convenient to interact with it through the browser. You want to have it in your computer. You will use the git command line tool to pull that code from the internet to your computer as follows:
Make sure you have git installed:
sudo apt update sudo apt install git
It's a good idea to create a directory to hold the source code, so:
mkdir ~/code cd ~/code
Now we use git to "clone" our fork. What the clone command does is copy all the code across all branches from the internet to your computer. Gazebo has a large codebase, so this process may take a while depending on your internet connection:
git clone https://github.com/<yourname>/gazebo
Now you should have a local copy of Gazebo under
move to that folder and list its contents:
cd ~/code/gazebo ls
You should see something like this:
Gazebo's code is organized into different branches with different purposes.
Let's take a look at all existing branches using the git command "branches":
cd ~/code/gazebo git branch -a
You'll see a long list which looks something like this:
remotes/origin/2.1_abi_compat remotes/origin/2014_copyright remotes/origin/90_windows_patch_test remotes/origin/DoNotLaunchMarkerManagerInServer remotes/origin/FixODERevoluteJointInitialization ...
Branches prefixed with
remotes/origin come from the official OSRF repository.
Most of the branches in Gazebo are branches where the core team is working on fixing bugs or adding new features. But a few branches have special meaning, these are:
master: This is the bleeding edge code where all new features are being
developed. You're automatically on this branch when you clone Gazebo. This
is where new features and code that is incompatible with previous releases
(i.e. breaks API/ABI) will go. Since Gazebo 11 was the last release, the
master branch no longer exists.
N is a number representing a Gazebo release. For example,
the code for the latest release of Gazebo 7 is found on branch
Cool, now we have all the code, let's build our own copy of Gazebo!
Note: This tutorial goes over the most basic installation. If you need some special configuration, check out the full install from source tutorial.
Setup your computer to accept software from packages.osrfoundation.org.
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
Setup keys and update
wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - sudo apt-get update
wget https://raw.githubusercontent.com/ignition-tooling/release-tools/master/jenkins-scripts/lib/dependencies_archive.sh -O /tmp/dependencies.sh ROS_DISTRO=dummy . /tmp/dependencies.sh sudo apt-get install $(sed 's:\\ ::g' <<< $BASE_DEPENDENCIES) $(sed 's:\\ ::g' <<< $GAZEBO_BASE_DEPENDENCIES)
Make sure you're at the source code root directory:
Make a build directory and go there
mkdir build cd build
Configure and build. This will take a while (easily more than one hour), leave it running and go watch some cool Gazebo videos.
cmake .. make -j4
Once that's done, install Gazebo:
sudo make install
Now you can try your installation:
If you've installed Gazebo on your system before, you might be asking how do you know if you're running your own copy of Gazebo, or the one you had previously installed. A quick trick to figure that out is to:
Check where you're running Gazebo from:
This will give you something like:
Now check where you're installing Gazebo to. You can do this by re-running install and looking for the install location, for example:
cd ~/code/gazebo/build sudo make install | grep /gazebo$
You'll see something like:
-- Up-to-date: /usr/local/bin/gazebo
If the paths from both commands match, you're running your own copy!