Book Image

ROS Robotics By Example

Book Image

ROS Robotics By Example

Overview of this book

The visionaries who created ROS developed a framework for robotics centered on the commonality of robotic systems and exploited this commonality in ROS to expedite the development of future robotic systems. From the fundamental concepts to advanced practical experience, this book will provide you with an incremental knowledge of the ROS framework, the backbone of the robotics evolution. ROS standardizes many layers of robotics functionality from low-level device drivers to process control to message passing to software package management. This book provides step-by-step examples of mobile, armed, and flying robots, describing the ROS implementation as the basic model for other robots of these types. By controlling these robots, whether in simulation or in reality, you will use ROS to drive, move, and fly robots using ROS control.
Table of Contents (17 chapters)
ROS Robotics By Example
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Installing and launching ROS


For this book, we assume the reader has a computer with Ubuntu Saucy 13.10 or Trusty 14.04 installed. The examples in this book have been developed using ROS Indigo and this version of ROS is only supported by these two versions of Ubuntu. The instructions for ROS installation provided in this section are for installing Debian (binary) packages. This method is the most efficient and preferred way to install ROS.

If you wish to install the ROS Indigo source code and build the software, refer to instructions at http://wiki.ros.org/indigo/Installation/Source. The instructions presented here to install ROS Indigo with Debian packages can also be found at http://wiki.ros.org/indigo/Installation/Ubuntu.

If you have any problems installing ROS, refer to this site and the ROS forum at http://answers.ros.org.

Configuring your Ubuntu repositories

To begin, configure the Ubuntu repositories to allow restricted, universe, and multiverse. Click on the Ubuntu Software Center icon in the launch menu on the left side of your desktop. From the Software Center's top menu bar, navigate to Edit, then to the drop-down menu, and select Software Sources. On the Software & Updates screen, select checkboxes to match the following screenshot:

Ubuntu Software Center Screen

Setting up your sources.list

Open a terminal window to set up the sources.list file on your computer to accept software from the ROS software repository at http://packages.ros.org which is the authorized site for the ROS software.

At the $ command prompt, type the following command as one long command:

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu
$(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

This step allows the operating system to know where to download programs that need to be installed on your system. When updates are made to ROS Indigo, your operating system will be made aware of these updates.

Setting up your keys

Keys confirm the origin of the code and verify that unauthorized modifications to the code have not been made without the knowledge of the owner. A repository and the keys of that repository are added the operating system's trusted software list. Type the following command:

$ sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-key 0xB01FA116

Installing ROS Indigo

Before you begin with the installation, the current system software must be up to date to avoid problems with libraries and wrong versions of software. To make sure your Debian package index is up-to-date, type the following command:

$ sudo apt-get update

Note

Warning: If you are using Ubuntu Trusty14.04.2 and experience dependency issues during the ROS installation, you may have to install some additional system dependencies.

Do not install these packages if you are using 14.04, it will destroy your X server:

$ sudo apt-get install xserver-xorg-dev-lts-utopic mesa-common-dev-lts-utopic libxatracker-dev-lts-utopic libopenvg1-mesa-dev-lts-utopic libgles2-mesa-dev-lts-utopic libgles1-mesa-dev-lts-utopic libgl1-mesa-dev-lts-utopic libgbm-dev-lts-utopic libegl1-mesa-dev-lts-utopic

Alternatively, try installing just this to fix dependency issues:

$ sudo apt-get install libgl1-mesa-dev-lts-utopic

For more information on this issue, refer to the following sites:

http://answers.ros.org/question/203610/ubuntu-14042-unmet-dependencies/

https://bugs.launchpad.net/ubuntu/+source/mesa-lts-utopic/+bug/1424059

Install the desktop-full configuration of ROS. Desktop-full includes ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation, and 2D/3D perception. In this book, we will be using rqt and rviz for visualization and also the Gazebo 3D simulator, as well as the ROS navigation and perception packages. To install, type the following command:

$ sudo apt-get install ros-indigo-desktop-full

ROS Indigo is installed on your computer system when the installation is complete!

Initialize rosdep

The ROS system may depend on software packages that are not loaded initially. These software packages external to ROS are provided by the operating system. The ROS environment command rosdep is used to download and install these external packages. Type the following command:

$ sudo rosdep init
$ rosdep update

Environment setup

Your terminal session must now be made aware of these ROS files so that it knows what to do when you attempt to execute ROS command-line commands. Running this script will set up the ROS environment variables:

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

Alternately, it is convenient if the ROS environment variables are automatically added to your terminal session every time a new shell is launched. If you are using bash for your terminal shell, do this by typing the following command:

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

Now when a new terminal session is launched, the bash shell is automatically aware of the ROS environment variables.

Getting rosinstall

The rosinstall command is a command-line tool in ROS that allows you to download ROS packages with one command.

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

$ sudo apt-get install python-rosinstall

Troubleshooting – examining your ROS environment

The ROS environment is set up through a number of variables that tell the system where to find ROS packages. Two main variables are ROS_ROOT and ROS_PACKAGE_PATH that enable ROS to locate packages in the filesystem.

To check whether the ROS environment variables are set correctly, use the export command in the following form that lists the ROS environment variables:

$ export | grep ROS

The output of the preceding command is as follows:

declare -x ROSLISP_PACKAGE_DIRECTORIES=""

declare -x ROS_DISTRO="indigo"

declare -x ROS_ETC_DIR="/opt/ros/indigo/etc/ros"

declare -x ROS_MASTER_URI="http://localhost:11311"

declare -x ROS_PACKAGE_PATH="/opt/ros/indigo/share:/opt/ros/indigo/stacks"

declare -x ROS_ROOT="/opt/ros/indigo/share/ros"

If the variables are not set correctly, you will need to source your setup.bash file as described in the Environment setup section of this chapter. Check whether the ROS_DISTRO= "indigo" and the ROS_PACKAGE_PATH variables are correct, as shown previously.

The tutorial that discusses the ROS environment can be found at http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment.