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!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
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
Google bike uses a cadence sensor from a bike computer to detect wheel rotations. Simple wired cadence sensors, like the ones used here, are typically reed switches embedded in plastic for protection. Attach the sensor to the back fork of the bike (this is important as the front tire doesn't rotate when the bike is in the stand) and install the supplied magnet on one of the spokes of the back wheel.
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
Google bike uses a thumb joystick to control turning angle and reverse. I selected a simple thumb joystick and breakout board from sparkfun which looks identical to the kind found in ps2 controllers. The joystick contains two potentiometers and a push button switch. At rest, the pots (potentiometers) are at their middle positions and will output half (2.5V) of VCC (5V), move the joystick and the outputs of the pots will move between VCC and ground. Pressing on the joystick closes the push button switch and causes the SEL output to go to ground. When the joystick is not pressed, SEL outputs VCC.
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
Google bike uses a small python server to read incoming sensor data and serve up the google bike webpage. You will need to install python (version 2.something, the script is not 3.0 compatible as far as I know), and pyserial. Installing python and pyserial should be a relatively painless process with lots of useful information found via google. The only issue I ran into on windows was that I needed to install a 32-bit version of python as I could not find a 64-bit version of pyserial.
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
Aside from being a fun project, google bike was created as a christmas gift for my father. The past two years he and my brother (the star of the video) rode in the "Bike MS To Paradise and Back", a 100 mile bike ride to raise money for the National Multiple Sclerosis Society. The cold Pennsylvania winters don't have the best training weather for bike riding and my brothers and I wanted to get him a stationary bike stand so he could ride without braving the snow. He's also a big fan of google earth (who isn't!?) so I figured he would enjoy using indoor riding to explore new places.
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!
1 Person Made This Project!
Bergamotov made it!