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 0x1101. 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:

17 comments

17 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 […]

  7. Migsantiago May 5th, 2009 5:18 pm

    Hello Todbot

    Thanks for sharing your program and library. I will try to write a simple COM port communication with a PC using MobileProcessing.

    Gratz on your project :D

  8. Migsantiago May 10th, 2009 6:53 pm

    I finished my program using RoombaCtrl as a guide. It basically sends via Bluetooth the key that the user presses on the cell phone. I created a tutorial in spanish using Mobile Processing…

    http://migsantiago.com/index.php?option=com_content&view=article&id=12&Itemid=13

    Thanks again Tod for your project. :D

  9. Philip Bevan October 29th, 2009 5:24 am

    I am a university student and have a final year project that requires me to be able to connect to a roomba and a meccano spkyee and enable a user/users to race the two robots through bluetooth. The user/users will be able to use accelerometers to control the robots and the robots will be able to race themselves also. This has been so much help and any feedback that anyone can provide would be extremely useful.

    Thanks all.

  10. kmykc » Bluetooth JAVA y MobileProcessing 0007 December 17th, 2009 12:19 am

    […] Articulo original. […]

  11. danilo March 9th, 2010 8:04 am

    quiero un programa o manual en java donde haya como funciona el j2me y j2se y con conectividad bluetooth..es para mi tesis…nesecito ayuda en eso….para asi pooderme guiarme y terminar mi tesis,…espero me ayuden gracias..

  12. danilo March 9th, 2010 8:20 am

    nesecito un programador en java con experiencia en j2me y j2se y con conectividad bluetooth..
    o un manuual para guiarme para poder hcacer mi tesis…..espero me puedan ayudar….

  13. Tayeb Habib September 16th, 2010 2:58 am

    Thanks Todd for your project.

    I used mostly your code to control a 8051-robot “Robo-51″.

    Some extra ideas were gotten from Pedro Dias’s project for NXT Lego (I believe using your code).

    All projects can be seen at:

    http://redacacia.wordpress.com/2010/09/15/controlling-a-robot-with-bluetooth-enabled-cell-phone/

    I have more Open Apps there. The direct link is:

    http://redacacia.wordpress.com/

    Tayeb

  14. Tayeb Habib June 7th, 2011 11:44 am

    Just to let know everyone, I have just tested the code I have written on Blackberry Bold 9700, software v.6.

    Apart from small irrelevant differences (some of sound files mentioned in my 2010 addenda did not work), I controlled perfectly my robot.

    Previously I had controlled the robot from a Nokia N97.

    Anyone interested can read all at:

    http://redacacia.wordpress.com/2010/09/15/controlling-a-robot-with-bluetooth-enabled-cell-phone/

    Please check fully the addenda in above link.

  15. Tayeb Habib June 8th, 2011 8:29 am

    Just something extra to add. The voice implementations works fully now in Blackberry Bold 9700. I had forgotten to add the sound files of different commands in my project folder. I believe my project should work in any Blackberry smart phones.

  16. Clayder June 16th, 2011 1:46 pm

    Hi!

    I download the program for my sony ericsson w760i and the first three times it worked well. Yesterday, I was creating a midlet based on your code; however, it didn’t work well. The problem is that when I went back to run roombactrl again, it wasn’t was able to find the serial port of my computer; it finds my computer, but not the serial port, I think it’s the same problem tha v3iuser has, with the difference that the program worked well for the first 3 times.

    What do you think could be the problem?

  17. Robot App Store May 29th, 2012 12:04 am

    No more struggling! get source code and examples from the Robot App Store programming guide to Roomba: http://www.robotappstore.com/Knowledge-Base/1-Introduction-to-Roomba-Programming/15.html

    After you develop your robot-app, you can also sell it on the marketplace!

Leave a reply