In this section, we are going to install ROS Fuerte on our computer. You can have different versions installed on the same computer without problems; you only need to select the version that you want to use in the .bashrc
file. You will see how to do this in this section.
If you want to see the official page where this process is explained, you can visit the following URL: http://wiki.ros.org/fuerte/Installation.
You can install ROS using two methods: using repositories and using source code. Normal users will only need to make an installation using repositories to get a functional installation of ROS. You can install ROS using the source code but this process is for advanced users and we don't recommend it.
First, you must check that your Ubuntu accepts restricted, universal, and multiversal repositories. Refer to the Installing ROS Electric – using repositories section if you want to see how to do it.
Normally, Ubuntu is configured to allow these repositories and you won't have problems with this step.
Now we are going to add the URLs from where we can download the code. Note that ROS Fuerte doesn't work for Maverick and Natty, so you must have Ubuntu 10.04, 11.10, or 12.04 on your computer.
For this book we have used Ubuntu 12.04 and it works fine. All the examples have been checked, compiled, and executed in this version of Ubuntu.
Open a new shell and type the following command, as we did before, which should work for any Ubuntu version you have:
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
It is important to add the key because with it we can be sure that we are downloading the code from the right place and nobody has modified it.
If you have followed the steps to install ROS Electric, you don't need to do this again as you have already completed this earlier; if not, add the repository using the following command:
$ wget http://packages.ros.org/ros.key -O - | sudo apt-key add –
We are ready to install ROS Fuerte at this point. Before doing something, it is necessary to update all the programs used by ROS. We do it to avoid incompatibility problems.
Type the following command in a shell and wait:
$ sudo apt-get update
Depending on whether you had the system updated or not, the command will take more or less time to finish.
ROS has a lot of parts and installing the full system can be heavy in robots without enough features. For this reason, you can install various versions depending on what you want to install.
For this book, we are going to install the full version. This version will install all the examples, stacks, and programs. This is a good option for us because in some chapters of this book, we will need to use tools, and if we don't install it now, we will have to do it later:
The easiest (and recommended if you have enough hard disk space) installation is known as desktop-full. It comes with ROS, the Rx tools, the rviz visualizer (for 3D), many generic robot libraries, the simulator in 2D (such as stage) and 3D (usually Gazebo), the navigation stack (to move, localize, do mapping, and control arms), and also perception libraries using vision, lasers, or RGB-D cameras:
$ sudo apt-get install ros-fuerte-desktop-full
If you do not have enough disk space, or you prefer to install only a few stacks, first install only the desktop installation file, which comes only with ROS, the Rx tools, rviz, and generic robot libraries. Later, you can install the rest of the stacks when you need them (using aptitude and looking for the
ros-electric-*
stacks, for example):$ sudo apt-get install ros-fuerte-desktop
If you only want the bare bones, install ROS-comm, which is usually recommended for the robot itself or computers without a screen or just a TTY. It will install the ROS package with the build and communication libraries and no GUI tools at all:
$ sudo apt-get install ros-fuerte-ros-comm
Finally, along with whatever option you choose from the list, you can install individual/specific ROS stacks (for a given stack name):
$ sudo apt-get install ros-fuerte-STACK
Do not worry if you are installing things that you do not know. In the upcoming chapters, you will learn about everything you are installing and how to use it.
When you gain experience with ROS, you can make basic installations in your robots using only the core of ROS, using less resources, and taking only what you need.
Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. You can also download these code files from https://github.com/AaronMR/Learning_ROS_for_Robotics_Programming.
Now that you have installed ROS, to start using it, you must provide Ubuntu with the path where ROS is installed. Open a new shell and type the following command:
$ roscore roscore: command not found
You will see this message because Ubuntu does not know where to search for the commands. To solve it, type the following command in a shell:
$ source /opt/ros/fuerte/setup.bash
Then, type the roscore
command once again, and you will see the following output:
... started roslaunch server http://localhost:45631/ ros_comm version 1.8.11 SUMMARY ======== PARAMETERS * /rosdistro * /rosversion NODES auto-starting new master ....
This means that Ubuntu knows where to find the commands to run ROS. Note that if you open another shell and type roscore
, it will not work. This is because it is necessary to add this script within the .bashrc
file. So, every time you start a new shell, the scripts will run because .bashrc
always runs when a shell runs.
Use the following commands to add the script:
$ echo "source /opt/ros/fuerte/setup.bash" >> ~/.bashrc $ source ~/.bashrc
As mentioned before, only source setup.bash
for one ROS distribution. Imagine that you had Electric and Fuerte installed on your computer, and you are using Fuerte as the normal version. If you want to change the version used in a shell, you only have to type the following command:
$ source /opt/ros/electric/setup.bash
If you want to use another version on a permanent basis, you must change the .bashrc
file and put the correct script for your version.
ROS has some tools that need to be installed after the principal installation. These tools will help us install dependencies between programs to compile, download, and install packages from ROS. These tools are rosinstall
and rosdep
. We recommend installing them because we will use them in the upcoming chapters. To install these tools, type the following command in a shell:
$ sudo apt-get install python-rosinstall python-rosdep
Now we have a full installation of ROS on our system. As you can see, only a few steps are necessary to do it.
It is possible to have two or more versions of ROS installed on our computer. Furthermore, you can install ROS on a virtual machine if you don't have Ubuntu installed on your computer.
In the next section, we will explain how to install a virtual machine and use a drive image with ROS. Perhaps this is the best way to get ROS for new users.