Page 382 - Hacking Roomba
P. 382
Chapter 15 — RoombaCam: Adding Eyes to Roomba 363
A Final Fun Thing
Like most of the newer wireless routers, the WRTSL54GS has a button on its front. This
button is available in OpenWrt by looking at /proc/sys/button. For example:
root@roombawrt:~# cat /proc/sys/button # button not pressed
0
root@roombawrt:~# cat /proc/sys/button # button pressed
1
It’s easy to write a little program that monitors the button and takes a snapshot and archives it,
like the snapshot command of the control panel. For example, Listing 15-8 shows just such a
program that runs in the background. Now you can tell anyone to go and press the button, and
you’ll get a picture of them doing it. Alternatively, you could have it e-mail the picture and post
it to Flickr. (There’s a mini-sendmail ipkg package to help with this.)
Listing 15-8: Making the WRTSL54GS Button Take a Picture
#!/bin/sh
# edit this: where the webcam is writing an image
PICPATH=”/tmp/SpcaPic.tif”
# edit this: where archived (“snapshot”) images should be
stored
SNAPPATH=”/mydisk/archive/cam-`date -Is`”
while [ true ]; do
sleep 1
if [ `cat /proc/sys/button` = “1” ]; then
echo “Saving snapshot to $SNAPPATH”
cp $PICPATH “$SNAPPATH.tif”
fi
done &
Summary
You now have a vision-enabled, large storage capacity, Linux-running Roomba rover and a
handful of common consumer electronics components. It’s a great platform to start adding
complex data acquisition algorithms and peripherals. You could easily add a cheap USB audio
dongle and microphone so Roomba records what it hears as well as what it sees. Multiple cam-
eras pose no problem as well, and you could add a backward-facing camera to supplement the
front camera. Add four cameras and produce a real-time panorama of what your Roomba sees.
You can also build new C programs that run natively in OpenWrt to access all these peripher-
als. From the huge repositories of open-source software, you could find some interesting code
and port it for use with OpenWrt. Most non-GUI Linux code will port easily. Find some of
the free motion-tracking code and try it out on your Roomba. Program your Roomba to follow
you throughout your house. Add USB audio and some powered speakers and you have a boom
box that plays your favorite online radio station wherever you go.