Page 343 - Hacking Roomba
P. 343
324 Part III — More Complex Interfacing
Listing 14-4 Continued
elsif( $CMD eq ‘backward’ ) {
roomba_backward();
}
elsif( $CMD eq ‘spinleft’ ) {
roomba_spinleft();
}
elsif( $CMD eq ‘spinright’ ) {
roomba_spinright();
}
elsif( $CMD eq ‘stop’ ) {
roomba_stop();
}
else {
usage();
}
In order to use the roombacmd.mpl script, you must first install microperl and get stty (if
it’s not already on your system). Listing 14-5 shows the commands needed to do that, as well as
download the roombacmd.mpl script and install everything in a non-volatile location.
Listing 14-5: Installing and Using roombacmd.mpl
root@OpenWrt:~# ipkg install microperl
root@OpenWrt:~# ipkg install libgcc
root@OpenWrt:~# wget
http://roombahacking.com/software/roombacmd/roombacmd.mpl
root@OpenWrt:~# wget
http://roombahacking.com/software/roombacmd/stty.tar.gz
root@OpenWrt:~# tar xvzf stty.tar.gz
root@OpenWrt:~# chmod +x ./stty
root@OpenWrt:~# chmod +x ./roombacmd.mpl
root@OpenWrt:~# mv stty roombacmd.mpl /usr/bin
With everything in place you can now control Roomba from the command line of the WL-
HDD. Listing 14-6 shows a simple Logo-like example of drawing a square with the Roomba.
Listing 14-6: Controlling Roomba from the Command Line
root@OpenWrt:~# # draw a square
root@OpenWrt:~# ./roombacmd.mpl /dev/usb/tts/0 init
root@OpenWrt:~# ./roombacmd.mpl /dev/usb/tts/0 forward ;
sleep 5