Processing + GPS

It’s the holiday season, which, since I was about 15, meant it was time to take some time to catch up on the projects I’ve been meaning to do. Terribly alpha-geeky. I’ve been meaning to connect a GPS to Processing (http://www.processing.org) to allow Processing to get some rudimentary context awareness — where it is running, how fast it is moving, etc. One idea that Vince had, which I think is quite fun to think about, is turning a used, cheap-o TabletPC into a screen saver for your car. Might not be the safest app for the car, but a cool idea in that it could be responsive to motion (or lack thereof, if you frequent LAs highways), where you are in the world (in this sense, the idea is kindred of The Path of the Mad Prophet), or, as Vince had originally thought while we were working on Mad Prophet, as a kind of mini-map experience for your car. Gosh, that Vince is a clever fellow..

So, I tossed together a Processing sketch that’ll read most GPS devices. I’ve tested it with a Garmin GPSmap 60cs and a Bluetooth GPS from Socket. It’s also pretty much cross platform.

There are two classes. One’s the ever present start-up class, called GPS. The other is a class called GPSReader that talks to the GPS device and parses out some of the more useful info. Right now it’ll just give you lat/lon, speed (knots) and a UTC timestamp, but there are stubs in there to handled number of satellites in view and other stuff.

You’ll need to modify the serial initialization method to set it to read the serial/bluetooth/usb port to which your GPS is connected. The applet will spit out all the available ports, so if you’re not sure which one it’s connected to, you can just try each in turn.

Problems I’ve had that you might want to be aware of mostly occured with the Bluetooth GPS. It would sometimes hang Processing for some reason. I had to reboot until I discovered that I could go into Bluetooth preferences and click “disconnect” for the Bluetooth pairing and it would let go and I could stop the applet and figure out what was wrong. Cycling the power on the unit fixed the problem.

This is fairly barebones — there are some GPS data that I ignore, although it would be quite easy to insert code to handle that. I’m basically just getting the lat, lon, UTC and some other stuff.

Let me know what you do!

Some useful GPS related stuff is to be found at http://del.icio.us/jbleecker/GPS.

Download ProcessingGPS_0.0.zip

Technorati Tags: , ,