|
| 1 | +# Run your own copy of Gazebo |
| 2 | + |
| 3 | +On the [previous tutorial](http://gazebosim.org/tutorials?tut=guided_a1) |
| 4 | +we covered where to find the source code for Gazebo and other dependencies. |
| 5 | + |
| 6 | +This tutorial will go through the process of getting your own copy of the |
| 7 | +code running. |
| 8 | + |
| 9 | +## Fork it! |
| 10 | + |
| 11 | +We previously showed that Gazebo's source code lives on a mercurial |
| 12 | +[repository](https://bitbucket.org/osrf/gazebo) on Bitbucket. But even though |
| 13 | +everyone in the world is able to see and copy that code, only the Gazebo core |
| 14 | +team has write access to it. |
| 15 | + |
| 16 | +In order to modify the code, you'll need to get your own copy, which is called |
| 17 | +a "fork". You can fork Gazebo as follows: |
| 18 | + |
| 19 | +1. Click on [this link](https://bitbucket.org/osrf/gazebo/fork) |
| 20 | +1. You can choose a custom name for the repository, but here we will leave the |
| 21 | +default value `gazebo`. |
| 22 | +1. After you finish the fork process, you should have a copy of Gazebo on |
| 23 | +`https://bitbucket.org/<yourname>/gazebo`. |
| 24 | + |
| 25 | +> **Note**: Throughout these tutorials, substitute `<yourname>` with your |
| 26 | +Bitbucket account username. |
| 27 | + |
| 28 | +## Clone |
| 29 | + |
| 30 | +Great, now you have a copy of the code, but it's not very convenient to |
| 31 | +interact with it through the browser. You want to have it in your computer. |
| 32 | +You will use the mercurial command line tool to pull that code from the internet |
| 33 | +to your computer as follows: |
| 34 | + |
| 35 | +1. Make sure you have mercurial (`hg`) installed: |
| 36 | + |
| 37 | + sudo apt update |
| 38 | + sudo apt install mercurial |
| 39 | + |
| 40 | +1. It's a good idea to create a directory to hold the source code, so: |
| 41 | + |
| 42 | + mkdir ~/code |
| 43 | + cd ~/code |
| 44 | + |
| 45 | +1. Now we use mercurial to "clone" our fork. What the clone command does is |
| 46 | +copy all the code across all branches from the internet to your computer. |
| 47 | +Gazebo has a large codebase, so this process may take a while depending on |
| 48 | +your internet connection: |
| 49 | + |
| 50 | + hg clone https://bitbucket.org/<yourname>/gazebo |
| 51 | + |
| 52 | +1. Now you should have a local copy of Gazebo under `~/code/gazebo`. Let's |
| 53 | +move to that folder and list its contents: |
| 54 | + |
| 55 | + cd ~/code/gazebo |
| 56 | + ls |
| 57 | + |
| 58 | +1. You should see something like this: |
| 59 | + |
| 60 | + [[file:files/tut2_1.png|800px]] |
| 61 | + |
| 62 | +## Branches |
| 63 | + |
| 64 | +Gazebo's code is organized into different branches with different purposes. |
| 65 | + |
| 66 | +1. Let's take a look at all existing branches using the mercurial command |
| 67 | +"branches": |
| 68 | + |
| 69 | + cd ~/code/gazebo |
| 70 | + hg branches |
| 71 | + |
| 72 | +1. You'll see a long list which looks something like this: |
| 73 | + |
| 74 | + gazebo7 34485:8a11f7f5192d |
| 75 | + harness_detach_race 34483:61e3130bc8ac |
| 76 | + gazebo8 34480:bec999d7b4f5 |
| 77 | + default 34478:33a2f98c192b |
| 78 | + contact_sensor_active 34442:6f5bbf8258d0 |
| 79 | + harness_attach_default 34441:3316f27cf2c8 |
| 80 | + ardupilot_merge_gazebo8 34419:1df2ecb57e53 |
| 81 | + collision_pose_noncanonical 34393:57c8ae067a61 |
| 82 | + wind_patch_8a 34372:e6e53633700a |
| 83 | + issue_2049_7 34319:cc19fc0a7894 |
| 84 | + ... |
| 85 | + |
| 86 | +1. On the left you have branch names, and on the right the id of the latest |
| 87 | +commit on that branch. |
| 88 | + |
| 89 | +Most of the branches in Gazebo are branches where the core team is working |
| 90 | +on fixing bugs or adding new features. But a few branches have special meaning, |
| 91 | +these are: |
| 92 | + |
| 93 | +* `default`: This is the bleeding edge code where all new features are being |
| 94 | +developed. You're automatically on this branch when you clone Gazebo. This |
| 95 | +is where new features and code that is incompatible with previous releases |
| 96 | +(i.e. breaks API/ABI) will go. |
| 97 | + |
| 98 | +* `gazebo<N>`: Here, `N` is a number representing a Gazebo release. For example, |
| 99 | +the code for the latest release of Gazebo 7 is found on branch `gazebo7`. |
| 100 | + |
| 101 | +## Build |
| 102 | + |
| 103 | +Cool, now we have all the code, let's build our own copy of Gazebo! |
| 104 | + |
| 105 | +> **Note**: This tutorial goes over the most basic installation. If you need |
| 106 | +some special configuration, check out the full |
| 107 | +[install from source tutorial](http://gazebosim.org/tutorials?tut=install_from_source&cat=install). |
| 108 | + |
| 109 | +1. Setup your computer to accept software from packages.osrfoundation.org. |
| 110 | + |
| 111 | + sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' |
| 112 | + |
| 113 | +1. Setup keys and update |
| 114 | + |
| 115 | + wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - |
| 116 | + sudo apt-get update |
| 117 | + |
| 118 | +1. Install dependencies |
| 119 | + |
| 120 | + wget https://bitbucket.org/osrf/release-tools/raw/default/jenkins-scripts/lib/dependencies_archive.sh -O /tmp/dependencies.sh |
| 121 | + ROS_DISTRO=dummy . /tmp/dependencies.sh |
| 122 | + sudo apt-get install $(sed 's:\\ ::g' <<< $BASE_DEPENDENCIES) $(sed 's:\\ ::g' <<< $GAZEBO_BASE_DEPENDENCIES) |
| 123 | + |
| 124 | +1. Make sure you're at the source code root directory: |
| 125 | + |
| 126 | + cd ~/code/gazebo |
| 127 | + |
| 128 | +1. Make a build directory and go there |
| 129 | + |
| 130 | + mkdir build |
| 131 | + cd build |
| 132 | + |
| 133 | +1. Configure and build. This will take a while (easily more than one hour), |
| 134 | +leave it running and go watch some cool |
| 135 | +[Gazebo videos](https://www.youtube.com/results?search_query=gazebo+simulator). |
| 136 | + |
| 137 | + cmake .. |
| 138 | + make -j4 |
| 139 | + |
| 140 | +1. Once that's done, install Gazebo: |
| 141 | + |
| 142 | + sudo make install |
| 143 | + |
| 144 | +1. Now you can try your installation: |
| 145 | + |
| 146 | + gazebo --verbose |
| 147 | + |
| 148 | +## Check the installation |
| 149 | + |
| 150 | +If you've installed Gazebo on your system before, you might be asking |
| 151 | +how do you know if you're running your own copy of Gazebo, or the one you |
| 152 | +had previously installed. A quick trick to figure that out is to: |
| 153 | + |
| 154 | +1. Check where you're running Gazebo from: |
| 155 | + |
| 156 | + which gazebo |
| 157 | + |
| 158 | +1. This will give you something like: |
| 159 | + |
| 160 | + /usr/local/bin/gazebo |
| 161 | + |
| 162 | +1. Now check where you're installing Gazebo to. You can do this by re-running |
| 163 | +install and looking for the install location, for example: |
| 164 | + |
| 165 | + cd ~/code/gazebo/build |
| 166 | + sudo make install | grep /gazebo$ |
| 167 | + |
| 168 | +1. You'll see something like: |
| 169 | + |
| 170 | + -- Up-to-date: /usr/local/bin/gazebo |
| 171 | + |
| 172 | +1. If the paths from both commands match, you're running your own copy! |
| 173 | + |
0 commit comments