Tag Archives: Mechanical Design

Python Helps Win at Hardware Hackathon

–Jack Minardi, Enthought Developer

I recently participated in the Upverter + YCombinator Hardware Hackathon. My team placed first overall, and it was made possible with the power of Python.

The hackathon lasted about 10 hours, and the goal was to design and build a prototype hardware device. For our entry, my team built a wearable force feedback glove. When worn, the glove is able to simulate the feeling of holding a physical object. Potential uses for this device include gaming, surgical assistance, or other applications in augmented reality space. I have been interested in expanding the human-computer interface for a while, and this hack allowed me to explore the world of haptic feedback.

Mechanical Design
A length of twine is connected from the glove’s fingertips, through two guiding braces, back to a hobby servo. This is repeated for each finger. The servo is connected to a platform which is connected to the back of the glove. When the servo is actuated it pulls back on the twine holding the fingers open. Through this process we are able to simulate the resistive force of an object holding the wearers hand open.

For the demo at the competition, we used a distance sensor to set the hand position. The closer your hand was to the distance sensor, the more your fingers were pulled open. This simulated the feeling of squeezing a virtual object in your hand.

-Drawing by Tom Sherlock

Hardware I/O
To control servos and read from sensors usually you use GPIO pins. GPIO stands for General Purpose Input/Output. For output, the basic idea is that you can set the voltage on the pin high (5 volts) or low (0 volts). Sending the correct sequence of high and low pulses to a servo will cause it to go to a certain position. For input, you can read whether a certain pin is high or low. If you connect a sensor to an input pin, it is able to communicate information by sending specific sequences of high and low pulses.

Control Software
In this case, to control the servo and read from the distance sensor, we used a Raspberry Pi running Python. The script that reads from the sensor and sets the servo position can be found here: https://gist.github.com/jminardi/5022297

This script uses a library I wrote called RobotBrain. It sits on top of RPi.GPIO and provides a higher level interface for controlling individual pins and motors. The only module used in this project was the Servo, which makes it easy to set a servo to a given position. The Servo module uses the ServoBlaster kernal module under the covers, which exposes the servo as device in the filesystem.

In the end I had a great time at the hackathon. I think we were able to put together a winning demo in part because of the power of Python. With just a few libraries we are able to reason at a high level about what we wanted our servo to do and what our sensors were seeing. If you have ever tried doing hardware control in a lower level language, you know just how hard that can be, and as you can see, how easy Python makes it.

Read more here: http://techcrunch.com/2013/02/26/y-combinator-hardware-hackathon-winner/

To see more hardware control using Python, stop by Enthought’s booth at PyCon 2013 in Santa Clara. I will be demoing reading from sensors and controlling actuators using Python and a Raspberry Pi. We will also be giving out 6 raspi’s so stop by and enter your name.