Hacking Roomba

RoombaCtrl: Drive your Roomba with your cell phone

[originally published 12 September 2006 on todbot]

Ever since Bluetooth adapters for Roombas appeared, I’ve wanted to control my Roomba with a cell phone. All my recent phones have had Bluetooth. But getting a devkit for a phone was expensive and phone-specific. Trying to develop J2ME (aka “JavaME”) applications for cell phones has been a mess, especially for non-Windows users. Thankfully, Mobile Processing wraps up the ugly details, like Processing does for normal Java. It makes writing little programs for your phone pretty easy, and makes whipping up a program to control a Roomba possible.

So here’s “RoombaCtrl”, a small Java program for your Bluetooth- and J2ME-compatible phone that works with the build-your-own Bluetooth adapter shown in the book “Hacking Roomba” or the pre-built RooTooth.

RoombaCtrl Demo

Now you can drive your Roomba with your cellphone like so:

Download

You can download RoombaCtrl compiled, ready to install:
- roombactrl-1.0.jar
- roombactrl-1.0.jad
The “jad” file is if you’re doing “over-the-air” (OTA) installation. Don’t worry about that though. Just grab the jar file and copy it over with Bluetooth file transfer.

You can also download the Mobile Processing source:
- roombactrl-1.0-src.zip
Unzip that into your MobileProcessing sketch folder, open Mobile Processing, and choose RoombaCtrl from the available Sketches. Or if you want to see the entire source code right now:
- roombactrl.pde

You’ll also need a slightly patched Mobile Processing Bluetooth library:
- mobileprocessing-bluetooth-patched.zip
In the “libraries” directory of the Mobile Processing application, move the existing “bluetooth” library directory out of the way and unzip the above zipfile in its place.

Mobile Processing Bluetooth Library Patch

The patch for Mobile’s Bluetooth library is only a few lines long:
- Mobile-0005-Bluetooth.patch
All the patch does is allow one to specify short UUIDs when searching for services. The standard Bluetooth Serial Port Profile (SPP) has a short UUID of 0×1101. All the Roomba Bluetooth adapters appear as normal serial ports using SPP.

This patch allows you to search for Bluetooth serial ports (instead of other Mobile Processing apps) by doing:

Bluetooth bt = new Bluetooth(this, Bluetooth.UUID_SERIALPORT);

Conceivably, you could add additional static defines for the other pre-defined Bluetooth UUIDs.

RoombaCtrl Buildling and Installation

Installing a program on a cell phone can be mysterious; some cell providers even prohibit you from downloading programs. If you have Bluetooth on your phone, installation becomes a simple file transfer.

Building MIDlets (Java applets for cell phones) can also be a little puzzling. Mobile Processing makes it easier, but it still assumes a little too much knowledge. Mobile Processing is still pretty new so perhaps as it ages it’ll get easier. Of course, it doesn’t help that Sun doesn’t make a cross-platform toolkit for developing MIDlets.

Below is a small movie showing how, if everything is configured correctly, building and installing a new Mobile Processing program on your phone can be pretty quick. It uses Mac OS X, but the techniques are the same for any OS.

Useful Links

I had a real time trying to figure out why Mobile Processing wouldn’t let me talk to Bluetooth Serial Devices. I ended up learning how to write Java MIDlets by hand. Here’s some of the links I got knowledge from:

6 Comments so far

  1. homer December 5th, 2006 10:25 am

    I uploaded the .jar file to my Moto V330 but the program would not run, it gave me an error. When I tried to run roomvactrl in mobile processing I got the following error: roombactrl.java:1:71:1:96: semantic error: the instance method “int freememory();” cannot override the accessible static method “long freememory();” declared in type “javax.microdition.midlet.MIDlet”

  2. homer December 5th, 2006 10:40 am

    The error message on the Moto V330 phone is “application error”.

  3. v3iuser January 22nd, 2007 1:12 pm

    On my v3i the program runs and finds my bluesmirf but never finds the serial port. Has anyone overcome this problem?

  4. todbot January 22nd, 2007 1:37 pm

    There seems to be some differences in the J2ME serial port implementations on different phones. If you want you can look at the Mobile Processing site to see if there’s been some improvement in that area. I suspect there is not, but feel free to play with the source code, maybe with some changes you can get it to work on your phone. Writing cross-platform software for phones that interact with serial ports seems to be hard.

  5. My robotic vacuum - Kawasaki Motorcycle Forums September 15th, 2007 12:42 am

    […] do all sorts of stuff? Although I haven’t gotten into this myself (yet… ) this is on of my favs: Hacking Roomba RoombaCtrl: Drive your Roomba with your cell phone __________________ aka scott 2007 vulcan 1600 mean streak se ktf dtrt ftm-ptb egh The world is a […]

  6. My robotic vacuum - Kawasaki Motorcycle Forums September 16th, 2007 5:41 pm

    […] do all sorts of stuff? Although I haven’t gotten into this myself (yet… ) this is one of my favs: Hacking Roomba » RoombaCtrl: Drive your Roomba with your cell phone __________________ aka scott 2007 vulcan 1600 mean streak se ktf dtrt ftm-ptb egh The world is a […]

Leave a reply