During the summer of 2012, Jon and I were itching to build something cool. The problem was that our previous project, the Rocket Ship Treehouse, had gotten out of control and consumed most of our hobby time for more than two years. This time, we wanted to do something short and sweet. We decided our project should last exactly one weekend: we'd start at 9AM on a Saturday, and set a hard deadline of Sunday evening no matter how near or far it was from being finished.
We eventually settled on what we came to call the SALWOW: Sail Across Lake Washington, One Weekend. We'd try to build an autonomous boat that could navigate itself across the lake! Our dream was to drop it in the lake on one shore, drive across the bridge and pick it up on the other side. This seemed hard enough to be interesting, but easy enough that we just might be able to do it a single weekend.
Between the two of us, Jon and I have pretty decent prototyping facilities. He has a good woodworking shop and I've got a nice electronics lab. Both are well stocked with random parts, so our hope was to complete the challenge without buying anything in advance. We'd have to build a self-driving boat using just what we had on hand and what we could buy over the course of the weekend.
We met bright and early (for us; we're computer scientists) at 9AM on Saturday morning and talked first about what kind of boat we should start with. There seemed to be two general options open:
- Start with a tiny remote-controlled boat from a hobby shop; remove the radio receiver and replace it with our own electronics.
- Get a human-sized dinghy, add a trolling motor and some marine batteries that Jon had in his basement, and try to steer it using big servos or stepper motors from the junk box. We discovered that a local sporting-goods store sold inflatable rowboats for just 25 bucks.
There were pros and cons to each plan. The bigger boat seemed like it would be more likely to survive a trip across the lake. On the other hand, we might spend the whole weekend trying to build a steering system for the trolling motor. An RC boat had the advantage of already having the mechanics worked out; all we'd have to do is replace the control system. The winds were light that weekend so it seemed at least plausible that a hobby-sized RC boat would make it across the lake without sinking. Our decision was made when we called our friend JD for advice. He owns and frequently sails a boat on Lake Washington with his wife Sherry. He thought there was a decent chance the RC boat would sink, but had a larger concern:
"Are you planning on taking your own boat alongside the boat you're building to watch it?"
"Uh.... no, we were hoping to just put it in the lake on one shore and pick it up on the other."
"You're doing what ?"
Okay, so maybe unleashing an unattended trolling motor steered by hastily-written software on a public lake wasn't the best idea. We decided to try out Option 1 and see how far we could get with an RC boat. First stop: Hobbytown USA!
They had a small selection of RC boats; the AquaCraft Mini Wildcat seemed to fit the bill, but we quickly realized there was a problem. According to the manual, we could only expect the boat to run for 8 to 10 minutes with the standard 1,100mAh battery.
At its narrowest point, the Lake Washington is about 1.4 miles (2¼ km) wide. Not all the shoreline is accessible, so we'd planned a 1.8 mile route from Magnuson Park to the public beach in Kirkland.
We weren't sure how fast the Wildcat could go in the open lake. Even at 15 miles per hour, it would need nearly 8 minutes to go 1.8 miles. We'd need a bigger battery. Hobbytown sold a variety of sizes, but a larger battery would mean more weight. The boat might not even float. Even if it did, the boat would go even slower -- thus needing more time to cross the lake, and a yet larger battery. There might be no escape from this vicious cycle. We bought a 4,500mAh battery and set out to do some tests.
Next stop: our offices at the Microsoft campus, just down the street from Hobbytown. We weighed the 4,500mAh batteries, attached an equivalent mass of bolts to the boat, and floated it in the courtyard's water feature. The nose was just barely above the waterline.
It looked like we'd need some supplemental flotation. We deferred that problem until later and did our next test: boat speed. We head across campus to the big circular fountain behind Building 18. Jon drove the boat around the perimeter of the lake while I timed it. I pulled a map up on my phone and measured the fountain's diameter from the aerial photo. With that and Jon's lap time, we computed the boat could only go about 3 miles per hour with all the extra weight on it. The large battery would have the capacity to get us across. Barely.
We broke for lunch, then head over to Jon's workshop to try and solve the buoyancy problem. Jon had some inch-thick Styrofoam sheets left over from previous projects that he wanted to fashion into "wings" that would increase the boat's surface area, allowing it to float higher and hopefully not get swamped in Lake Washington. He'd made his own foam cutting rig: a thin wire pulled taut in a wooden frame with a car battery attached. The current from the battery gets the wire hot enough to cut the foam.
After a quick float test in the bathtub, we declared the buoyancy problem Solved and moved on to the electronics.
Next stop was Jeremy's electronics lab. We opened the boat and discovered the radio receiver was both literally and figuratively a black box: it had been potted to keep it watertight. There was no way to inspect the components directly so we hooked the boat up to the oscilloscope and multimeter to figure out what was going on.
It turned out to be pretty straightforward. The battery provided 7.2 volts. The radio receiver fed this, unregulated, into the boat's two DC motors, with speed controlled by pulse-width modulation. The rudder was attached to a servo that was also getting unregulated 7.2v power, plus a standard servo control inputs (a 20Hz pulse whose width varies between 1ms and 2ms) that was regulated down to 5v.
We spent the evening designing the circuit board we wanted to build to replace the radio receiver and make the boat drive itself. Jon had an old GPS receiver with an RS232 serial port he was willing to sacrifice. The general idea was that we'd build a board with a microcontroller that would read the GPS position from a serial port, compute the correct turn (left, right or straight) to keep it on course, and generate a rudder servo command as needed. We'd put an N-channel MOSFET between the motors and the battery's ground so we'd be able to control propeller speed if necessary. Finally, we'd want a second serial port to use for debugging output so we could see what was going on.
I had a selection of Atmel microcontrollers in stock, including the Atmega 328 that most hobbyists know as the chip in the Arduino Uno, and its larger sibling, the Atmega 1284. We picked the '1284 mainly because it has the two serial ports we needed; the '328 only has one. We'd use a Max232 to convert the serial voltage levels between the microcontroller's voltage, which we'd regulate to 5v using a linear regulator, and the 12v used by the GPS and our debugging laptop. Our original plan, soon abandoned, was also to put one of Sparkfun's SD Card Headers on the board so we'd be able to log the GPS positions for post-mortem analysis (if we were lucky enough to ever see the boat again).
As Jon started working out the math to convert from latitude and longitude to a bearing, I drew out the schematic:
I started to assemble the board while Jon wrote some code. Soon after, we found ourselves exhausted and hungry, so we got some dinner and called it a night.
Sunday morning was quiet: I was soldering, and Jon was coding. By noon I'd put together a board with the processor, a programming header, a servo header, a voltage regulator, and the MAX232 serial level converter with two three-pin serial headers on it. Conveniently, the boat's motors and rudder all used standard 0.1" sockets; I always keep 0.1" headers in stock.
By 1PM, the board was ready for its first test! I wrote a simple test program that would command the rudder servo to go left, straight, right, and straight. I attached the board to one of my bench power supplies and held my breath as I turned it on, half-expecting it to blow up:
By the afternoon, things were starting to come together. Jon had written basic navigation software that seemed to do the right thing. He'd torn apart his old GPS to make the package smaller and lighter. I added an extra 5v regulated output to the board we built; this let us power the GPS from the boat's battery rather than carrying the weight of four more AA's for the GPS. We got the serial connection between the GPS and microcontroller working.
We noticed that the rudder would sometimes spuriously turn left or right when we'd run the motors. DC motors are inductive loads, so we'd already added flyback diodes; we guessed that the voltage was sagging due to the large inrush current when the motors were turning on. To fix it, we put a giant capacitor on the unregulated side of the battery. This seemed to work.
By this time my electronics lab was quite a mess, but the electronics were done!
The problem we now had was a mechanical one. The electronics and larger battery wouldn't fit into the boat's watertight inner compartment. We made one more trip to Jon's workshop where we took the painful step of cutting the top of the boat's hull to make room for our additions. We then tried to waterproof everything as well as we could ... which, as you can see from our prodigious use of Saran wrap, wasn't very well.
In an attempt to prevent panic and a visit from Homeland Security, I wrote a note on the bow, with my phone number: "Science! If found, call..."
Before trying to sail across Lake Washington, we decided to start with a smaller scale test in Green Lake, a small, quiet lake near downtown Seattle popular for its jogging path and boat rentals. Our plan was to try to program the boat with a dozen waypoints that would command it to sail a few hundred feet out into the lake, go around a tiny island in the center, and come back to the dock where we'd launched it.
We loaded Jon's truck with his kayak, his netbook, the microcontroller's programming board, and a bunch of electronics equipment just in case we needed to execute a field repair. Off to the lake!
The first step was another float test. Now that the boat was fully loaded with its cargo, and we'd intentionally breached the hull to fit the electronics in, would it take on water?
Well, the boat floated ... sort of. The bottom of the boat was damp from just being in the water briefly. Next, we gave the boat a small test program so we could see if it was capable of navigating at all: after power-on, the boat would spend five seconds each going straight, turning left, going straight again, then turning right. After two such cycles, it would turn its motors off so we could retrieve it. I got in the kayak and we ran the test program.
What the boat actually did was go straight, then gentle-right, then hard-right. No problem, we thought: the boat just isn't quite symmetrical any more; we can fix it with a little calibration. We took it out of the water and reprogrammed it with new, further-left rudder positions for each of the three states. We put it in the water again, and this time it did something different: turn hard right, then straight, then ... wander seemingly at random.
We tried calibration a few more times, but things started to look bad. The boat was taking on a lot of water. The more water it took on, the more its direction seemed to become random. We're not sure exactly what happened; it could be the increasing weight of water sloshing around in the bottom eventually became the dominant factor in the boat's direction, overpowering the tiny rudder.
Finally, as the sun began to set, we decided we should try Jon's navigation software at least once even though it seemed certain it'd fail. Unfortunately, we never got the chance: when we pulled the boat out of the water one last time to reprogram it, there was so much water in the electronics that the GPS had shorted out and died. And with that we declared our project to be finished!
I'd call this project a successful failure. The failure part is obvious: we didn't even get the boat to cross Green Lake, let alone the much larger Lake Washington. But we had a lot of fun and stuck ruthlessly to our one-weekend time limit. The limit ended up being really helpful in guiding our decisions. At one point, trying to avoid buying a $40 battery charger at Hobbytown, Jon said, "Can't we just build a charger ourselves?". I spent a minute searching the web, then said: "Jon, do you want to spend the weekend building a charger, or building a boat that can sail across a lake?" We immediately paid the $40.
Given the short time, we actually did accomplish a surprising amount: we built a fully working microcontroller board that put the motors and rudder under software control and wrote autonomous navigation software with a small simulator. Perhaps, one future weekend, we'll try again with a larger boat... along with a chase boat, and a much larger disclaimer on the front.
Jeremy Elson is a computer science researcher who spends his time outside of work riding bicycles, flying airplanes, and building electronics.
Jon Howell studies operating systems by day; after work he goes on adventures with his four junior astronauts.