Saturday, 24 September 2011

Fun with Robots, Arduino and Android

Together with Mike Hogg from my firm, Zühlke Engineering, I recently developed a demonstration project over a three-day training exercise. We purchased a simple robot and added a set of three infra-red sensors capable of detecting a black line marked out on the ground with electrician's tape. We had to develop a line-sensing algorithm and control logic to follow the line and stop at stations (a short length of tape at right angles to the line) until instructed to move on.

We followed a test-driven development (TDD) approach for C++ using CppUTest, as described by James Grenning, to create a state machine to turn sensor readings into motor control instructions (with hindsight, we might have saved time by resorting to the Machine Objects library). To my surprise, once we loaded the finished firmware to the Arduino board, it worked very well with only a bit of tweaking of the motor speed settings corresponding to "hard left", "slight left" etc.

Then we linked this with an application we developed for an Android tablet computer (Motorola Xoom) that could be used to instruct the robot to go to any selected station, pick up/drop a "payload" (only conceptually) and return to base. The two components communicated by Bluetooth radio link.

Finally, the tablet app was linked via a RESTful Web Service interface to an "enterprise" system developed by other colleagues on the training course, that controlled the whole delivery network and knew which consignments had to be delivered to what stations. The tablet would send a message to the enterprise server telling it where the robot had arrived, and receive back an instruction containing the name of the next station to move to. The robot would then move off automatically after 5 seconds.


The whole thing was enormous fun (as well as very instructive) and was demonstrated successfully to the entire group (see photo).

Jason Gorman and Simon Peyton Jones, among others, have recently been at pains to point out the shortcomings of IT education in the UK. Thinking about the above exercise, it occurred to me that it is just the sort of project that could engender enthusiasm for the subject from a wide range of school students. It involves lots of varied tasks from assembling the hardware to designing the user interface, and of course the devising of suitable protocols between all the components.

Simon Peyton Jones of Microsoft Research will be presenting an interactive talk about Computing At School on 2nd November in London, and the following month (6 December) Mike and I plan to do a session on the Robot Shop exercise at the same location. Anyone interested will be most welcome.