Contributed by sean on from the taking current out for a <b>spin</b> dept.
Chris Kuethe has written an application which, by taking advantage of some unique OpenBSD features, has allowed him to turn his laptop into a race car data logger. aps(4) is a driver that utilizes the OpenBSD sensors framework to retrieve and report various statistics provided by IBM/Lenovo Thinkpads. The important ones here were the X and Y acceleration features, which provide the same functionality found in expensive accelerometer devices.
Since a typical consumer GPS will only update its data once per second, and a race car might be travelling in excess of 200 km/h, on its own, it is not capable of generating much meaningful performance data. It is even less fit to record information about turns and other sudden changes in position. Digital signal processing and sound editing fans might recognize a parallel problem: sampling frequencies too low to properly describe a signal (Nyquist/Shannon Sampling Theorem, anyone?). Since GPS receivers that can provide navigation solutions several times tend to be slightly expensive and less common than those that produce only one solution per second, and 'real' dataloggers are even more expensive, it occurred to Chris that he already had all the necessary hardware, as well as a framework for putting it to use for his task.
The beginning of a solution to the problem arrived when Marc Balmer (mbalmer@) wrote the nmea(4) driver, which is a tty interface to the NMEA line discipline. This allows the operating system to use NTP timedelta sensors in conjunction with the information retrieved from the connected GPS. In this way, it becomes possible to track the latitude and longitude of the computer itself with great accuracy.
nmea(4) was written with the knowledge that this information could be tracked by the operating system, however, the practical applications were, at the time, unknown.
Chris wrote this utility to calibrate the output of the aps(4) sensors in his Thinkpad by measuring the pull of gravity on each edge and face. This is a necessary step because the sensors are not mounted in the same orientation in every model, and the absolute values reported by individual laptops vary quite significantly. Once a set of correction factors was calculated, they could be loaded into the kernel with sysctl(8). Once this was done, any further readings were scaled to more meaningful quantities - either G or m/s2. Combining this data with the GPS allows for the generation of accurate position information previously only available through dedicated hardware.
The work on nmea(4) and appscale is highly experimental. Interested parties who have access to the hardware mentioned are invited to contact mbalmer and ckuethe to help with testing. The appscale source is available at http://www.ualberta.ca/~ckuethe/apsscale.tgz. Chris insists that this tool is dangerous and will crash your hard drive, shave your pets and set your CPU on fire if you use it. Still, any Thinkpad owners who wish to help test the calibration routines are welcome to try it out and give feedback to firstname.lastname@example.org.
Note that since the initial posting of apsscale, Chris has realized that aps(4) currently updates at only 2Hz (50Hz was wishful thinking) but there is work going on to change that.
The nmea driver appeared in OpenBSD-current on June 1, 2006.
(Comments are closed)