Mac OS X Logo

Virtual Bicycle Download Page

You will probably need to right click on the "download" link below, and then save the link target as a file. Then you can execute the file from the command line. You may need to fix its permissions in order to make it executable.
Download Mac OS X Version Download Linux Version Download Fast Linux Version (for slow machines)
This is for machines without hardware graphics acceleration. The only difference in this version is that it draws less floor. This is a little uglier, but it can help performance to be tolerable even when hardware support for 3D is absent. Note that if you're getting less than 10 frames per second, then the delta-t physics approximation ceases to be stable and the bicycle will eventually fly apart.


At any time, press "Q" to quit or "P" to pause.

Camera Viewpoint

All the keys around "K" on the keyboard control the camera. When you start, you will notice that the camera is rotating around the bicycle. The camera is always centered on the bicycle, but it rotates around its mount. It can either have an absolute mount ("U"), or be mounted on the bicycle ("I"). "K" stops the rotation. "J" increases the clockwise speed of rotation, while "L" increases the counterclockwise speed. "O" stops rotation and resets the viewing angle. If you're going to try to drive the bicycle, pressing "I" and then "O" will set your viewpoint to be similar to what a rider typically sees.

Use "<" and ">" to zoom in and out (you do not need to press the shift key). Use ";" vs. "/" to move the camera up (looking down) vs. down (looking forwards).

"M" will keep a [imaginary] vertical line in the frame aligned with screen vertical. If you are not using the rider viewpoint ("I"+"O"), this doesn't look very natural.

Driving the Bicycle

There are several options for controlling the bicycle, shown in purple on the left. When you start, the autopilot is used. Pressing the numbers 1-5, you can choose how to control the bicycle, but you will want to make sure your mouse's x coordinate (shown by the blue vertical line at the top) is centered before you change modes. You will probably crash anyway — each mode has its own peculiarities.

Regardless of mode, you can control your speed via the cruise control, shown in red. The up and down arrows adjust your cruising speed, in multiples of 36, up to a maximum of 360 (cm/sec). (The orange lines on the floor are spaced one every three meters.) In general, the faster you are going, the more stable the bicycle is. Even the autopilot can barely keep control of the bicycle at 144, and manual control is even more difficult. After a crash, the cruise control is automatically reset to 360.

When you crash, press the space bar to lift the bicycle back up again, and put the bike in autopilot mode. Once the yellow indicators at the top of the screen have centered, press the space bar again to stop the lifting and allow the bicycle to accelerate. Wait until your speed is nice and high before disengaging the autopilot.

Handlebar Angle

This is the easiest form of control to understand, but the hardest way to control the bicycle. In this mode, the mouse (by definition) sets the position of the yellow marker on the third of the three lines at the top of the screen.

Handlebar Torque

With this form of control, the mouse position controls the torque being exerted on the handlebars. In this mode, the mouse sets the position of the yellow marker on the second of the three lines at the top of the screen. This is the control mode used by the autopilot, and you are free to follow the autopilot's suggested mouse position, shown in pink on the second of the three lines at the top of the screen.

Handlebar Spring

This is the hardest form of control to understand. In this mode, the mouse sets the position of the yellow marker on the first of the three lines at the top of the screen. This marker is simply the sum of the other two markers. This is like setting the zero position for a spring that applies a torque to the handlebars based on how far they deviate from the zero position (position of zero torque). If you just leave the mouse somewhere near the center, the bike will never fall, so this is perhaps the easiest way to control the bicycle, but it is still difficult to aim the bicycle in a desired direction.

Shifting Weight

Implemented due to popular demand, this mode increases the weight of the bicycle seat to 30kg, more than twice the weight of the entire rest of the bicycle. The mouse then lets you shift the seat's position to the left or right. When you crash in this mode, the lifting force is not strong enough to lift the heavy weight, so that's another reason to switch back to autopilot when you crash.

Using the Autopilot

The autopilot is a very simple system. It simply takes a linear combination of some sensor values, and applies that amount of torque to the handlebars. (This linear combination operation is easily within the capability of a single neuron, even using a mean firing rate interpretation. This makes it somewhat of a mystery why humans take so long to learn how to ride.) The autopilot works at a range of speeds (144cm/s and above). The autopilot has three modes of operation, discussed below: directional tracking, waypoint tracking, and learning mode.

At all times, a blue and pink arrow are shown under the bicycle. The blue arrow is the desired direction, and can move discontinuously when the desired direction suddenly changes. The pink arrow is a continuous approximation to the blue arrow (when the blue arrow jumps, the pink arrow rotates at constant speed towards the blue arrow). The direction of the pink arrow is fed as input to the autopilot.

Also, the weights for the linear combination used by the autopilot are shown in white. "A"/"Z" will increase/decrease the first weight, "S"/"X" adjust the second weight, "D"/"C" the third, "F"/"V" the fourth, and "G"/"B" the fifth. This (as well as all the other keys) will make no sense if you have a Dvorak keyboard (Europeans will hopefully only be puzzled by the "Z").
The first weight applies to the difference between the bicycle's heading and the pink arrow's heading.
The second weight applies to the amount the bicycle is leaning away from vertical.
The third weight applies to the rate at which the amount of leaning is changing.
The fourth weight applies to the rate at which the handlebars are turning.
The fifth weight applies to the current angle of the handlebars (0=straight ahead).

Directional Tracking

Press the left and right arrows to adjust the angle of the blue arrow (and thus, sooner or later, the bicycle) in increments of 45 degrees.

Waypoint Tracking

If there are any waypoints, then directional tracking is disabled, as the blue arrow will always simply point to the next waypoint. To create a waypoint, click with the mouse, ahead of the bicycle, at about the boundary of the orange floor lines. The bicycle should head towards it. To create a whole mess of waypoints, press "W". Pressing "W" again will remove all unreached waypoints, returning you to directional tracking. Waypoints created with the mouse are always added to the end of the list, and the bicycle visits them in order. The current target is shown in pink. Once a waypoint is reached, it turns green. Future targets are white.

Learning Mode

Pressing "+" will start learning mode. This should only be done from directional tracking mode, as the presence of any waypoints will interfere with the learning. The learning method is stochastic descent, with weights adjusted up to +-5% of their value, and the objective function is to reduce the time it takes to make a 180 degree U-turn and resume a stable vertical state of no leaning. The learning will not start until the bicycle is stable and the speed reaches the cruising speed (the learning indicator is shown in red while waiting for this). When the learning indicator is green, new weights are being compared with old ones, and the times being compared (in seconds) are shown.

Why does this whole thing exist?

There are two reasons that this exists.

This is a general purpose platform for trying machine learning methods on real-time control problems.

The bicycle is implemented as four rigid bodies, connected by rotatable-axle connections. The code has been specifically written so as to make it easy to implement different robots in the future, for examining different kinds of control problems.

This shows that it should not be that hard for a machine to learn to ride a bicycle.

Several researchers have worked on the problem of controlling a riderless bicycle. Some (Randlov & Alstrom, Lachiver et al., etc.) have even worked on getting a machine to learn on its own how to ride a bicycle, without being told. So far, this has proven to be a difficult task.

One purpose of this bicycle demonstration is to show that competent bicycle riding does not require a complex mapping from inputs to outputs. A simple linear combination is surprisingly competent. (A two- or three-neuron controller can do even better.) Perhaps this knowledge can lead future researchers to examine the question of how computers might be able to recognize the appropriate level of complexity for solving such a control problem.

Created by Matthew Cook, 2004