Installing and launching ROS
For this book, we assume the reader has a computer with Ubuntu Wily 15.10 or Xenial 16.04 installed. The examples in this book have been developed using ROS Kinetic 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 is the most efficient and preferred way to install ROS.
If you wish to install the ROS Kinetic source code and build the software, refer to the instructions at http://wiki.ros.org/kinetic/Installation/Source. The instructions presented here to install ROS Kinetic with Debian packages can also be found at http://wiki.ros.org/kinetic/Installation/Ubuntu.
If you have any problems while installing ROS, refer to this site and the ROS forum at http://answers.ros.org.
Note
Refer to the Gazebo tutorial at http://gazebosim.org/tutorials/?tut=ros_urdf for a list of these elements and their usage (Elements for Links and Elements for Joints).
Configuring your Ubuntu repositories
To configure your Ubuntu repositories to allow restricted, universe and multiverse, perform the following steps:
- Click on the Ubuntu System Settings icon in the menu on the left side of your desktop.
- Click on the Software & Updates icon. On the Software & Updates screen, select the appropriate checkboxes to match the following screenshot:
Setting up your sources.list file
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'
Tip
In copying such two line commands from the electronic version of this book, be sure to delete the Carriage Return at the end of the first line.
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 Kinetic, 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 to the operating system's trusted software list. Type the following command:
$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
Installing ROS Kinetic
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
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-kinetic-desktop-full
ROS Kinetic is installed on your computer system when the installation process 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 commands:
$ 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/kinetic/setup.bash
Alternatively, 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 commands:
$ echo "source /opt/ros/kinetic/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 env
command in the following form that lists the ROS environment variables:
$ env | grep ROS
The output of the preceding command is as follows:
ROS_ROOT=/opt/ros/kinetic/share/ros ROS_PACKAGE_PATH=/opt/ros/kinetic/share ROS_MASTER_URI=http://localhost:11311 ROSLISP_PACKAGE_DIRECTORIES= ROS_DISTRO=kinetic ROS_ETC_DIR=/opt/ros/kinetic/etc/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= "kinetic"
and 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