loading
Picture of Google Bike
Has the winter weather got you down? Is the snow preventing you from training for the next Tour De France? Or are you afraid to ride outside with all those cellphone weilding drivers? Google bike is the answer for you! Now you can ride anywhere in the world in the climate controlled safety of your home.

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!
 
Remove these adsRemove these ads by Signing Up

Step 1: Overview and Parts

Picture of Overview and Parts
Here's the gist. A sensor from a bike computer is used to detect the rotation of a bike tire. The output of this sensor and the turning angle (controlled by the thumb joystick) is read by an Arduino and relayed to a computer over a usb cable. The computer reads the number of rotations and angle of the joystick and uses these values to control a virtual bike within google earth!

Stuff you will need:

  • Indoor bike stand (or suitable stationary bike)

  • Bike cadence sensor (or reed switch and magnet)

  • Arduino

  • 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

Picture of Bike cadence sensor
IMG_0865.jpg
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

Picture of 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

Picture of Arduino
googlebike_schem.png
Google bike uses an Arduino to relay sensor data to the computer.

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:

    ard.configure_serial('COM6')

on mac it will look something like:

    ard.configure_serial('/dev/tty.usbserial-A4001Lf4')

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:

http://localhost:8080/index.html

Step 6: Up and Riding!

Picture of Up and Riding!
Google bike should be up and running! Pedal to move forward, move the joystick to turn, and press the joystick to stop/reverse. Type an address into the search box to teleport to a new location (the default should be Googleplex, Mountain View, CA, USA) or click one of the presets.

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



Be sure to fully refresh the page after making any of these changes so that your browser does not load the cached javascript file.

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 previous projects 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:
https://github.com/braingram/googlebike

Good luck and happy riding!
Bergamotov made it!9 months ago

Thank you, braingram, for easy to understand code. I was able to hook-up my elliptical trainer to your code in one week-end. I even hacked it to use two buttons for turning instead of thumb joystick. This will keep me motivated to stay fit through the winter!

ellliptical.png
W9RAN2 years ago
Has anyone found a way around the Google Earth issue for Linux since this was originally posted? Looks like Goggle Maps is putting emphasis on WebGL but there are some strict hardware limitations. It would be nice to run this app on cheap Linux hardware.
I've been working on this for about a week now with limited success. The bike on the screen goes backwards and counterclockwise. It does not appear that it is responding to the joystick input. The output from the python server look good, showing a range of 0-1023 for the x/y inputs and 0/1 for the push button. The cadence output increases incrementally with each input.

Problem with the python server, maybe?
braingram (author)  greatgoogamooga3 years ago
Yeah, it sounds like a problem with the javascript. I'm not quite sure what though :-/

I hooked up the press button on the joystick (press down and hear a click) to make the bike go backwards.

I also ended up only using the V component of the joystick (the H component broken on mine).

If the python server output looks ok I'd say add some alerts or something to the javascript code to see what ARDUINO_V and ARDUINO_C are doing. If they're misbehaving than it sounds like a problem between the python server and javascript code.
vince_rmf3 years ago
This is the coolest idea. 

Unfortunately I do not have the skill to build my own.  For some reason there is not too many ready-made controllers out there.  I only found a couple:
Cyber ExerCycle http://www.cyberbiking.com
XR Kit http://www.xrgame kit.com

I am not sure how well they would work with Google Earth. Has anyone tried them?

nicky234 years ago
Interesting, I'll try it.
Umm, Google earth is out for linux....
bazzargh4 years ago
Might be interesting to hook this up to opensprints. They use an open http-based protocol to serve up the data from their arduino sensors, so multiple software frontends exist. With preset steering info, eg from a GPS trace, you could have a circuit race (up the Champs Elysee?)

Another option that I keep meaning to try (when I find my ANT+ stick...lost in a box somewhere) is to use libusb to get the cadence or speed events from Garmin sensors - again, getting the steering from a GPS trace. There's code for reading those events floating around t'internet.
Craig84 years ago
Great Idea...! Some suggestions for your consideration:

- Hook it up to a projector and have the streetview projected large-scale in front of the rider.
- Designing a mechanism to adjust the resistance of the magnetic flywheel to match the gradient of the road - getting data from google earth height info.
- Design the joysick to mount to the headset with a link to the stem/handlebars so small movements in the steering to control direction - removing the need to let go of the handlebars.
- Put a desktop fan in front of the cyclist - the speed of the fan could be controlled by the riders speed - to mimic wind/air resistance whilst keeping the cyclist cool.

Good work.!! Really like it.!
ltnemo20004 years ago
LINUX USERS!!!!
you can run google earth through wine and do great!
runs really well.
(also, as a cyclist i would pay for this setup in a sleeker case attached to my rear wheel.
patent it.
???
profit.)
thanks for the tips
-hack life
>G
pecospearl4 years ago
Put a patent on it and make your fortune! I think you have a winner!
magic19694 years ago
very cool. i'll try it.......
earlye4 years ago
I once worked at a company that provided its employees with a gym. It included several bikes that were networked together. You would play Azteca, a game based on an Aztec progenitor of soccer - you could steal the ball by riding into your opponent, and you would shoot the ball by pressing a button on the handle. Stearing was accomplished by leaning the recumbent bike like you would if it were a real bike. It was *very* fun. It'd be cool to take what you've done and basically turn your controller into a joystick controller.
merijnvw4 years ago
this is GREAT!!! I have to have this for the winters here. I can't train outside but cycling inside is too boring, this is the best solution
Wonderful idea, I may use your idea and modify it for a treadmill.

Paul
braingram (author)  messyworkbench4 years ago
Nice! My dad expressed some interest in making another or modifying the current project for use on an elliptical machine for my mom. I seem to remember someone setting up a treadmill to 'run' through world of warcraft, they might have some documentation on the setup that could be useful. Good luck!
Dr_Stupid4 years ago
Google Earth is available in Linux. (don't know why you'd mention "sorry Linux") in reference to Google Earth.
braingram (author)  Dr_Stupid4 years ago
Please see my reply to skidawgs comment. The problem is that there is no google earth browser plugin for linux.
jennnnnnn4 years ago
Sweet!!!!
skidawg4 years ago
I just looked at Google Earth's site, and there is a Google Earth 6 version that can be downloaded for Linux, at least for Debian/Ubuntu and Fedora/openSUSE. It also looks like the pySerial package can also be installed from source on Linux.

Is there anything else that causes this to not be able to run on Linux? I am not seeing anything.
braingram (author)  skidawg4 years ago
Google bike runs through your web browser and uses the google earth browser plugin. You are correct that you can download google earth and the necessary python stuff for linux. Sadly, the browser plugin does not exist for linux :( If you find otherwise please let me know as I'd love to get this running on linux (my os of choice). If you do find the plugin, getting google bike to run should be almost identical to the osx instructions (the serial port should be /dev/ttyUSB0 or something like that).
rimar20004 years ago
GENIUS!

I envy your brains!
Dr. Pepper4 years ago
cool!
Ranie-K4 years ago
Cool! Here's how some guys ride the Bergensbanen railroad with a bike: http://www.rullesykling.com/Bergensbanen.html