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
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.
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.
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.
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.
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:
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.
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.
Been playing around with Processing to act as the Roomba telemetry console. Here’s a little playable mock-up of what it might look like:
Click to play with it. It’s sorta like a Virtual Roomba!
Random experiments, circuits, code, rapid prototyping examples, sometimes things to buy, and occasionally tunes by Tod E. Kurt.
Reach me at tod [at] todbot.com
Crash Space
Crash Space is a Los Angeles-based hackerspace. Come visit! Become a member! Learn Arduino or how to solder!
Yay BlinkMs!
BlinkM is a smart LED. Imagine an LED with a tiny computer inside, one that can be any color and have a life of its own. You can buy them now from one of our global distributors.
ThingM
A device studio that lives at the intersections of ubiquitous computing, ambient intelligence, industrial design, and materials science.
Recent Comments