RoombaMidi: Roomba as MIDI instrument

[Update: an improved version of this idea, called RoombaMidi2, is available on the HackingRoomba.com Projects area.]

The Roomba has a piezo beeper that can play tunes. You’ve heard it.
And its motors make noise. Why not put them under MIDI control?

So here is RoombaMidi: a Mac OS X application that creates a virtual MIDI instrument for use by any Mac OS X MIDI sequencer, like Ableton Live, Logic, and so on.

If you don’t have a sequencer or just want to play with this quickly, grab the awesome and free app MidiKeys. It’s a little virtual MIDI keyboard.

RoombaMidi has the following features:
– provides GUI interface to controlling Roomba (MIDI not required)
– acts as normal MIDI interface to any MIDI application
– supports up to 16 Roombas, one per MIDI channel.
– responds to MIDI notes 32-127 as tones on Roomba beeper,
– MIDI notes 32-127 play corresponding pitch, velocity is duration in 1/64ths-second increments
– MIDI note 24 turns vacuum motor on-n-off for bass drum fun
– MIDI note 25 blinks the LEDs, velocity is color of Power LED
– MIDI note 28 & 29 spins left or right, velocity is speed of spin
– can act as general multi-Roomba test system
– written in Java, but acts like Mac OS X application

To download:
RoombaMidi-0.9.zip
RoombaMidi-0.93-Panther.zip, for Mac OS X 10.3, aka Panther

And if you really want to look at the source…

Here’s what RoombaMidi looks like:
roombamidi1

The about page:
roomba midi about

Here’s one example use:

revver version

Other recorded compositions are forthcoming….

(as always thanks to MikeK for helping with this)

RoombaComm: Roomba Control & Communications API, release 1

This is an updated version of the RoombaComm API.

This release contains Javadoc documentation!

This release further expands on the two different levels of driving API: a lower-level one that is based on velocity, and a higher-level distance/angle one. I’m debating how to notate these differences. For instance:

roombacomm.setSpeed( 100 ); // set speed to 100 mm/sec
roombacomm.goForward( 150 ); // go forward 150 mm
roombacomm.spinRight( 45 ); // spin 45 degrees right
roombacomm.goBackward( 25 ); // go 20 mm backward

vs.

roombacomm.goForwardAt(100); // go forward at 100mm/sec
roombacomm.pause( 1500 ); // wait for 1.5 seconds, so it goes 150 mm
roombacomm.spinRightAt( 100 ); // spin right at 100mm/sec
float ptime = 45.0 * roombacomm.millimetersPerDegree / 100.0;
roombacomm.pause( ptime ); // wait until the Roomba has spun thru the angle

The wacky angle calculation above is the primary reason why I wanted a higher-level API. I want to do more Logo-like things.

HOWTO: Mac OS X Bluetooth Serial Port

Setting up a Bluetooth serial adapter like the SparkFun BlueSMiRF isn’t very hard, but not very intuitive.

Bluetooth supports many “profiles” for doing various things (phone headset, address book syncing, file exchange, etc.) One of these profiles is the “COM” profile and is a simple serial port: raw binary data transmit and receive. That’s the profile these Bluetooth serial adapters speak. All Bluetooth stacks on computers appear to support the COM profile.

The SparkFun BlueSMiRF module speaks only the COM profile and when powered on and set up, looks just like a normal serial port to software. In truth it looks a little like a modem, because you can escape into a “command mode” that has an AT-compatible configuration language.

The full steps are below.
Continue reading “HOWTO: Mac OS X Bluetooth Serial Port”

15 kbytes of fame

A couple of the Roomba projects got mentioned on the Net recently. Actually what was primarily mentioned was the wonderful editing job of the posts done by Phillip Torrone for the Makezine blog. The projects were on the front pages (briefly) of Makezine, Boing Boing, Digg, etc.! Very exciting. I’ve been collecting links of famous (to me) places were it was mentioned:
Makezine blog, serial interface
Makezine blog, bluetooth interface
Digg, serial interface
Boing Boing, serial and bluetooth
Engadget, serial and bluetooth
Gizmodo, bluetooth
robots.net

Unfortunately, many of the comments on these blogs don’t quite get the reason for hacking the Roomba in this way. (many “what’s the point?” comments) It’s not to make Roomba a better vacuum cleaner or to make it into a fully-fledged autonomous robot. It’s to bring the fun of robots into your household very cheaply. If you already have a Roomba or don’t mind spending ~$160 for one, you can easily hook it up to your computer and have real live Logo with a real live ‘turtle’. Or make it dance. Or just play around with it.

It’s not often we can write programs that effect the real world.

And if none of that helps, just think of it more as a computer-controlled RC car rather than a vacuum cleaner or robot.

RoombaComm: Roomba Control & Communications API, release 0

Update:
new version of RoombaComm released

As mentioned previously, I’ve started on a library to make Roomba-to-host-computer interfacing easier. This is the zeroth release of such a library.

The goals of this library are:

  • provide full access to the entire Roomba SCI protocol
  • provide a set of higher-level functionality on top of the SCI protocol
  • create a library that is as cross-platform as possible
  • provide interfaces to high-level languages/environments like Java, Flash, Processing, Max/MSP, etc.
  • allow someone who’s not an expert programmer utilize a rapid development environment like Processing to quickly manipulate the Roomba.

Java was chosen as a language, since the RXTX serial library seems well-developed on many platforms and has been tested thouroughly in Processing. Java also has good network connectivity, making it possible to create a net-to-serial adapter for the other languages.

And so the RoombaComm API:

RoombaComm In Use
In both Java and Processing, usage is very similar. Here is an example in Processing, which also forms the core of one of the Java examples:

RoombaCommSerial roombacomm = new RoombaCommSerial(this);

if( roombacomm.connect("/dev/cu.KeySerial1") ) {
    println("connected!");
    roombacomm.startup();

    println("Playing some notes");
    roombacomm.playNote( 72, 10 );
    roombacomm.pause( 200 );
    roombacomm.playNote( 79, 10 );
    roombacomm.pause( 200 );
    roombacomm.playNote( 76, 10 );
    roombacomm.pause( 200 );

    println("Spinning left, then right");
    roombacomm.spinLeft();
    roombacomm.pause(1000);
    roombacomm.spinRight();
    roombacomm.pause(1000);
    roombacomm.stop();

    println("Going forward, then backward");
    roombacomm.goForward();
    roombacomm.pause(2000);
    roombacomm.goBackward();
    roombacomm.pause(2000);
    roombacomm.stop();

    println("Disconnecting");
    roombacomm.disconnect();
}
else {
  println("could not connect! :(");
}

If all goes well with the above, you should see and hear something like this:

The API functions used above allow for a very Logo-like programming experience. The API has also more detailed commands, including the ability to read the Roomba’s sensors. As there is no documentation, see the examples and source for now.

Expect a new version of this API with more examples and documentation within a week or so.

Roomba Bluetooth Interface

I created a couple of Roomba Bluetooth Interfaces.

They work well and were easier to create than the Roomba Serial Interface. Unfortunately, “bluetooth as serial port” on computers seems a little raw. This is both for PC and Mac, though the Mac seems to be a bit more intelligent about it, perhaps because of its Unix core.

It’s pretty cool being able to drive the Roomba around wirelessly.

Update: added a Mac OS X Bluetooth Serial HOWTO