Toilet paper

Toilet Paper
Harlan Hile and Drew Perttula

University of California, Berkeley


This whole project began simply as a remodeling project, to repaint and re-floor a water closet. As time went on, it was decided that there was no reason to stop there, and we sought to bring the room into the high-tech realm. Although documentation on using Python in such an environment was scarce, we believe it was the right choice for the project.

Since then, the water closet has finally advanced to the

and the computer running it have developed into a very unusual use of Python.

The main objective of this project is to have fun, and create a smart, interactive, mysterious, and amusing bathroom going experience. However, it can also be viewed at as an experiment in home automation, artificial intelligence, and user interfaces.

Technology Overview

An inexpensive IBM 486 computer called toilet has been "installed" in the water closet alongside the real toilet. Toilet runs Slackware Linux and contains a sound card with joystick port, an ethernet card, standard parallel and serial ports, and a CD-ROM drive. The case is on the floor with a special cover (this is an especially adverse environment), and a mini keyboard is mounted on the wall.

Most data is acquired through the joystick port of the sound card, which gives 4 analog values (the axes) and 4 digital on/off values (the buttons). A few input bits of the parallel port are also used to read digital on/off values. See the schematic for a complete list of inputs and outputs.

watermark image of a toilet behind everything,
need space in "custom IO",
align the input boxes on the left; outputs on the right,
regularize caps in the vertical labels,
lcd display?,
"laser beam level" or something instead of "laser photocell",
"red led in bowl"?,
"audio output" spelling,
should be double arrow between customio & python,
keyboard input? www output?,
put "input" and "output" at the top above their columns

How Python Fits in
We chose Python for its incredible prototyping speed and ease of extensibility. The interfaces to the parallel port, joystick port, and CD-ROM are custom C modules, for example. Older versions of the toilet software called separate programs from a script and parsed their output. Under Python's module system, our scripts are shorter, clearer, and faster.

Toilet also makes use of various modules written by others. In order to get news headlines from the web, it has httplib fetch selected web pages and the re module parse the headlines out of them. Once it has these headlines, it scrolls them across the LCD screen using termiosmodule. The sound output system uses the linuxaudiodev and wave modules to play .wav sounds. Toilet also uses a DB-API module to store history into a database and socket to listen for requests from other processes.

Python's threading is also used to allow sequences of events to execute, while input data is still polled, and locks are used to synchronize threads.
What it Does

When a motion sensor detects a visitor in the hallway outside, toilet picks from a list of sounds to play to encourage a visitor to enter. When Toilet has a visitor, it picks an appropriate track to play from the CD based on things like the seat positions, the laser beam across the seat being broken, the light switch being off, etc. It scrolls news headlines across the LCD panel. When the toilet is flushed, the lights flash and the music fades. If the seat is left up when the door is opened, a reminder sound plays. Toilet also serves web pages to the outside that allow us to view history from the database, request specific CD tracks, control the volume, and send messages to the LCD screen.


Toilet has been in development for nearly two years. We have used Python for about 3 months, during which time the development has gone significantly faster.

With the available sensors, and easy control and manipulation through Python, Toilet can be expected to do many more intelligent and entertaining things.

Klein bottle grid object

Klein bottle grid object
Click images for larger versions

Background photograph courtesy Philip Greenspun

This is a model of the standard immersion of the Klein bottle in three dimensions. The u/v gridlines (in my formulation) are thickened, and special care is taken so that at the circle where the surface self-intersects, the grid does not.

A physical model built from this description would make a useful teaching aid. It allows people without access to a computer and 3D viewer to turn a Klein bottle around and examine its features.

In addition, the connectivity of the grid creates a few mobius strips of varying lengths between the grid lines.

The complexity of this part demands that it be built using some SFF technique.

The shape is just over two units long, and each grid tube is a near-square .04 units on a side. If the part is sized so the side length is 2mm, the whole shape is just under 4in.

Cross-section rings: 24
Sides per ring: 6
Object genus: 145
Faces (as triangles): 3456
Vertices (as triangles): 1440
Volume (scaled so side length is 2mm): 11.8 cm^3
Surface area (same scale factor): 25.8 cm^2

Geomview OOGL file (quadrilaterals)
VRML file (quadrilaterals)
MUG object (triangles)
STL object

Click here

See my CS284 project-- it's even prettier!

Powered by Zope

Spherical mirror demo

Spherical mirror demo

Get the Tcl plug-in around here (updated 6/01).

The lines reflect off the spherical mirror. You can drag the mirror around and adjust four other parameters. If you move the mouse on a line, the point of reflection will be labeled with the reflecting angle.

The point is that it is easy to see spherical abberation with this demo. The lines don't all intersect at the same point after reflecting in the spherical mirror.

I wrote this while taking Physics 7B at U.C. Berkeley, fall 1997.

Powered by Zope

Walking bug

CS184 Final Project - May 1998

Second half of the project

This is a cool stereo pair of the scene. No shaders on the bug. Cross your eyes to see it (don't diverge them).

Bug project

Older stereo pair. You can see the contours in the snow really well. The red and green lights are light sources in the air around the bug.

Click thumbnails for larger images

This animation shows the bug climbing a hill and jumping.
The bug was walking in the live-bug program, and I saved a series of positions. Then I had Povray render the frames. Took 50 minutes on a 500mhz Dec Alpha. (80 frames, 510k)

[full size animation, 8mb FLI]

City in fog

City in fog
I want to make a short (like 30 second) movie where you're in a huge city at night and there's fog all over. You see a person standing on top of a building, and lights shine around him or her so you can see a silhouette in the fog. All the time, the camera is on the ground, on other buildings, on a helicopter, walking around the person, etc. Then perhaps the person should jump off the building and fly down through the fog. I don't want it to look sad or suicidal-- just very very pretty.

Here are some experiments I made of the city look. I started in POV-Ray, then moved to the Blue Moon Rendering Tools because Renderman lets me write my own shaders. I think all these pictures were rendered by POV-Ray.

fog1, Sat Apr 19 12:02:23 1997

fog10, Mon Apr 21 16:26:51 1997

fog11, Wed Apr 23 10:45:47 1997

fog2, Sun Apr 20 15:13:34 1997

fog3, Sun Apr 20 17:46:38 1997

fog4, Sun Apr 20 19:29:06 1997

fog6, Sun Apr 20 22:30:50 1997

fog7, Mon Apr 21 00:22:29 1997

fog8, Mon Apr 21 13:11:49 1997

fog9, Tue Apr 22 00:13:22 1997

Wine bottle woodsman

This is a 30-second commercial-style animation I want to make. I've got a script, storyboards, and some rough timings. I would like to include as much interesting motion as possible, such as flocking birds and sloshing liquid.

I started the project a few years ago (like around 1995) when I used an Amiga. Here are some pictures from then. Here are some renders by Imagine. I made these on my Amiga 2000 a long time ago.

Here are some renders by POV-Ray from around January 1997.

This is the the bottle shape against some clouds. I kept this because I can make Absolut Vodka ad parodies out of it.

Here's an accident where the bottle cast no shadow. Only the label did.

The fingers merge together.

Here's one of the odd trees. A Perl script generates the recursive shape. POV-Ray did the rendering, using its blob objects.

Nice hands. I forgot to put checkerboard on the fingers, and POV-Ray made the texture dissolve between the blob components.

This is an older version of the interface. You can see the preview on the right and the matching rendered image on the left. The gray box has all the axis of motion.

Interestingly (to me), a similar UI issue came up on my lighting control system. Just like this very old tcl/tk program could map joystick axes to channels, the light9 system we used in summer 2002 could map 4 external sliders to submasters. We handled the UI differently in light9.

Then I rebuilt everything in POV-Ray (around 1998). Here are some newer pictures.

For the most control, I'll probably move the whole thing to Renderman and render with the Blue Moon Rendering Tools.

8/27/2002 - Wouldn't that be nice. But Exluna pulled BMRT. So maybe I'll keep sitting on this project until povray has a complete shader system, and then use povray.