Ever since seeing Man On Wire last year, a brilliant documentary about Philippe Petit, a french high wire artists who tightrope walked between the towers of the World Trade Center in 1974, I've been fascinated with the idea of balance.
The film contains striking footage of Petit 1768 feet about the ground, standing (or even more astoundingly, lying down) on a thin wire that seems, by turns, a solid surface and an invisible fantasy.
How does balancing work? The simplest recipe for balancing would go something like this: if you are off-center to the left, move your weight right; if you are off-center to the right, move your weight left. By using a Finite State Machine, you can make this recipe into instructions that can be executed by a machine. You can build a robot that tries to keep itself balanced.
This week, for Living Art, Allison Walker and I set out to do just that.
We started by hooking up an Adafruit 3-axis accelerometer breakout board to an Arduino and making sure we could read in the x-axis values. The breakout board needs 3v of power to use as a comparison with the values coming off of the accelerometer. At first we provided that with a simple Zener diode coming from the main Arduino 5v supply, but then (after losing that on the floor), we added an additional wire to hook up the accelerometer board to the Arduino's 3.3V supply directly.
Once we had the input coming in reliably, we used the Arduino Finite State Machine Library to connect the accelerometer input to a servo. The idea being that a servo connected to a long, wobbly leg could displace a balance beam in order to right itself when it began to get off center.
The Finite State Machine code we wrote (see the final source at the bottom of this post) ended up very straightforward. We had two states: LeaningLeft and LeaningRight. And two transitions between them: correctLeftLean and correctRightLean.
Once we had the servo reacting relatively correctly to the motion of the accelerometer, we rubber-banded the whole assemblage together. Allison built a leg for it to stand on and affixed that leg to a round wooden shaft so that the bot could roll over left or right but not tip over forward or backwards (along which axes it had no ability to correct itself).
Finally, we attached a balance beam to the bots' servo and set it loose.
We quickly discovered that the balance beam was nowhere near heavy enough or long enough to actually give the bot a chance of keeping itself vertical. Additionally, while the feedback between the accelerometer and the servo moved the beam in basically the right direction as we tilted the bot around, it's central point never seemed completely correct and it was prone to overreaction. Finally, the bot's leg was probably far too long meaning that as soon as the bot was slightly off axis, the rotational force would build up rapidly, throwing it straight to the table.
During our in-class critique, our fellow students had helpful ideas like examining how Victorian-era balancing toys use counterweights
and actually taking tightrope-walking lessons at the Chelsea Pier.
I intend to keep working on this project. The image of a tiny balancing bot, re-enacting Petit's "coup" at the top of a miniature replica of the now-vanished towers sticks with me.