Book Image

Learning ROS for Robotics Programming Second Edition

Book Image

Learning ROS for Robotics Programming Second Edition

Overview of this book

Table of Contents (27 chapters)
Learning ROS for Robotics Programming Second Edition
Credits
About the Author
Acknowledgments
About the Author
Acknowledgments
About the Author
Acknowledgments
About the Author
Acknowledgments
About the Reviewer
About the Reviewer
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Installing ROS Hydro in BeagleBone Black (BBB)


BeagleBone Black is a low-cost development platform based on an ARM Cortex A8 processor. This board is fabricated with a Linux distribution called Ångström. Ångström was developed by a small group who wanted to unify Linux distribution for embedded systems. They wanted an operating system that was stable and user-friendly.

Texas Instruments designed BeagleBone Black thinking that the community of developers needed an on-board computer with some general purpose input/output (GPIO) pins. The BeagleBone Black platform is an evolution of the original BeagleBone. The main features of the board are an ARM Cortex A8 processor at 1 GHz with 512 MB RAM, and with Ethernet, USB, and HDMI connections and two headers of 46 pins GPIO. This GPIO can be set up as digital I/O, ADC, PWM, or for communication protocol like I2C, SPI, or UART. The GPIO is an easy way to communicate with sensors and actuators directly from the BeagleBone without intermediaries. The following is a labeled image of BeagleBone:

When the BeagleBone board came out, it was not possible to install ROS on the Ångström distribution. For this reason, it was common to install an operating system based on Ubuntu on the BeagleBone. There are different versions of Ubuntu ARM compatible with the BeagleBone Black and ROS; we recommend you use an image of Ubuntu ARM 13.04 raring armhf on the platform to work with ROS.

Now, a ROS version for Ångström distribution is ready to be installed; you can do it following the installation steps given at http://wiki.ros.org/hydro/Installation/Angstrom. Despite this possibility, we have chosen to install ROS on Ubuntu ARM because these distributions are more common and can be used on other ARM-based boards such as UDOO, ODROID U3, ODROID X2, or Gumstick.

The ARM technology is booming with the use of mobile devices such as smartphones and tablets. Apart from the increasing computer power of the ARM cortex, the great level of integration and low consumption have made this technology suitable for autonomous robotic systems. In the last few years, multiple ARM platforms for developers have been launched in the market. Some of them have features similar to the BeagleBone Black like the Raspberry PI or the Gumstick Overo. Additionally, more powerful boards like Gumstick DuoVero with a Dual Core ARM Cortex A9 or some quad core boards like Odroid U3, Odroid X2 or UDOO are now available.

Prerequisites

Before installing ROS on Beaglebone Black, we have to achieve some prerequisites. As this book is focused on ROS, we will list them without entering into detail. There is a lot of information about Beaglebone Black and Ubuntu ARM available on websites, forums, and books that you can check out.

First, we have to install an Ubuntu ARM distribution compatible with ROS. So, an image of Ubuntu ARM is needed. You can obtain an Ubuntu 13.04 Raring armhf using wget with the following command:

$ wget https://rcn-ee.net/deb/flasher/raring/BBB-eMMC-flasher-ubuntu-13.04-2013-10-08.img

Download the Ubuntu 13.04 armhf image and install it on your SD card. You can get more details on how to install Ubuntu on Bealgebone Black on eLinux at http://elinux.org/Beagleboard:Ubuntu_On_BeagleBone_Black#Ubuntu_Raring_On_Micro_SD.

The process described in the preceding webpage works fine, but we have to be careful with the version of Ubuntu used. As the website is periodically updated, they are now using Ubuntu 14.04, which is not compatible with ROS. We will use an Ubuntu 13.04 Raring armhf as mentioned earlier.

Once we have Ubuntu ARM on our platform, the Beaglebone Black network interfaces must be configured to provide access to the network. So, you will have to configure the network settings such as IP, DNS, and gateway.

Remember that the easiest way could be mounting the SD card in another computer and editing /etc/network/interfaces.

After setting up the network, we should install the packages, programs, and libraries that ROS will need such as CMake, Python, or Vim using the following commands:

$ sudo apt-get install cmake python-catkin-pkg python-empy python-nose python-setuptools libgtest-dev build-essential

$ sudo apt-get install g++ curl pkg-config libv4l-dev libjpeg-dev build-essential libssl-dev vim

The operating system for Beaglebone Black is set up for micro SD cards with 1-4 GHz. This memory space is very limited if we want to use a great part of the ROS Hydro packages. So in order to solve this situation, we can use SD cards with larger space and expand the file system to occupy all the space available with re-partitioning.

So if we want to work with a bigger memory space, it is recommended to expand the Beaglebone Black memory file system. This process is further explained at http://elinux.org/Beagleboard:Expanding_File_System_Partition_On_A_microSD.

You can do this by following the commands listed next:

  1. We need to become a super user, so we will type the following command and our password:

    $ sudo su
    
  2. We will look at the partitions of our SD card:

    $ fdisk /dev/mmcblk0
    
  3. On typing p, the two partitions of the SD card will be shown:

    $ p
    
  4. After this, we will delete one partition by typing 'd' and then, we will type 2 to indicate that we want to delete /dev/mmcblk0p2:

    $ d
    $ 2
    
  5. On typing n, a new partition will be created; if we type p it will be a primary partition. We will indicate that we want to number it as the second partition by typing 2:

    $ n
    $ p
    $ 2
    
  6. You can write these changes by typing w if everything is right, or eliminate the changes with Ctrl + Z:

    $ w
    
  7. We should reboot the board after finishing:

    $ reboot
    
  8. Once again, become a super user once the reboot is complete:

    $ sudo su
    
  9. And finally, run the following command to execute the expansion of the memory file system of the operating system.

    $ resize2fs /dev/mmcblk0p2
    

Now we should be ready to install ROS. At this point, the process of installation is pretty similar to the PC installation previously explained in this chapter. So, we should be familiar with it. We will see that the main difference when installing ROS on BeagleBone Black is that we can't install the ROS full-desktop; we must install it package by package.

Setting up the local machine and source.list file

Now you will start setting up your local machine:

$ sudo update-locale LANG=C LANGUAGE=C LC_ALL=C LC_MESSAGES=POSIX

After this, we will configure the source lists depending on the Ubuntu version that we have installed in BeagleBone Black. The number of Ubuntu versions compatible with BeagleBone Black are limited, and only active builds can be found for Ubuntu 13.04 raring armhf, the most popular version of Ubuntu ARM.

  • Ubuntu 13.04 Raring armhf:

    $ sudo sh -c 'echo "deb http://packages.namniart.com/repos/ros raring main" > /etc/apt/sources.list.d/ros-latest.list'
    
  • Ubuntu 12.10 Quantal armhf:

    $ sudo sh -c 'echo "deb http://packages.namniart.com/repos/ros quantal main" > /etc/apt/sources.list.d/ros-latest.list'
    
  • Ubuntu 12.04 Precise armhf:

    $ sudo sh -c 'echo "deb http://packages.namniart.com/repos/ros precise main" > /etc/apt/sources.list.d/ros-latest.list'
    

Setting up your keys

As explained previously, this step is needed 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:

$ wget http://packages.namniart.com/repos/namniart.key -O - | sudo apt-key add –

Installing the ROS packages

Before the installation of ROS packages, we must update the system to avoid problems of library dependencies.

$ sudo apt-get update

This part of the installation is slightly different for the Beaglebone Black. There are a lot of libraries and packages in ROS and not all of them compile fully on an ARM. So, it is not possible to make a full-desktop installation. It is recommended to install package by package to ensure that they will work on an ARM platform.

You can try to install ROS-base, known as ROS Bare Bones. ROS-base installs the ROS package along with the build and communications libraries but does not include the GUI tools:

$ sudo apt-get install ros-hydro-ros-base

We can install specific ROS packages by using the following command:

$ sudo apt-get install ros-hydro-PACKAGE

If we need to find the ROS packages available for BeagleBone Black, you can run the following command:

$ apt-cache search ros-hydro

For example, the following packages are the basics that work with ROS and can be installed individually using apt-get install:

$ sudo apt-get install ros-hydro-ros
$ sudo apt-get install ros-hydro-roslaunch
$ sudo apt-get install ros-hydro-rosparam
$ sudo apt-get install ros-hydro-rosservice

Although theoretically, not all the packages of ROS are supported by BeagleBone Black, in practice, we have been able to migrate entire projects developed on PC to BeagleBone Black. We tried a lot of packages, and we could only not install rviz.

Initializing rosdep for ROS

The rosdep command-line tool must be installed and initialized before you can use ROS. This allows you to easily install libraries and solving system dependencies for the source you want to compile, and is required to run some core components in ROS. You can use the following commands to install and initialize rosdep:

$ sudo apt-get install python-rosdep
$ sudo rosdep init
$ rosdep update

Setting up the environment in BeagleBone Black

If you have arrived at this step, congratulations because you have installed ROS in your BeagleBone Black. The ROS environment variables can be added to your bash, so they will be added every time a shell is launched:

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

We have to be careful if we have more than one version of ROS in our system. The bashrc setup must use the variables of the version being used only.

If we want to set up the environment in the current shell, we will run the following command:

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

Getting rosinstall for BeagleBone Black

Rosinstall is a common command-line tool in ROS that helps us to install packages easily. It can be installed on Ubuntu with the following command line:

$ sudo apt-get install python-rosinstall