Thursday, February 19, 2015

How I Turned Nursery Songs Into Nightmares

This is a story I've already shared with some friends, but I think it’s worth commemorating in writing as well. It is best told in two movements.

I. Adagio, suspenseful
The background of this sad tale is as follows: in my Engineering 102 class, we’re building and programming small Lego robots that are tasked with searching an arena for yellow and blue canisters, capturing the canisters, and delivering them to separate landfills, one of which is marked by a strong light source. (If you've talked with me recently, you've probably heard about this robot thing, because it is somehow the most stressful project I've ever undertaken, even though from all accounts it’s very hard to get a bad grade in the course.) For the purpose of the preliminary competition, which is the focus of this story, we’ll ignore the yellow canisters and the landfill without the light source.

My group coded a search function that makes the robot run in an increasing spiral from the center of the field. This involved a lot of switches and loops-within-loops, which got seriously confusing, so we decided to take an upperclassman’s advice and put bits of sound into our code at important points, in order to know what the robot was running at any particular time.

What a great idea, I thought to myself at 11:43pm as I was adding the sounds. In fact, I’ll choose the musical notes to be recognizable songs at each part of the function, so I can immediately know what’s going on. How about the first four notes of “Mary Had A Little Lamb” at the end of each search loop? It’ll be cute, I thought.

It’ll be cute. Cute.

Try this out with me. Sing the first four notes of “Mary Had A Little Lamb”—just the first four. You’ll find yourself singing “Mary had a—” and stopping there. And this is precisely what chimed its charming way through our heads every single time the robot completed one square and prepared to enter another.

Mary had a—
Mary had a—
Mary had a—a what?
What did Mary have??

II. Vivace, enunciated
For the other sound bytes, I foolishly chose snippets of Brahm's Lullaby. In particular, the robot declared that it had found the direction of the light source—when the light sensor read 50 or above—with a loud, four-note ascending melody before it would drive towards the light. This was all right in practice, when we used a phone flashlight as our simulated “light source” and only heard the melody a few times before the robot reached a threshold where it released the canister, backed away, and turned around.

On the actual field, during our competition, it came to our attention that our wheel motors were out of sync, enough that our robot had a significant left-turn drag whenever it tried to go forward. This meant that every time it tried to drive towards the light, it would turn left after about two inches, lose the light, rotate again until it found it, play the melody again, and repeat the whole process.

At around the tenth repetition of the melody, I started to tremble and cover my ears. At around the twelfth repetition, the robot leaped forward into a dramatic left turn near ninety degrees, then stopped in utter confusion, as the light readings on that particular part of the field fluctuated constantly between 49 and 50.

The melody began to play endlessly.

I yelled in anguish, lunged to the other side of the arena, and scrabbled at the robot’s off-button until the whole program aborted.

“Shut UP SHUT UP SHUT UP,” I screamed.
Fellow students nearby backed away, some laughing nervously.

Throughout the rest of the day today, Brahm's Lullaby has kept needling its way into my brain and taunting me with its deceptively innocent tones, but the song is ruined for me, forever. I've had to keep myself from clawing at my own ears in the middle of the street.

Needless to say, the sound bytes are coming out of our code as soon as we don’t need them anymore.

No comments: