Beaglebone black for robotics development13 Sep 2015
The Beaglebone black is easily my favourite Embedded linux platform. It’s cheap, open-source and offers a great amount of functionnalities. Through this article, I would like to document my default setup for the board so I can start developing on it.
What’s even greater about this board is it’s surprisingly easy to use thanks to some great engineering and a great community of developers. All you need to use this board is the mini USB cable that comes with it: it powers it and emulates an ethernet connection over USB.
Choosing a Linux distribution, the eternal argument
The choice for a Linux distribution is always subject to discussion. The most popular distros on embedded computer boards are Yocto, Angstrom and Debian. The last two are supported by the Beagleboard organisation1. But I like Ubuntu better, that’s what I run on my laptop, its setup time is short and you will have less problems with drivers.
Fortunately, an official Ubuntu image is supported and maintained by the Beagleboard organisation.
So, start by downloading the image from them, uncompress it and then copy the image into your SD card (in my case under
Now remove it from your computer and plug it in the Beaglebone. Press the S2 button while powering it up so it boots from the SD card and starts flashing the image to the eMMC. After a few seconds, the LEDs should start in a K2000/Cylon way. Once the LEDs are off, it’s done, you can unplug/replug it and SSH into it.
If network manager is giving you a hard time, switch the LAN interface to manual by modifying your
/etc/network/interfaces file, mine looks like this:
Now, if you did this, before you can SSH into the board you will need to configure your IP over the shared network (let’s say
Linux, RT-PREEMPT or Xenomai, the roboticist’s dilemma
If you are starting to play with embedded linux platforms and just want to try to build some cool little thing, skip this part. If you are trying to build more complex systems that impose constraints on the execution time of your tasks, then read this part.
A good comparison between these three solutions is made by this article titled: How fast is fast enough? Choosing between Xenomai and Linux for real-time applications2 by Dr. Jeremy H.Brown and Brad Martin. The TL;DR of the article is that Linux is OK for soft real-time applications, but for hard real-time requirements you’ll either need RT-PREEMPT or Xenomai. The best solution being Xenomai although it requires more effort to install. On most boards you would need to maintain your own kernel with the Xenomai patch, but luckily for us there is a prepackaged kernel available for the Beaglebone in the official repositories. I told you the community was great.
If you want to install Xenomai on your Beaglebone, I suggest you check the section “Xenomai installation: the easy way (3 steps)” of my previous article on the subject3.
Slaying Cerberus: IO setup made easy
In the early years of embedded linux, the boards were dark and full of terrors. IO configuration was a hell of task that required kernel recompilation. Luckily, now we have the device tree4. They were introduced as a way of decoupling hardware dependencies from the Linux kernel. And they made IO configuration at runtime possible.
Writing a device tree overlay may seem hard but if you’re familiar with IO configuration on microcontrollers it’s quite similar. But we are not going to write any device tree overlay. Thanks to cdsteinkuehler, we have beaglebone-universal-io5, an amazing tool that reduces pin configuration from writing 30 somewhat complicated lines of configuration to a single line in the command line. So we are going to install this on our board:
Now we can start messing with the IOs. For example if I want to have a GPIO at pin 20 from header 9, I can just type
And that’s it. Told you it was going to be easy. To understand more of what you can do with this tool, go read the documentation.
Finding a low-level library to use the hardware peripherals
There are some neat libraries out there that allow you to use the Beaglebone’s peripherals with a nice Python API for instance. I can think of the PyBBIO library6 by graycatlabs or the Adafruit library7. But my favourite is the MRAA library8 developped by the IOT team at Intel.
It was first meant to be a library for the Edison, but it soon became compatible with the Raspberry Pi and the Beaglebone black (and other boards). That way it provides a nice low-level library that abstracts the hardware to some extent. This library is written entirely in C and it provides severals APIs: C, C++, Python and NodeJS. So you can do anything from real-time robotic applications to Web-based/IOT applications.
To install it, do the following:
We are almost done:
The last command should output the list of all IOs on the board with the possible configurations for each pin.
The workflow is the following: you setup the IO function using the
config-pin command from beaglebone-universal-io and then you use mraa library to use that peripheral on that pin.
Now you can go write some cool application. Unless that’s not enough for you.
We need to go higher: installing ROS
Let’s say you want to build some little robot with computer vision for navigation. You can write your PWM driver to control your motors with the mraa library, but how can you do the vision part? A few years ago, I would have told you to install opencv and work from there. But you would most certainly get stuck communication-wise: how do you interface your vision code with the motor controller part. It turns out there is a very popular framework out there, in the wild forest of open-source projects, that is awesome at interfacing differents chunks of code that perform different tasks: ROS9.
ROS stands for Robot Operating System. It’s not and OS per se, it’s more like a virtual machine that runs on top of Linux. In some ways it’s similar to dbus as it enables inter process communication, but it’s safer to use and, I would argue, easier.
Using ROS to build your robotics application also opens the door to use a wide range of nodes written by other people that do can anything from reading a camera to performing SLAM with stereo vision. So you may even be able to reuse and tweak some existing code to complete your little robot with vision-aided navigation.
This gives you the base install which is lightweight enough to fit on the Beaglebone black’s 4GB eMMC. You can go on and search for ROS packages that may be of interest to your application and look up how to install them and use them.
That’s it for this guide. You should now have all the tools you need to start developing on your Beaglebone black. Go make some awesome stuff.
How fast is fast enough? Choosing between Xenomai and Linux for real-time applications by Dr. Jeremy H.Brown and Brad Martin https://www.osadl.org/fileadmin/dam/rtlws/12/Brown.pdf ↩
Xenomai installation on a Beaglebone black http://syrianspock.github.io/embedded-linux/2015/08/03/xenomai-installation-on-a-beaglebone-black ↩
beaglebone-universal-io repository on Github https://github.com/cdsteinkuehler/beaglebone-universal-io ↩
Adafruit library for Beaglebone black repository on Github https://github.com/adafruit/adafruit-beaglebone-io-python ↩
Creating a workspace for catkin from the ROS official wiki http://wiki.ros.org/catkin/Tutorials/create_a_workspace ↩