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.
Before installing ROS on BeagleBone Black, we have to achieve some prerequisites. As this book 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:
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:
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:
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:
If you do not know the device assigned to the microSD, you can use the following command:
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.
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
):
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
):
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.
And add restricted to the sources, so you have something like this:
Then, update the sources running:
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:
- We need to become a super user, so we will type the following command and our password:
- We will look at the partitions of our SD card:
- On typing
p
, the two partitions of the SD card will be shown: - 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
: - 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
: - You can write these changes by typing
w
if everything is right, or eliminate the changes with Ctrl + Z: - We should reboot the board after finishing:
- Once again, become a super user once the reboot is complete:
- Finally, run the following command to execute the expansion of the memory file system of the operating system:
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:
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:
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:
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:
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):
We can install specific ROS packages with the following command:
If you need to find the ROS packages available for BeagleBone Black, you can run the following command:
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
:
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
:
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:
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:
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:
Basic ROS example on the BeagleBone Black
As a basic example, you can run a ROS core on one terminal on the BeagleBone Black:
And from another terminal publish a pose message (note you can press Tab Tab after geometry_msgs/Pose
and it'd autocomplete the message fields, that then you need to change since it'd have the default values):
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):
And now you should be able to see the pose published from the BeagleBone Black on your laptop doing:
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.