Learning Robotics using Python
上QQ阅读APP看书,第一时间看更新

Installing ROS on Ubuntu

As per our previous discussion, we know that ROS is a metaoperating system that is installed on a host system. ROS is completely supported on Ubuntu /Linux and in the experimental stages on Windows and OS X. Some of the latest ROS distributions are as follows:

We will now look at the installation procedure of the stable, long-term support (LTS) distribution of ROS called Kinetic on Ubuntu 16.04.3 LTS. ROS Kinetic Kame will be primarily targeted at Ubuntu 16.04 LTS. You can also find instructions to set up ROS in the latest LTS Melodic Morenia on Ubuntu 18.04 LTS after looking at the following instructions. If you are a Windows or OS X user, you can install Ubuntu in a VirtualBox application before installing ROS on it. The link to download VirtualBox is https://www.virtualbox.org/wiki/Downloads.

You can find the complete instructions for doing this at http://wiki.ros.org/kinetic/Installation/Ubuntu.

The steps are as follows:

  1. Configure your Ubuntu repositories to allow restricted, universe, and multiverse downloadable files. We can configure it using Ubuntu's Software & Update tool. We can get this tool by simply searching on the Ubuntu Unity search menu and ticking the shown in the following screenshot:

Ubuntu's Software & Update tool

  1. Set up your system to accept ROS packages from packages.ros.org. ROS Kinetic is supported only on Ubuntu 15.10 and 16.04. The following command will store packages.ros.org in Ubuntu's apt repository list:
    $ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
  1. Next, we have to add apt-keys. An apt-key is used to manage the list of keys used by apt to authenticate the packages. Packages that have been authenticated using these keys will be considered trusted. The following command will add apt-keys for the ROS packages:
    sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116  
  1. After adding the apt-keys, we have to update the Ubuntu package list. The following command will add and update the ROS packages, along with the Ubuntu packages:
    $ sudo apt-get update
  1. After updating the ROS packages, we can install the packages. The following command will install all the necessary packages, tools, and libraries of ROS:
      $ sudo apt-get install ros-kinetic-desktop-full 
  1. We may need to install additional packages even after the desktop full installation. Each additional installation will be mentioned in the appropriate section. The desktop full install will take some time. After the installation of ROS, you will almost be done. The next step is to initialize rosdep, which enables you to easily install the system dependencies for ROS source packages:
$ sudo rosdep init    
$ rosdep update
  1. To access ROS's tools and commands on the current bash shell, we can add ROS environmental variables to the .bashrc file. This will execute at the beginning of each bash session. The following is a command to add the ROS variable to .bashrc:
    echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc   

The following command will execute the .bashrc script on the current shell to generate the change in the current shell:

    source ~/.bashrc  
  1. A useful tool to install the dependency of a package is rosinstall. This tool has to be installed separately. It enables you to easily download many source trees for the ROS package with one command:
    $ sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential  

The installation of the latest LTS Melodic is similar to the preceding instructions. You can install Melodic along with Ubuntu 18.04 LTS. You can find the complete instructions at http://wiki.ros.org/melodic/Installation/Ubuntu.

After the installation of ROS, we will discuss how to create a sample package in ROS. Before creating the package, we have to create a ROS workspace. The packages are created in the ROS workspace. We will use the catkin build system, which is a set of tools that is used to build packages in ROS. The catkin build system generates an executable or shared library from the source code. ROS Kinetic uses the catkin build system to build packages. Let's look at what catkin is.