Control a Star Wars BB-8 Droid With Arm Gestures and IBM Bluemix Internet of Things

What You'll Be Creating

Welcome! In our prior tutorial, Control a Droid With Your Mind and IBM Bluemix Internet of Things, we covered Joshua Carr's use of the Emotiv Insight headset to control a Star Wars BB-8 droid with his thoughts. If you don't believe me, check it out or watch the video below.

It's made possible with some amazing consumer hardware and IBM Bluemix integration with the Internet of Things.

In today's tutorial, I'll guide you through my interview with Consulting IT Specialist Rob Peeren. He created the featured video at the top, showing how he used an armband and arm gestures to control BB-8 with enough accuracy to play soccer (or concussion-free football as some call it).

We're also likely to continue this series on IBM Bluemix and the Internet of Things (IoT) with specific step-by-step tutorials about how to try out more of your own projects. Please let us know which types of IoT topics you'd like to see more written about in the future. 

If you'd like a broader overview of IBM Bluemix, I encourage you to watch David Barnes's introduction below:

As always, share your ideas and feedback in the comments below or reach me directly on Twitter @reifman. You can also reach out to Rob Peeren @robobob or via @IBMCloud.

Armband Controller Components

Here are the elements of Peeren's armband demonstration:

IBM Bluemix IoT Arm Gestures - The Components Used by Rob Peeren for Tutorial Today

You can buy the Myo armband in black or white for $199 USD:

IBM Bluemix IoT Arm Gestures - Myo Gesture Control Armband

Here are a couple of introductory videos of the Myo Armband which are fun to watch, especially if you haven't seen it before. 

Here's the general product introduction:

And this one is targeted more at developers:

They offer a variety of solutions for usage, as well as an excellent Developer site.

And of course, here's BB-8 again and how it came to be:

IBM Bluemix IoT Arm Gestures - Retail Box of Star Wars BB-8 Droid by Sphero

Building the Application

IBM Bluemix IoT Arm Gestures - View of BB-8 Darth Vader Golfball Raspberry Pi and Myo Armband

Now, let's dive in to how Peeren built the demonstration using IBM Bluemix Internet of Things. In today's episode, I'll be giving a general overview from my interview with Peeren. It's possible we'll do a step by step together in the near future—let us know us in the comments below if you'd be interested in this!

Here's a screenshot showing how Bluemix works with devices and the IoT:

IBM Bluemix IoT Arm Gestures - Hot it all fits together intro to Bluemix IoT

Here is a high-level architectural image of what's happening between Bluemix and each of the Raspberry Pis in Peeren's video (learn more about MQTT here):

IBM Bluemix IoT Arm Gestures - Device and Bluemix IoT Flowmap with MQTT

Setting Up a Bluemix Application

Since I'm not stepping you through the application setup, you may be interested in a tour of the Bluemix application UX given by IBM Design Lead, Tarun Gangwani:

Basically, you can create an application from any of the Bluemix boilerplates, including the Internet of Things Platform Starter.

IBM Bluemix IoT Arm Gestures - Boilerplates menu

Here is Peeren's Internet of Things Dashboard, which includes the SDK for NodeJS and the Internet of Things Platform which he uses to receive data from the Myo armband and send it to the BB-8:

IBM Bluemix IoT Arm Gestures - Bluemix Dashboard with IoT123 Demo App

Calibrating the Armband to Your Movements

Peeren recommends that you practice with the Myo armband after calibrating it. Here's a video from Creating a custom calibration of your Myo Armband which shows how this works (see also What can the Myo armband actually do):

Basically, you calibrate it with a few simple gestures and then practice your movements so that it can pick up your intentions. Peeren used the following gestures for the video:

  • Waving in to turn left
  • Waving out to turn right
  • Fist to make it stop
  • Spreading fingers to make it go
  • Raising your arm to spin 180 (Tony Hawk would be proud and then say, "Do it in mid-air Droid!")

Just as it took Carr hours to train the Emotiv Insight, Peeren says it takes practice to work with the Myo. Control systems aren't completely automatic yet—you can't just put on the helmet and accurately fly the helicopter (sorry to bum out you action movie writers.)

Sending Armband Telemetry to Bluemix

As I mentioned above, the blue Raspberry Pi receives input from the armband and sends it to the Bluemix cloud. It does this by running Python code and MQTT to communicate with Bluemix.

Essentially, the Myo Armband sends telemetry via Bluetooth to the Bluetooth adapter on the Raspberry Pi. Then, the Python code takes the telemetry and sends it to Bluemix in the cloud. All the data comes in as a JSON payload.

Here's a screenshot of Peeren's Python code:

IBM Bluemix IoT Arm Gestures - Python Code from the Demo

If you want to delve deeper in this area, I recommend checking out the Thalmic Labs Developer portal and its unofficial library page. You might also check out this related video of a Myo armband directing a Raspberry Pi wheeled robot (it has a great soundtrack):

Processing the Armband Data Within Bluemix

Within Bluemix, the data is transformable using the Node-RED visual editor. We need to convert the incoming Myo gestures into commands the BB-8 understands in its driver/language.

For example, armband up is translated to BB-8: start and stop. Here's a screenshot from Peeren's Node-RED translation flow:

IBM Bluemix IoT Arm Gestures - NodeRED Visual Wiring Editor

Delivering Commands to BB-8

To get commands from Bluemix to the robot, they are sent from Bluemix via the Internet to NodeJS and the Cylon.js SDK on the silver Raspberry Pi. The silver Pi sends commands via Bluetooth to the BB-8 droid.

Cylon.js is a JavaScript framework for robotics, physical computing, and the Internet of Things. It makes it incredibly easy to command robots and devices. There's also a specific Cylon.js SDK for Sphero's BB-8. See also the Cylon.js driver on GitHub.

Here's some of Peeren's Cylon code connecting from Bluemix via MQTT to BB8 via cylon-sphero-ble:

IBM Bluemix IoT Arm Gestures - Cylonjs JavaScript code from the Demo

Once the commands are received by the BB-8, its internal systems activate each command creating the droid's motion and lighting effects.

Key Takeaways

I asked Peeren what was hardest about this effort, and he replied, “It was actually fairly straightforward.” He said he's just connecting a bunch of APIs. 

“I didn’t build anything here. I didn’t write any device drivers or lower level code. I’m using the APIs and connecting in a standard way to Bluemix via the MQTT protocol. I didn’t have to invent anything to make it work."

Peeren wants to inspire us to think about using Bluemix in bigger ways. Certainly, I'm inspired by everything Bluemix can do with the Emotiv Insight headset, the Myo Armband and Raspberry Pi hardware. It's incredible how far the industry has come.

As a teenager, I experimented with voice signal capture and dreamed of recognition. In college, I experimented with pen tablet and how handwriting recognition might work (demonstrating this late one afternoon to Nathan Myhrvold helped me land my first job at Microsoft.) But now most of this is possible with Bluemix and the Internet of Things.

Peeren says, "The basic plumbing is very simple." And Bluemix offers over 120 enterprise-ready services; "It’s not just about armbands and robots." Or microphones and voice recognition—it's much more.

He suggests experimenting with the Bluemix analytics engine to raise the intelligence of the interpretation of gestures or its visual recognition capabilities.

When you build your own application in Bluemix, you have everything in one place. You don't have to go to different platforms. One place for business rules, a reporting rules engine, Hadoop, etc. The possibilities are nearly endless.

What's Next?

I hope you've enjoyed both our IBM Bluemix Internet of Things video demonstrations and tutorials. Perhaps you'll feel inspired to try building your own demonstration.

Peeren mentioned to me that the best part about Bluemix IoT is that nothing is ever very complicated. He's able to accomplish his goals by combining the building blocks which Bluemix and third-party providers offer.

IBM also offers a range of training and certification for Bluemix through its developerWorks sites. Here are some related resources:

If you'd like to see more on Bluemix and IoT, please let us know—post in the comments or reach us on Twitter @reifman or Rob Peeren @robobob or via @IBMCloud. If you build a cool IoT device application, let us know and perhaps we'll write a feature about yours!

You can look for future tutorials of all kinds from me on my Envato Tuts+ instructor page. I hope you'll also check out my two series How to Program With Yii2 and Building Your Startup With PHP about building Meeting Planner.

IBM Bluemix IoT Arm Gestures - IBM Logo and Bluemix Link

If you wish to learn more about IBM Bluemix and Internet of Things, visit

Related Links



Related Articles