Navigation Menu

Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gigasquid committed Aug 9, 2012
0 parents commit 2f411fc
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
/target
/lib
/classes
/checkouts
pom.xml
*.jar
*.class
.lein-deps-sum
.lein-failures
.lein-plugins
3 changes: 3 additions & 0 deletions .roomba_config
@@ -0,0 +1,3 @@
/dev/cu.FireFly-943A-SPP
SCI
N
16 changes: 16 additions & 0 deletions README.md
@@ -0,0 +1,16 @@
# clj-roomba

A Clojure library designed to ... well, that part is up to you.

## Usage
lein localrepo install roombacomm/roombacomm.jar roombacomm 0.96
lein localrepo install roombacomm/RXTXcomm.jar rxtxcomm 0103
http://wiki.processing.org/w/Serial_Issues

FIXME

## License

Copyright © 2012 FIXME

Distributed under the Eclipse Public License, the same as Clojure.
3 changes: 3 additions & 0 deletions doc/intro.md
@@ -0,0 +1,3 @@
# Introduction to clj-roomba

TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/)
6 changes: 6 additions & 0 deletions project.clj
@@ -0,0 +1,6 @@
(defproject repl-roomba "1.0.0-SNAPSHOT"
:description "Fun Sample Project to Control Roomba with Clojure"
:dependencies [ [org.clojure/clojure "1.3.0"]
[roombacomm "0.96"]
[rxtxcomm "0103"]]
:jvm-opts [~(str "-Djava.library.path=roombacomm/")])
17 changes: 17 additions & 0 deletions roombacomm/README.rxtx
@@ -0,0 +1,17 @@
These RXTX files were just copied directly from the 0103 released of
Processing.

Their versions are reported as:
Native lib Version = RXTX-2.1-7pre17
Java lib Version = RXTX-2.1-7pre17




If you've never used RXTX before on your Mac OS X box, run the command:

% ./macosx_setup.command

And then shutdown (not just log out) and log back in again.
And read this faq from Processing: http://processing.org/faq/bugs.html#serial

Binary file added roombacomm/librxtxSerial.jnilib
Binary file not shown.
Binary file added roombacomm/librxtxSerial.so
Binary file not shown.
55 changes: 55 additions & 0 deletions roombacomm/macosx_setup.command.old
@@ -0,0 +1,55 @@
#!/bin/sh
#
# Taken from Processing's serial library -=tod
#

#
# originally fixperm.sh from rxtx-2.1_6/contrib
# with a couple additions from pathsetup.command from fink [fry]

# A script to fix permissions for lock files on Mac OS X
# Contributed by Dmitry Markman <dimitry.markman@verizon.net>
# Fri Aug 23 15:46:46 MDT 2002

echo ""
echo ""
echo "This command will take care of a couple system things"
echo "so that you can properly use the serial port to communicate"
echo "between hardware devices and processing."
echo ""
echo "If there are actually changes that need to be made, then"
echo "enter your password when prompted. The command uses sudo,"
echo "and you'll need to have administrator access."
echo ""

echo -n "Do you want to continue? [Y/n] "
read answer
answer=`echo $answer | sed 's/^[yY].*$/y/'`
if [ -z "$answer" -o "x$answer" = "xy" ]; then
curruser=`sudo id -p | grep 'login' | sed 's/login.//'`

if [ ! -d /var/spool/uucp ]
then
sudo mkdir /var/spool/uucp
fi

sudo chgrp uucp /var/spool/uucp
sudo chmod 775 /var/spool/uucp

if [ ! `sudo niutil -readprop / /groups/uucp users | grep $curruser > /dev/null` ]
then
sudo niutil -mergeprop / /groups/uucp users $curruser
fi

echo "Finished making changes, you should be all set"
else
echo "Ok, nevermind then."
fi

echo ""
echo ""
echo " (All done... you can close this window now)"
echo ""
echo ""
echo ""

Binary file added roombacomm/rxtxSerial.dll
Binary file not shown.
55 changes: 55 additions & 0 deletions src/clj_roomba/core.clj
@@ -0,0 +1,55 @@
(ns clj-roomba.core
(:import roombacomm.RoombaCommSerial))

(println (System/getProperty "java.class.path"))
(println (System/getProperty "java.library.path"))

(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)
(.pause roomba 30)
(.updateSensors roomba)
(.playNote roomba 72 40)
(.playNote roomba 79 40)
(.spinLeft roomba)
(.spinRight roomba)
(.goBackward roomba)
(.goForward roomba)
(.turnLeft roomba)
(.turnRight roomba)

(.stop roomba)
(.reset roomba)


;; Get the sensor data
(.bumpLeft roomba)
(.bumpRight roomba)
(.wheelDropLeft roomba)
(.wheelDropRight roomba)
(.wheelDropCenter roomba)
(.sensorsAsString roomba)

(.vacuum roomba true)
(.vacuum roomba false)


(defn bark [r]
(doto r
(.vacuum true)
(.playNote 50 5)
(.pause 150)
(.vacuum false)))


(bark roomba)

(.disconnect roomba) ;; coredumps locally native problem?
7 changes: 7 additions & 0 deletions test/clj_roomba/core_test.clj
@@ -0,0 +1,7 @@
(ns clj-roomba.core-test
(:use clojure.test
clj-roomba.core))

(deftest a-test
(testing "FIXME, I fail."
(is (= 0 1))))

0 comments on commit 2f411fc

Please sign in to comment.