Thursday, September 6, 2012

Cycle virtually where ever you want

I've been talking for a while about writing a webpage and building some hardware that can make it look as though you were cycling along a gpx route as you use your exercise bike. Today I got it working so in this blog I'm going to talk about the concept and the hardware.

Google maps has a free, public api that allows a web page to get maps and display them. It can also display street level images. Google has created a massive catalog of panoramic images taken at regular intervals along most of the roads in the areas marked blue in this link. This includes most of North America and Europe and many other places around the world too.

You can quickly display a street level view from any of these points in any direction. If you display the view from a series of these points along a road you can create the illusion you are moving along the road. The faster your computer and Internet connections are, the better the illusion.

There are many sites such as ridewithgps, mapmyride, gpsies, etc that allow you to easily create and download gpx files that are merely a list of coordinates that form a sequence of straight-line segments that approximate a route. The segments are normally from 1 to 100 meters long depending on how curvy or straight the road is. If Google maps has created street view images along the route, an application can read the gpx file and drive you along your route at street level.

This in itself is fairly cool, but I wanted to connect my recumbent exercise bike to my computer so that I progressed along the route as I pedalled. I tried an Arduino but ended up with a much easier solution. I bought a thrift store usb mouse for $1, grabbed the sensor and magnet from a broken bicycle computer, soldered the sensor wires across the right-mouse button on the mouse and put the whole thing in a small box. When the mouse is plugged into my laptop the computer thinks the right mouse button is pressed every time the magnet passes near the sensor.

All that remained was to attach the sensor and magnet to my exercise bike and write a javascript program which responds to a right-mouse click. I purposely did not use the left mouse button because Google maps does it's own thing when it sees a left-mouse click.


This is why I'm not an electrical engineer

Here are some unedited results



I'll start on the software in the next blog.

No comments:

Post a Comment