I gave a talk at the Sketching in Hardware 1 conference. It was a great conference, full of amazing people and hosted at an astounding location. I’ll write more on the conference later.
My talk was “USB on Rails”. The USB HID standard enables the sending and receiving of arbitrary data-structures (“objects”) between a host PC and a device. All without any additional device drivers, since the HID driver is built in to all OSs. Many sketching tools or demos use USB, but introducing them to the unintiated means lots of reboots for driver installs. The title is a silly, but half-serious, take of applying the philosophy of Rails to hardware-to-computer interfacing: solve the common case simply, but allow deviations. More on this later, for now, here’s my talk’s slides:
RoombaComm is Java library for communicating and controlling the Roomba. It works on any operating system that RXTX supports. This includes Mac OS X, Linux, and Windows. It also works with Processing. It will soon work with Flash and Max/MSP.
It’s been a work in progress for several months and has gotten a little better as I work through improving it for the book.
Several bugs have been fixed, particularly with respect to Bluetooth on Windows. See the README for some info on that.
Tested systems:
– Mac OS X 10.4 (Tiger) : usb serial & bluetooth
– Mac OS X 10.3 (Panther) : usb serial & bluetooth
– Windows 2000 : usb serial & bluetooth
– Gumstix Linux : built-in serial
Demo command-line programs include:
– DriveRealTime — Drive your Roomba with cursor keys
– RTTTLPlay — Play monophonic ringtones on your Roomba
– Spiral — Roomba drives in ever expanding spiral
– Waggle — Roomba wags like a dog
– BumpTurn — Roomba drives around by itself, avoiding things
– Spy — Read your Roomba’s mind while it works
– Tribble — Roomba purrs and sometimes barks
– RoombaCommTest — Roomba GUI remote control panel (not command-line)
Processing demos include:
– RoombaTune — Play your Roomba like a musical instrument
– RoombaRing — Play RTTTL ringtones on a Roomba
– RoombaView — Full instrument panel and remote control
Mike spent some time getting a Gyration Air Mouse to work on Mac OS X as a gestural input device. The Gyration stuff is interesting because it’s based upon a two-axis gyroscope. It’s not accelerometer-based like some of the old game console controllers (or like the Sudden Motion Sensor in the new Mac laptops)
I got a few of those mice as well to experiment with, thinking it would be a cheap way to acquire a gyro, since dual-axis gyros are pretty pricey.
Except when you take it apart, it turns out the gyro is huge:
I’m considering talking to Gyration about getting a few OEM samples of their gyro for non-mousing applications. Or maybe just get the datasheet from them and canabilize some Air Mouses.
At the next meeting of the SoCal instantiaton of dorkbot, I’ll be bringing an entourage of Roomba with me and will be demonstrating the hackability of them. Some of the things I’ll be talking about:
– RoombaMidi / Roombas making music
– Roomba Spirographs / Roombas making art
– Roomba as robotics experimentation platform
– What’s needed to hack a Roomba
What: Roomba-a-go-go at dorkbot-socal Where:Machine Project When: Saturday June 3rd, 1pm Why: Know your enemy, the Roombas are ready to revolt
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.
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.