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
ROS Programming: Building Powerful Robots

You're reading from   ROS Programming: Building Powerful Robots Design, build and simulate complex robots using the Robot Operating System

Arrow left icon
Product type Course
Published in Mar 2018
Publisher Packt
ISBN-13 9781788627436
Length
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Authors (5):
Arrow left icon
Anil Mahtani Anil Mahtani
Author Profile Icon Anil Mahtani
Anil Mahtani
Aaron Martinez Aaron Martinez
Author Profile Icon Aaron Martinez
Aaron Martinez
Lentin Joseph Lentin Joseph
Author Profile Icon Lentin Joseph
Lentin Joseph
Enrique Fernandez Perdomo Enrique Fernandez Perdomo
Author Profile Icon Enrique Fernandez Perdomo
Enrique Fernandez Perdomo
Luis S√°nchez Luis S√°nchez
Author Profile Icon Luis S√°nchez
Luis S√°nchez
+1 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (37) Chapters Close

Title page
Copyright and Credits
Packt Upsell
Preface
1. Getting Started with ROS FREE CHAPTER 2. ROS Architecture and Concepts 3. Visualization and Debugging Tools 4. The Navigation Stack - Robot Setups 5. The Navigation Stack - Beyond Setups 6. Manipulation with MoveIt! 7. Using Sensors and Actuators with ROS 8. Computer Vision 9. Point Clouds 10. Working with 3D Robot Modeling in ROS 11. Simulating Robots Using ROS and Gazebo 12. Working with Pluginlib, Nodelets, and Gazebo Plugins 13. Writing ROS Controllers and Visualization Plugins 14. Interfacing I/O Boards, Sensors, and Actuators to ROS 15. Programming Vision Sensors using ROS, Open-CV, and PCL 16. Building and Interfacing Differential Drive Mobile Robot Hardware in ROS 17. Exploring the Advanced Capabilities of ROS-MoveIt! 18. ROS for Industrial Robots 19. Troubleshooting and Best Practices in ROS 20. Face Detection and Tracking Using ROS, OpenCV and Dynamixel Servos 21. Building a Siri-Like Chatbot in ROS 22. Controlling Embedded Boards Using ROS 23. Teleoperate a Robot Using Hand Gestures 24. Object Detection and Recognition 25. Deep Learning Using ROS and TensorFlow 26. ROS on MATLAB and Android 27. Building an Autonomous Mobile Robot 28. Creating a Self-Driving Car Using ROS 29. Teleoperating a Robot Using a VR Headset and Leap Motion 30. Controlling Your Robots over the Web 1. Bibliography
2. Other Books You May Enjoy Index

Installing ROS in BeagleBone Black


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 GPIO pins.

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 that you use an image of Ubuntu ARM 16.04 Xenial armhf on the platform to work with ROS.

Now, an ROS version for Ångström distribution is ready to be installed; you can do so following the installation steps given at http://wiki.ros.org/kinetic/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, ODROIDU3, ODROIDX2, or Gumstick.

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 has 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, such as the Raspberry PI or the Gumstick Overo. Additionally, more powerful boards like GumstickDuoVero with a Dual Core ARM Cortex A9 or some quad core boards like OdroidU3, OdroidX2 or UDOO are now available.

Prerequisites

Before installing ROS on BeagleBone Black, we have to achieve some prerequisites. As this section is focused on ROS, we will list them without going 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 16.04 Xenial armhf using wget with the following command:

$ wget https://rcn-ee.com/rootfs/2016-10-06/elinux/ubuntu-16.04.1-console-armhf-2016-10-06.tar.xz

From the URL https://rcn-ee.com/rootfs you can look for newer versions too. This version is the one mentioned in the official documentation at http://elinux.org/BeagleBoardUbuntu.

Once the image is downloaded, the next step is installing it on a microSD card. First, unpack the image with the following commands:

$ tar xf ubuntu-16.04.1-console-armhf-2016-10-06.tar.xz
$ cd ubuntu-16.04.1-console-armhf-2016-10-06

Insert a microSD of 2 GB or more on the card reader of your computer and install the Ubuntu image on it with the following setup script:

$ sudo ./setup_sdcard.sh --mmc DEVICE --dtb BOARD

In the preceding script, DEVICE is the device where the microSD appears on the system, for example /dev/sdb, and BOARD is the board name. For the BeagleBone Black it would be beaglebone. So, assuming the microSD is in /dev/mmcblk0, and you are using a BeagleBone Black, the command would be as follows:

$ sudo ./setup_sdcard.sh --mmc /dev/mmcblk0 --dtb beaglebone

If you do not know the device assigned to the microSD, you can use the following command:

$ sudo ./setup_sdcard.sh --probe-mmc

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 the IP, DNS, and gateway.

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

Another easy way consists on using an Ethernet cable and running the DHCP client to obtain an IP address.

$ sudo dhclient eth0

For this, you need to boot up the BeagleBone Black with the microSD. For that, you need to keep the S2 button press before you power on the board, either with the DC or USB connector. After some minutes the system will show the login prompt. Log in with the user ubuntu and password temppwd (default ones) and then run the DHCP client command shown above with the Ethernet cable connected. Then, you can check the IP address assigned using (look at the inet addr: value):

$ ifconfig eth0

In our setup, we have connected to the BeagleBone Black the following devices (as shown in the image below):

  • HDMI (with microHDMI adapter) cable to see terminal prompt on the screen during the network setup; after that we can SSH into the board
  • Keyboard connected through USB
  • Power supplied through the microUSB connector
  • Ethernet cable to access the Internet, as explained so far

After setting up the network, we should install the packages, programs, and libraries that ROS will need. Now that the network is up, we can also SSH into the board with (assuming the IP address assigned to it is 192.168.1.6):

$ ssh ubuntu@192.168.1.6

We are going to follow the instructions in http://wiki.ros.org/indigo/Installation/UbuntuARM, but with the changes required so they work for ROS kinetic (note they are still for indigo on the web). The first step consists on setting up the repository sources so we can install ROS.

$ sudo vi /etc/apt/sources.list

And add restricted to the sources, so you have something like this:

deb http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe multiverse
#deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe multiverse
#deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe
multiverse
#Kernel source (repos.rcn-ee.com) : https://github.com/RobertCNelson/linux-stable-rcn-ee
#
#git clone https://github.com/RobertCNelson/linux-stable-rcn-ee
#cd ./linux-stable-rcn-ee
#git checkout `uname -r` -b tmp
#
deb [arch=armhf] http://repos.rcn-ee.com/ubuntu/ xenial main
#deb-src [arch=armhf] http://repos.rcn-ee.com/ubuntu/ xenial main

Then, update the sources running:

$ sudo apt-get update

The operating system for BeagleBone Black is set up for micro SD cards with 1-4 GB. This memory space is very limited if we want to use a large part of the ROS Kinetic packages. In order to solve this problem, we can use SD cards with more 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.

Although the following steps are not needed in general, they are here in case you need them in your particular case. You can proceed by following these commands:

  1. We need to become a super user, so we will type the following command and our password:
$ sudo su
  1. We will look at the partitions of our SD card:
$ fdisk /dev/mmcblk0
  1. On typing p, the two partitions of the SD card will be shown:
$ p
  1. 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
  1. 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
  1. You can write these changes by typing w if everything is right, or eliminate the changes with Ctrl + Z:
$ w
  1. We should reboot the board after finishing:
$ reboot
  1. Once again, become a super user once the reboot is complete:
$ sudosu
  1. 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 is limited, and only active builds can be found for Ubuntu 16.40 Xenial armhf, the most popular version of Ubuntu ARM. Run the following to install the Ubuntu armhf repositories:

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -cs) 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:

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

Installing the ROS packages

Before the installation of ROS packages, we must update the system to see all the packages on the ROS repository just added:

$ 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 that you install them 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 (press ENTER (Y) when prompted):

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

We can install specific ROS packages with the following command:

$ sudo apt-get install ros-kinetic-PACKAGE

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

$ apt-cache search ros-kinetic

For example, the following packages are the basics (already installed as ros-base dependencies) that work with ROS and can be installed individually using apt-get install:

$ sudo apt-get install ros-kinetic-ros
$ sudo apt-get install ros-kinetic-roslaunch
$ sudo apt-get install ros-kinetic-rosparam
$ sudo apt-get install ros-kinetic-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 the only one that we could not install was rviz, which is indeed not recommended to run on it.

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 solve 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 the 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/kinetic/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/kinetic/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:

$ sudo apt-get install python-rosinstall

Basic ROS example on the BeagleBone Black

As a basic example, you can run a ROS core on one terminal on the BeagleBone Black:

 

$ roscore

And from another terminal publish a pose message (note you can press TabTab after geometry_msgs/Pose and it'd autocomplete the message fields, that then you need to change since it'd have the default values):

$ rostopic pub /dummy geometry_msgs/Pose
Position:
x: 1.0
y: 2.0
z: 3.0
Orientation:
x: 0.0
y: 0.0
z: 0.0
w: 1.0 -r 10

Now, from your laptop (in the same network), you can set ROS_MASTER_URI to point to the BeagleBone Black (IP 192.168.1.6 in our case):

$ export ROS_MASTER_URI=http://192.168.1.6:11311

And now you should be able to see the pose published from the BeagleBone Black on your laptop doing:

$ rostopic echo -n1 /dummy
Position:
x: 1.0
y: 2.0
z: 3.0
Orientation:
x: 0.0
y: 0.0
z: 0.0
w: 1.0
---

If you use a PoseStamped, you can even visualize it on rviz.

From this point, you can check multiple projects at http://wiki.ros.org/BeagleBone, as well as another installation option, which uses the Angstrom OS instead of Ubuntu, but it does not support ROS Kinetic at the moment.

You have been reading a chapter from
ROS Programming: Building Powerful Robots
Published in: Mar 2018
Publisher: Packt
ISBN-13: 9781788627436
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