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 mercurial repository on Bitbucket. 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 Bitbucket 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 mercurial command line tool to pull that code from the internet to your computer as follows:
Make sure you have mercurial (
sudo apt update sudo apt install mercurial
It's a good idea to create a directory to hold the source code, so:
mkdir ~/code cd ~/code
Now we use mercurial 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:
hg clone https://bitbucket.org/<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 mercurial command "branches":
cd ~/code/gazebo hg branches
You'll see a long list which looks something like this:
gazebo7 34485:8a11f7f5192d harness_detach_race 34483:61e3130bc8ac gazebo8 34480:bec999d7b4f5 default 34478:33a2f98c192b contact_sensor_active 34442:6f5bbf8258d0 harness_attach_default 34441:3316f27cf2c8 ardupilot_merge_gazebo8 34419:1df2ecb57e53 collision_pose_noncanonical 34393:57c8ae067a61 wind_patch_8a 34372:e6e53633700a issue_2049_7 34319:cc19fc0a7894 ...
On the left you have branch names, and on the right the id of the latest commit on that branch.
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:
default: 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.
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 http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - sudo apt-get update
wget https://bitbucket.org/osrf/release-tools/raw/default/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!