ROS on Ubuntu on Beaglebone Black (BBB) Rev. C

Introduction

Beaglebone Black (BBB) is a very nice single-board PC that offers numerous features. When it comes to building robots that can do nontrivial tasks, it is my first choice. Installing an OS on the BBB and getting it ready to use can be time consuming. By following the simple steps provided in this post, large amounts of time can be saved and devoted instead to development of the software to accomplish the targeted tasks of the robot.

Although BBB comes with a pre-installed copy of the Debian Jessie Linux distribution, ROS developers do not currently build packages for Kinetic Jessie for armhf architecture; they only provide builds for amd64 and arm64  (as mentioned here).  However, they have armhf builds for Ubuntu Xenial. Because Ubuntu is my favorite Linux distribution, this was a breeze for me!

I hope this post will help you save some time. Also, please don’t hesitate to share your comments and suggestions to help make this post better. I will be using it as a living document that I will always try to update to reflect best approaches reached.

Installing Ubuntu Xenial on BBB

Using an SD card to flash the eMMC is easy for Windows users. An SD card ≥ 2GB is needed (I used 16GB). I will cover the necessary steps using Windows as this is what I used.

  1. Get the latest image here.
  2. Download SD Formatter here or here. You will need to use this if you decide to rewrite the image on the card as you’ll notice that formatting the card  the normal way results in a shrunk card size.
  3. Download Win32 Disk Imager here. You will need this to burn the image onto the SD card.
  4. Download 7-Zip here. You will need this to extract the .xz compression of the .img file.

Now that you’ve downloaded these files, follow the below steps to prepare your SD card for burning the image to the BBB’s eMMC.

  1. Use 7-Zip to extract the compressed image. This results a .img file.
  2. Open Win32 Disk Imager, select  your BBB’s drive letter, and select your Ubunutu .img file.
  3. Once you are done, safely remove the SD card.

I would like to note here that, having read a few articles here and there during the many installs that I’ve done on the BBB, I always had the misconception that connecting the BBB to the USB port of my laptop is not a good idea when running the install and it is better to use 5V adapter for that purpose. THIS IS NOT TRUE. Continue reading to learn what really matters to initiate a successful install.

The important thing to keep in mind when starting to burn the image on the BBB is to do the following:

  1. Insert the card into the BBB. It doesn’t really matter whether it is on or off.
  2. Connect the BBB to the USB port of your computer if not connected.
  3. Press the reset button.
  4. To tell if an install has been successfully initiated, the four user LEDs should start to light in a sweeping sequence and continue for around 20 minutes.

Sometimes, the sweeping sequence may stop after a couple of minutes and the install will fail. You will know this by observing that the LEDs will all stay on. If this happens, just redo step 3 until the sweeping persists roughly for the amount of time mentioned above.

When the install finishes, the LEDs will light up steadily. You can then remove the SD card and press the restart button.

Congratulations! you have just installed Ubuntu on your BBB.

Connecting  to  BBB through Putty

The next step is to be able to connect to the BBB through USB. Do the following:

  1. Get and install Putty from here.
  2. With the BBB plugged in to the USB port of your computer, browse to your BBB’s drive, find the suitable drivers for your Windows architecture, e.g. 64-bit vs 32-bit and install them.
  3. Run Putty and enter the IP address 192.168.7.2 in Host Name  and 22 in Port.
  4. Pick a suitable name for your session (e.g. BBB)  then click Save.
  5. With the saved session selected,  click Open.
  6. A terminal will be opened and, if Ubuntu installation was successful, you will be prompted to enter a username.
  7. Type ubuntu and hit Enter.
  8. Enter temppwd for the password.
  9. You are now logged into your embedded Ubuntu instance.

You can display the release info of your Ubuntu instance using the cat command as follows: cat /etc/*release

Connecting your  BBB to the Internet  through USB

If you try pinging 8.8.8.8 (www.google.com), you will not get any response. This is because the BBB doesn’t know how to connect to the internet through USB. Hitting Ctrl+c will show that no packets have been received.

To enable internet access through USB on Windows, follow these steps:

1) Bridging your network connection

  1. Go to Control Panel\Network and Internet\Network Connections.
  2. Identify the two adapters that represent the connection used by your computer and the one representing the BBB. In my case, these were WiFi and Ethernet 3, respectively. BBB’s connection will contain Linux USB Ethernet/RNDIS Gadget in its device description section of the name.
  3. Go to the Sharing tab in the properties of the connection used by your computer and check Allow other users to connect through this computer’s internet connection.  Next, select BBB’s connection from the dropdown menu.
  4. Switch to the Networking tab  and edit the Properties of Internet Protocol Version 4 (TCP/IPv4) to make sure that IP and DNS server addresses are obtained automatically.
  5. Repeat the previous step for BBB’s network adapter.

2) Configuring  internet connectivity on your BBB

Now that we have created the bridge between the USB connection that connects the BBB to the computer and the one that connects the computer to the internet, it is time to configure the BBB to be able to utilize that bridge.

Switch to Putty and do the following steps:

  1. Set the default gateway of your BBB to your computer’s IP address by using the command:
  2. sudo /sbin/route add default gw 192.168.7.1
  3. If you try to ping googe’s IP address (8.8.8.8) now, you should be able to receive packets.
  4. To be able to use domain names instead of IP address, you need to configure the name servers in your resolve.conf. You can do this by editing  that file and adding google’s name servers as follows:
  5. sudo nano /etc/resolv.conf

    Add these to the file:

  6. domain localdomain
    search localdomain
    nameserver 8.8.8.8
    nameserver 8.8.4.4
  7. If you try to ping www.google.com, you will get a similar response to this:

There is a caveat with this approach:

CAVEAT 1 – Sometimes, the bridged connection can fail and attempting to connect to the internet from the BBB will not work. This can be fixed by unchecking the “Allow other users to connect through this computer’s internet connection” in the Sharing tab of the main connection’s settings then re-applying it and selecting the second connection from the menu.

The other thing to keep in mind is that running the above steps enables internet connectivity only until the BBB is restarted. If you’d like these changes between restarts (the almost certain scenario), you need to add the commands that set the default gateway and name servers to the rc.local file as follows:

  1.  Edit the rc.local file in you favorite editor.
  2. sudo nano /etc/rc.local
  3. Add the two following lines to the end of the file.
  4. # set default gateway
    /sbin/route add default gw 192.168.7.1 || exit 1
    
    # append nameservers to the end of the /etc/resolve.conf file
    # echo "domain localdomain\nsearch localdomain\nnameserver 8.8.8.8\nnameserver 8.8.4.4" > /etc/resolv.conf || exit 2

Installing  ROS on Ubuntu on BBB

Now that you are connected to the internet, you can install ROS on your Ubuntu. The following sections show you how to do this and are adapted versions from ROS’s installation instructions on Ubuntu install of ROS Kinetic page.

1) Updating APT Configuration

First you need to configure apt‘s sources list to allow it to accept packages from all kinds of repositories that Ubuntu recognizes (Main, Universe, Restricted, and Multiverse). This can be done using the following steps:

  1. Use your favorite text editor to edit the sources.list file:
  2. sudo nano /etc/apt/sources.list
  3. Add restricted, universe, and multiverse after main to the two entries  containing Ubuntu’s release name and updates (xenial and xenial-updates in my case). These entries represent the URI’s of the binaries or pre-compiled packages for Xenial and its updates.
  4. Save the file and quit.

Next, ROS’s packages repository URI need to be added to sources.list. Although this will work, it is better to use the sources.list.d directory to add dedicated file to list ROS sources. This can be done as follows:

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

This command basically says: run the shell command echo, plugging in Ubuntu’s release name in the args section of the source’s entry and redirect the standard output to the file ros-latest.list.

The last step of this configuration is to add an authentication key to apt to make it trust the packages supplied by ROS’s repository. This can be done using this command:

wget http://packages.ros.org/ros.key -O - | sudo apt-key add -

The -O option of wget specifies where to direct the output of the download. By using the '-', we are telling it to direct it to standard output.  Similarly, the use of the '-' when adding the key using apt‘s key management utility apt-key, means read it from standard input.

At this point, you should be ready to start the installation process for ROS …

2) ROS Install

Now that package sources have been specified, we need to resynchronize apt‘s package index files from their sources. Run the following command:

sudo apt-get update

To confirm that ROS Kinetic packages are now available and can be installed, you can search the cache as follows:

apt-cache search ros-kinetic

On ROS’s Kinetic install on Ubuntu (here) under Section 1.4 Installation, different install options based on the different needs. In my case, I selected ros-base (bare bones) as I believe this should do the job on a BBB. If any specific packages are found to be needed later, individual install can be performed. To make sure that ros-base is available,  you may want to run the above command piping the output to grep.

apt-cache search ros-kinetic | grep ros-base

You can now install ros-kinetic-ros-base using apt as follows:

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

Congratulations!! you now have ROS Kinetic on BBB … but there are a few things that you need do before starting to play with ROS and start building robots …

3) Initializing Some Tools

One of the tools you will likely need is rosdep, which is a command line system dependency installation tool. It is especially useful if you are a developer and want to build packages from source. It is also required by some ROS core components. Because it has been already installed as part of ROS install, we only need to initialize it and update it to get any new definitions. To confirm it is already installed, you can run:

rosdep --version

In my case, the installed version was 0.11.5. To initialize and update rosdep, you can run the two following commands:

sudo rosdep init
rosdep update

As recommended by ros.org, it is useful to configure ROS environment variables to be automatically set on shell start. This can be done by adding the command that sources ROS’s setup.bash to your .bashrc. This can be done as follows:

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

The first command appends the setup.bash sourcing command to the end of the .bashrc file so that it can be run at the start of every bash session. The second command sources the .bashrc file for the current session to make it source setup.bash.

Another useful tool for downloading ROS package sources is rosinstall. This can obtained using apt as follows:

sudo apt-get install python-rosinstall

References

  1. Nootrix: ROS Installation Made Easy
  2. ROS.org: Ubuntu install of ROS Kinetic
  3. apt-key man page
  4. Ubuntu Repositories
  5. Ubuntu Repositories/CommandLine
  6. BeagleBoard Ubuntu
  7. ROS Answers: Incomplete packages for kinetic armhf jessie
  8. How to Connect a Beaglebone Black to the Internet via USB
  9. rosdep

 

Leave a Reply

Your email address will not be published. Required fields are marked *