Installing and setting up ROS in 5 mins

[*disclaimer: not really 5 mins. Downloading ROS will probably take longer than that lol]

ROS is a really great library for robotics research. It might even be good for not robotic applications, I don’t know, but my general feel is that I like ROS about as much as I like nutella. (read: a lot). The ROS install tutorial is really good at explaining the process, but it’s spread over too many pages and requires too much scrolling. I’ve consolidated the information here in one page for ease of use. Our robotics lab only uses ROS Indigo, so I’m writing install instructions with that in mind. Also, ROS only works well with Ubuntu, so I’m assuming you’re also using the correct OS.

Everything that follows, unless explicitly stated, should be typed in a terminal window. Okay, so the steps:

1. Set up sources.list
We need to add the ROS package sources to our sources list so we can actually find the ROS packages using the apt package manager. Open up a terminal window and paste the following:
sudo sh -c ‘echo “deb $(lsb_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’

2. Set up your keys
Next we need to set up keys so Ubuntu will actually allow us to download + install the packages.
sudo apt-key adv –keyserver hkp:// –recv-key 0xB01FA116
If you get a gpg: keyserver timed out error, use this instead:
sudo apt-key adv –keyserver hkp:// –recv-key 0xB01FA116

3. Install ROS via apt-get
Make sure the apt package index is up to date from when we added those new sources at step 1.
sudo apt-get update
Then install ROS!
sudo apt-get install ros-indigo-desktop-full
There are a couple of flavors of ROS that you can install, but for most applications, you might as well do the full install to make sure you get all the packages you’ll ever need.

4. Initialize rosdep
Before we can use ROS, we need to initialize rosdep. rosdep enables ROS to easily install dependancies when necessary, and is required for some core ROS functionality.
sudo rosdep init
rosdep update

5. Temporarily source ROS setup.bash
In order to do the rest of setup, we need to temporarily source the default setup.bash so that we can actually run the ROS commands. If this step is skipped, the terminal won’t be able to recognize commands like catkin_make, roscore etc.
echo “source /opt/ros/indigo/setup.bash” >> ~/.bashrc
source ~/.bashrc

This step is explained more in step 7.

6. Create a ROS workspace
All the packages that we do work in will need to be in a workspace. A workspace is required as a place where all the catkin packages (ROS’s method of compiling code) are kept and built. You can read more about it here, but the core concept is that your packages will go in catkin_ws/src/.

So let’s make one! Open a new terminal window and type the following:
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src

You will now have an empty workspace. Now we “build” the workspace to get the required development files we’ll need to set up our environment for working in ROS at a later time.
cd ~/catkin_ws/

The catkin_make command is a convenience tool for working with catkin workspaces. If you look in your current directory you should now have a “build” and “devel” folder.

7. Source workspace setup.bash [important!]
Since all of the code we work with will be in the catkin_ws, we need to source ROS such that we’re overlaying the setup files from the workspace instead of the /opt folder where we installed ROS. This will allow you to run roscore from any directory in your terminal window. To do so, we will modify the .bashrc.

Open up the bashrc in a text editor. I like to use gedit, but you can use vim, or whatever is easiest for you.
gedit ~/.bashrc
Will open up a window with your current bashrc. Scroll to the bottom, comment out the default ROS setup.bash that was sourced on step 5 and add the new one. Example of what your bashrc should look like at the bottom is below.


It’s a default bashrc, yours may be different. What’s important is that the last line is there.

8. Download ROS beginner tutorials, and off you go~
Now that you’ve installed ROS and have a workspace, you’re ready to develop cool packages for your robots! Go ahead to start the ROS beginner tutorials, or just the next post I wrote about learning core ROS concepts in 5 min.

Hope this makes installing ROS a bit less frustrating. 😛


Leave a Reply

Your email address will not be published. Required fields are marked *