Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning ROS for Robotics Programming Second Edition

You're reading from   Learning ROS for Robotics Programming Second Edition Take control of the Linux based Robot Operating System, and discover the tools, libraries, and conventions you need to create your own robots without the hassle.

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher Packt
ISBN-13 9781783987580
Length 458 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with ROS Hydro FREE CHAPTER 2. ROS Architecture and Concepts 3. Visualization and Debug Tools 4. Using Sensors and Actuators with ROS 5. Computer Vision 6. Point Clouds 7. 3D Modeling and Simulation 8. The Navigation Stack – Robot Setups 9. The Navigation Stack – Beyond Setups 10. Manipulation with MoveIt! Index

Installing ROS Hydro – using repositories

Last year, the ROS webpage was updated with a new design and a new organization of contents. You can see a screenshot of the webpage that follows:

Installing ROS Hydro – using repositories

In the menu, you can find information about ROS and whether ROS is a good choice for your system, blogs, news, and so on.

Instructions for the ROS installation can be found under the Install tab in the Getting Started section.

ROS recommends that you install the system using the repository instead of the source code, unless you are an advanced user and you want to make a customized installation; in that case, you may prefer installing ROS using the source code.

So to install ROS using the repositories, we will start by configuring the Ubuntu repository in our system.

Configuring your Ubuntu repositories

In this section, you will learn the steps for installing ROS Hydro in your computer. This process has been based on the official installation page, which can be found at http://wiki.ros.org/hydro/Installation/Ubuntu.

We assume that you know what an Ubuntu repository is, and how to manage it. If you have any doubts about it, refer to https://help.ubuntu.com/community/Repositories/Ubuntu.

Before we start the installation, we need to configure our repositories. To do that, the repositories need to allow restricted, universe, and multiverse. To check if your Ubuntu accepts these repositories, click on the Ubuntu Software Center in the menu on the left-hand side of your desktop, as shown in the following screenshot:

Configuring your Ubuntu repositories

Click on Edit | Software Sources and you will see the next window. Make sure that all the listed options are checked as shown in the following screenshot:

Configuring your Ubuntu repositories

Normally these options are marked, so you should not have any problem with this step.

Setting up your source.list file

In this step, you have to select your Ubuntu version. It is possible to install ROS Hydro in various versions of the operating system. You can use any of them, but we recommend version 12.04 to follow the chapters of this book. Keep in mind that Hydro works in the Precise Pangolin (12.04), Quantal Quetzal (12.10), and the Raring Ringtail(13.04) versions of Ubuntu.

  • If you're going follow the book with Ubuntu 12.04 (Precise Pangolin), type the following command to add the repositories:
    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list'
    
  • If you're going to follow the book with Ubuntu 12.10 (Quantal Quetzal), type the following command to add the repositories:
    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu quantal main" > /etc/apt/sources.list.d/ros-latest.list'
    
  • To follow the book with Ubuntu 13.04 (Raring Ringtail), type the following command to add the repositories:
    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu raring main" > /etc/apt/sources.list.d/ros-latest.list'
    

Tip

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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/ROS_Book_Hydro.

Once you've added the correct repository, your operating system will know where to download programs to install them into your system.

Setting up your keys

This step is to confirm that the origin of the code is correct and that no-one has modified the code or programs without the knowledge of the owner. Normally, when you add a new repository you have to add the keys of that repository, so it is added to your system's trusted list.

$ wget http://packages.ros.org/ros.key -O - | sudo apt-key add -

Now we can be sure that the code came from an authorized site and has not been modified.

Installing ROS

We are ready to start the installation now, but before we do that it's better to make an update to avoid problems with the libraries and software with a version other than what ROS needs. This is done with the following command:

$ sudo apt-get update

ROS is huge; sometimes you will install libraries and programs that you will never use. Normally it has four different installations, but this depends on the final use. For example, if you are an advanced user, maybe you only need the basic installation for a robot without much space on the hard disc. For this book, we recommend you use the full installation because it will install everything necessary to practice the examples and tutorials.

It doesn't matter if you don't know what are you installing right now — rviz, simulators, navigation, and so on. You will learn everything in the upcoming chapters:

  • The easiest (and recommended if you have enough hard disk space) installation is known as desktop-full. It comes with ROS, the rqt tools, the rviz visualizer (for 3D), many generic robot libraries, simulator in 2D (like stage) and 3D (usually gazebo), the navigation stack (to move, localize, do mapping, and control arms), and also perception libraries using vision, lasers or RGBD cameras:
    $ sudo apt-get install ros-hydro-desktop-full
    
  • If you do not have enough disk space or you prefer to install only a few packages, install only the desktop install initially, which comes with only ROS, the rqt tools, rviz, and generic robot libraries. You can install the rest of the packages as and when you need them. For example, using aptitude and looking for ros-hydro-* packages with the following command:.
    $ sudo apt-get install ros-hydro-desktop
    
  • If you only want the bare bones, install ROS-base, which is usually recommended for the robot itself, or for 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. With BeagleBone Black (BBB), we will install the system with the following option:
    $ sudo apt-get install ros-hydro-ros-base
    
  • Finally, whichever of the previous options you choose, you can also install individual/specific ROS packages (for a given package name):
    $ sudo apt-get install ros-hydro-PACKAGE
    

Initializing rosdep

Before you can use ROS, you will need to initialize rosdep. The rosdep command line too enables you to easily install system dependencies for the source you want to compile and is required to run some core components in ROS. In ROS Fuerte you had to install rosdep after installing ROS, and it was known as a standalone tool. Now rosdep is installed in ROS by default. To initialize rosdep, you have to use the following commands:

$ sudo rosdep init 
$ rosdep update

Setting up the environment

Congratulations! If you are at this step, you have an installed version of ROS on your system! To start using it, the system needs to know the location of the executable or binary files as well as the other commands. To do so, normally you need to execute the next script; if you also install another ROS distro, you can work with both just by calling the script of the one you need each time, since this script simply sets your environment. Here we use the one for ROS Hydro, but just replace Hydro with Fuerte or Groovy if you want to try other distros:

$ source /opt/ros/hydro/setup.bash

If you type roscore in the shell, you will see something starting up. This is the best test for finding out if you have ROS, and if it is installed correctly.

Notice that if you open another shell and type roscore or other ROS commands, it does not work. This is because it is necessary to execute the script again to configure the global variables, the path where ROS is installed, and so on.

It is very easy to solve this; you just need to add the script at the end of your .bashrc script file so that when you start a new shell, the script will execute and you will have the environment configured.

The .bashrc file is within the user home (/home/USERNAME/.bashrc). It has the configuration of the shell or terminal, and each time the user opens the terminal, this file is loaded. So you can add commands or configuration to make the user's life easy. For this reason, we will add the script at the end of the .bashrc file, to avoid keying it in each time we open a terminal. We do this with the following command:

$ echo "source /opt/ros/hydro/setup.bash" >> ~/.bashrc 

To see the results, you have to execute the file using the next command, or close the current terminal and open another.

$ source ~/.bashrc

Some users need more than a single ROS distribution installed in their system. Your ~/.bashrc must only source the setup.bash of the version you are currently using, since the last call will override the environment set of the others. So you have several distros living in the same system and need to switch between them.

For example, you might have the following lines in your .bashrc file:


source /opt/ros/hydro/setup.bash
source /opt/ros/fuerte/setup.bash
source /opt/ros/electric/setup.bash

The ROS Electric version will be executed in this case. So you have to make sure that the version you are running is the last one in the file.

If you want to check the version used in a terminal, you can do so easily using the echo $ROS_DISTRO command.

Getting rosinstall

Now, the next step is to install a command tool that will help us install other packages with a single command. This tool is based in Python, but don't worry, you don't need to know Python to use it. You will learn how to use this tool in the upcoming chapters:

To install this tool on Ubuntu, run the following command:

$ sudo apt-get install python-rosinstall

And that is all! You have a complete ROS system installed in your system. When I finish a new installation of ROS, I personally like to test two things: that roscore works, and turtlesim.

If you want to do the same,, type the following commands in different shells:

$ roscore
$ rosrun turtlesim turtlesim_node

And if everything is okay, you will see the following screenshot:

Getting rosinstall
You have been reading a chapter from
Learning ROS for Robotics Programming Second Edition
Published in: Aug 2015
Publisher: Packt
ISBN-13: 9781783987580
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image