Google bike is a virtual bike riding program. Using a few simple electronic components and some software hackery you too can ride in virtual style!
Here is the bike in action!
Step 1: Overview and Parts
Stuff you will need:
- Indoor bike stand (or suitable stationary bike)
- Bike cadence sensor (or reed switch and magnet)
- Small thumb joystick or harvest this from a PS2 controller
- Computer with windows or osx (sorry linux :( blame google for not releasing the google earth browser plugin for linux)
Step 2: Bike Cadence Sensor
I had to splice the cable going from the sensor to the computer and install a 0.1" header to get access to the reed switch. The bike computer still works, but you may be able to avoid this depending on the type of bike computer or sensor that you buy. The cable contained two wires that act like a magnetically activated switch. When the sensor is near a magnet, the switch is closed.
Step 3: Thumb Joystick
I laser cut a small bracket so the joystick could be temporarily mounted onto the handlebars using a rubberband. I've attached the svg file for the mounting bracket so you can modify it to your specific needs.
Step 4: Arduino
First wire up all the sensors to the Arduino. See the attached schematic for a graphical representation of what I'm about to describe. You are free to change the wiring to your hearts content, but be warned! The cadence sensor must be attached to digital 2 or 3 as it is used to trigger an intterupt. Also, be sure to make any corresponding changes to the arduino sketch.
Attach one wire (it doesn't matter which one) from the cadence sensor cable to ground and attach the other to digital input 3.
Next wire up the joystick. Connect:
- Arduino-5V to VCC on the breakout board
- Arduino-GND to GND on the breakout board
- Arduino-Digital-2 to SEL
- Arduino-Analog-0 to VERT
- Arduino-Analog-1 to HORZ
Upload the googleBike.pde sketch to the Arduino. Briefly, the sketch...
- defines an interrupt routine with crappy debouncing that increments a rotation counter
- configures serial communication
- configures digital input 3 (the cadence sensor) as an interrupt
- sets sensor pin directions and pull-up resistors
- every 10 milliseconds, relays the joystick status and rotation count over the serial connection (which travels over the usb cable)
I've also attached a svg file that contains a mounting braket for the arduino that is similar to the one used for the joystick. Beware! The mount quickly broke because I didn't put in little cross-bars to reinforce the crappy glue joints. If you decide to cut this yourself I suggest either adding reinforcements or redesigning the mount.
Step 5: Python Server
The attached server.zip contains the python code to run google bike. It includes:
arduino.py a very simple python module with an Arduino object that receives incoming sensor data
server.py the main python script that creates an Arduino object, a small web server, and launches the google bike page (index.html)
and other supporting files
Sadly, the serial port address is hardcoded on line 17 of server.py So... once you plug in the arduino be sure to correct this line before running server.py On a windows machine the line should look something like:
on mac it will look something like:
After correcting line 17, run server.py (either from the command line, or double click, etc...) and python should launch a web browser with the address:
Step 6: Up and Riding!
There are lots of variables that can be modified within the bike.js file. Here are some fun examples:
- change gravity (line 41) from 9.8 to 1.62 to feel like you're riding on the moon (helps for getting sweet air!)
- increase acceleration (line 45) to reach ludicrous speed!
- change the camera height and distance (lines 42 and 43) to get a zoomed out view for areas without 3d buildings
Step 7: Motivation
A bit of research revealed a couple previousprojects and I was encouraged to build a similar setup. One of the deciding factors was finding this wonderfully entertaining example of the google earth api that I was able to modify for use with the google bike. The bulk of the work was done the weekend before christmas and hopefully with the documentation here the project could be completed in a weekend or possibly a lazy saturday.
I attached various important files in this instructable that should allow you to create your own google bike. However, I also plan to maintain and update the following public repository:
Good luck and happy riding!