#N900 - My New GPS

Over the years, I’ve had a couple different GPS units. The first two were both made by Garmin and were incredibly rugged devices which served their purposes quite well. One was used primarily on my boat when sailing and the other was more designed for hiking and geocaching. Yet in the sake of ruggedness, they sacrificed one aspect that is very important to me, programmability. They both had wires that could be used to connect them to the serial port of a computer where a limited amount of data could be uploaded or downloaded, but that was about it.

My New GPS is my Nokia N900. I didn’t really get it to be a GPS and I’m not sure how much I’ll end up using the GPS functionality, yet I have had a bit of fun programming it. There is an API for getting to the GPS on the N900 called liblocation. The documentation is pretty good and provides a nice sample C program that can be compiled and run on the N900 to test things out. What is even nicer is the Python wrapper for the API. While not all the values that are available in the C API are available in the Python API, tweaking the Python script is very easy and provide a good way to rapidly prototype an application using liblocation.

I took the Python script from that page, changed the GPS location method to GNSS. While the GNSS mode takes a little longer to get an accurate fix, once it has connected to the satellites it is pretty accurate. In addition, it doesn’t require a network connection and unless I’m stationary where there is WiFi, I’m unlikely to have a network connection. I set the location interval to sixty seconds so I wouldn’t get flooded with information. Finally, I took out the data.stop call after the location fix was printed. This allows the program to run continuously printing out updates. I also added a timestamp, the altitude and the accuracy in my print statement.

I left it running and saved the data as we drove to Church. I cut and pasted some of the waypoints along the way into Google Maps to get this representation of the trip.


View Larger Map

It is a good example of what can be done when the API is easily accessible from a scripting language like Python. I may expand on this a little more, as I explore different ideas of how Python gtk can be mashed up with liblocation on a Nokia N900.

Some of this investigation was prompted by a discussion on a mailing list of N900 users. While it is fairly easy to roll your own GPS applications using Python and liblocation, many of them would like to try and get existing applications that depend on GPSD to work. It may be that GPSD could be modified to support a call to liblocation for N900s, that an alternative GPSD could be written that would use liblocation and look like the original GPSD to other programs, or it might be that a shim could be written so that GPS data from liblocation could be made available on a virtual device that GPSD could listen to.

There is a project already in the works to create a miniGPSD. However, it is still in development and currently pieces appear to be missing.

Beyond the GPS programming, there is the Geolocation API for HTML5 that is likely to make all of this all the more interesting. So, another project may be to make my blog more location aware as HTML5 becomes more common.

Any way that you cut it, GPSes have sure changed a lot over the past decade. My old GPSes are still good for their purposes, but if you’re a geek wanting to play with location, the N900 sure is a fun toy.

(Categories: )