
One of the things that I love about Clojure is that it can go anywhere that Java can. That is why, when I found out that the Roomba already had a Java library written for it – I was excited to be able to hook it up to my Emacs / Swank and be able to control it from my editor.
It is great fun! If you have a Roomba at home and you want to play along…
- Read Setting up and Configuring Bluetooth and Roomba part from this post.
- Checkout the sample project clj-roomba from github.
Have fun doing this like this:
(def roomba (RoombaCommSerial. )) ;;Find your port for your Roomba (map println (.listPorts roomba)) (def portname "/dev/cu.FireFly-943A-SPP") (.connect roomba portname) (.startup roomba) ;;puts Roomba in safe Mode ;; What mode is Roomba in? (.modeAsString roomba) (.control roomba) (.updateSensors roomba) ; returns true if you are connected (.pause roomba 30) (.playNote roomba 72 40) (.playNote roomba 79 40) (.spinLeft roomba) (.spinRight roomba) (.goBackward roomba) (.goForward roomba) (.turnLeft roomba) (.turnRight roomba) (.stop roomba) (.reset roomba) (.vacuum roomba true) (.vacuum roomba false) (.clean roomba) ;; Get the sensor data (.updateSensors roomba) (.bumpLeft roomba) (.bumpRight roomba) (.wheelDropLeft roomba) (.wheelDropRight roomba) (.wheelDropCenter roomba) (.sensorsAsString roomba) (defn bark [r] (doto r (.vacuum true) (.playNote 50 5) (.pause 150) (.vacuum false))) (bark roomba) |
A quick video of hacking Roomba in action
Next up – Getting more roombas to implement Rich Hickey’s ant colony demo…

Hello,
I just read few messages from your blog. It is interesting. I have a technical question for you: did you manage to stream the sensor input from your robot using the bluetooth adapter (using for instance the command [148 1 100]) ?
Thanks.
If you download the Roomba java zip http://hackingroomba.com/code/roombacomm/ – It has examples showing the sensor input.
Thank you for your answer. Well, the problem is not really making the roomba start streaming. The problem is that the firefly (the bluetooth device) disconnects after a while and the robot becomes unresponsive. I was wondering if you observed something similar.
Hmmm. That is strange. I haven’t seen that.