# HG changeset patch # User Robert McIntyre # Date 1336483339 18000 # Node ID 702b5c78c2de437cbd0b04e83cbb15a8cf0a8901 # Parent 52de8a36edde16d40d839b400ebf9382a0351c66 gathered all the tests into (run-suite), which should make testing vastly easier. diff -r 52de8a36edde -r 702b5c78c2de org/body.org --- a/org/body.org Thu Mar 01 06:24:17 2012 -0700 +++ b/org/body.org Tue May 08 08:22:19 2012 -0500 @@ -135,8 +135,8 @@ (.getMesh geom)) (if-let [mass (meta-data geom "mass")] (do - (println-repl - "setting" (.getName geom) "mass to" (float mass)) + ;;(println-repl + ;; "setting" (.getName geom) "mass to" (float mass)) (float mass)) (float 1)))] (.addControl geom physics-control))) @@ -295,7 +295,7 @@ (defmethod joint-dispatch :point [constraints control-a control-b pivot-a pivot-b rotation] - (println-repl "creating POINT2POINT joint") + ;;(println-repl "creating POINT2POINT joint") ;; bullet's point2point joints are BROKEN, so we must use the ;; generic 6DOF joint instead of an actual Point2Point joint! @@ -308,7 +308,7 @@ pivot-b)) ;; but instead we must do this: - (println-repl "substituting 6DOF joint for POINT2POINT joint!") + ;;(println-repl "substituting 6DOF joint for POINT2POINT joint!") (doto (SixDofJoint. control-a @@ -321,7 +321,7 @@ (defmethod joint-dispatch :hinge [constraints control-a control-b pivot-a pivot-b rotation] - (println-repl "creating HINGE joint") + ;;(println-repl "creating HINGE joint") (let [axis (if-let [axis (:axis constraints)] @@ -348,14 +348,14 @@ limit-xy (:limit-xy constraints) twist (:twist constraints)] - (println-repl "creating CONE joint") - (println-repl rotation) - (println-repl - "UNIT_X --> " (.mult rotation (Vector3f. 1 0 0))) - (println-repl - "UNIT_Y --> " (.mult rotation (Vector3f. 0 1 0))) - (println-repl - "UNIT_Z --> " (.mult rotation (Vector3f. 0 0 1))) + ;;(println-repl "creating CONE joint") + ;;(println-repl rotation) + ;;(println-repl + ;; "UNIT_X --> " (.mult rotation (Vector3f. 1 0 0))) + ;;(println-repl + ;; "UNIT_Y --> " (.mult rotation (Vector3f. 0 1 0))) + ;;(println-repl + ;; "UNIT_Z --> " (.mult rotation (Vector3f. 0 0 1))) (doto (ConeJoint. control-a @@ -398,13 +398,14 @@ ;; will register the joint with the physics system ;; when the simulation is started. (do - (println-repl "creating joint between" - (.getName obj-a) "and" (.getName obj-b)) + ;;(println-repl "creating joint between" + ;; (.getName obj-a) "and" (.getName obj-b)) (joint-dispatch constraints control-a control-b pivot-a pivot-b joint-rotation)) - (println-repl "could not find joint meta-data!")))) + ;;(println-repl "could not find joint meta-data!") + ))) #+end_src Creating joints is now a matter of applying =connect= to each joint @@ -507,6 +508,14 @@ "Models/test-creature/worm.blend")) (defn test-worm + + "Testing physical bodies: + You should see the the worm fall onto a table. You can fire + physical balls at it and the worm should move upon being struck. + + Keys: + : fire cannon ball." + ([] (test-worm false)) ([record?] (let [timer (RatchetTimer. 60)] @@ -527,6 +536,9 @@ no-op)))) #+end_src +#+results: test-4 +: #'cortex.test.body/test-worm + #+begin_html
diff -r 52de8a36edde -r 702b5c78c2de org/hearing.org --- a/org/hearing.org Thu Mar 01 06:24:17 2012 -0700 +++ b/org/hearing.org Tue May 08 08:22:19 2012 -0500 @@ -1021,6 +1021,14 @@ (in-ns 'cortex.test.hearing) (defn test-worm-hearing + "Testing hearing: + You will see the worm fall onto a table. There is a long + horizontal bar which shows the waveform of whatever the worm is + hearing. When you play a sound, the bar should display a waveform. + + Keys: + : play sound" + ([] (test-worm-hearing false)) ([record?] (let [the-worm (doto (worm) (body!)) diff -r 52de8a36edde -r 702b5c78c2de org/movement.org --- a/org/movement.org Thu Mar 01 06:24:17 2012 -0700 +++ b/org/movement.org Tue May 08 08:22:19 2012 -0500 @@ -123,7 +123,7 @@ (vec (map #(float (* strength (/ % (last pool-integral)))) pool-integral)) control (.getControl target RigidBodyControl)] - (println-repl (.getName target) axis) + ;;(println-repl (.getName target) axis) (fn [n] (let [pool-index (max 0 (min n (dec (count pool)))) force (forces pool-index)] @@ -186,6 +186,15 @@ #+name: test-movement #+begin_src clojure (defn test-worm-movement + "Testing movement: + You should see the worm suspended in mid air and a display on the + right which shows the current relative power being exerted by the + muscle. As you increase muscle strength, the bar should fill with + red, and the worm's upper segment should move. + + Keys: + h : increase muscle exertion + n : decrease muscle exertion" ([] (test-worm-movement false)) ([record?] (let [creature (doto (worm) (body!)) diff -r 52de8a36edde -r 702b5c78c2de org/proprioception.org --- a/org/proprioception.org Thu Mar 01 06:24:17 2012 -0700 +++ b/org/proprioception.org Tue May 08 08:22:19 2012 -0500 @@ -217,11 +217,23 @@ (defn test-proprioception "Testing proprioception: - You should see two floating bars, and a printout of pitch, yaw, and - roll. Pressing key-r/key-t should move the blue bar up and down and - change only the value of pitch. key-f/key-g moves it side to side - and changes yaw. key-v/key-b will spin the blue segment clockwise - and counterclockwise, and only affect roll." + You should see two floating bars, and a display of pitch, yaw, and + roll. The white dot measures pitch (spin around the long axis), the + green dot measures yaw (in this case, rotation around a circle + perpendicular to your line of view), and the red dot measures + roll (rotation around a circle perlendicular to the the other two + circles). + + Keys: + r : rotate along long axis + t : opposite direction of rotation as + + f : rotate in field of view + g : opposite direction of rotation as + + v : rotate in final direction + b : opposite direction of rotation as " + ([] (test-proprioception false)) ([record?] (let [hand (box 0.2 1 0.2 :position (Vector3f. 0 0 0) diff -r 52de8a36edde -r 702b5c78c2de org/sense.org --- a/org/sense.org Thu Mar 01 06:24:17 2012 -0700 +++ b/org/sense.org Tue May 08 08:22:19 2012 -0500 @@ -376,7 +376,8 @@ (fn [#^Node creature] (if-let [sense-node (.getChild creature parent-name)] (seq (.getChildren sense-node)) - (do (println-repl "could not find" parent-name "node") [])))) + (do ;;(println-repl "could not find" parent-name "node") + [])))) (defn closest-node "Return the physical node in creature which is closest to the given diff -r 52de8a36edde -r 702b5c78c2de org/test.org --- a/org/test.org Thu Mar 01 06:24:17 2012 -0700 +++ b/org/test.org Tue May 08 08:22:19 2012 -0500 @@ -11,9 +11,18 @@ #+begin_src clojure (ns cortex.test (:use cortex.util) - (:require [cortex.test touch vision body hearing]) + (:require [cortex.test + body + vision + hearing + touch + proprioception + movement + + ]) (:import com.jme3.app.state.AppState - com.jme3.system.AppSettings)) + com.jme3.system.AppSettings) + (:import (com.jme3.math Triangle Vector3f Vector2f Ray Matrix4f))) (defn run-world "run the simulation and wait until it closes properly." @@ -44,21 +53,34 @@ "print the docstring for the test, then run the simulation which it yields, waiting until it is terminated." [test-fn-var] + (println-repl (:doc (meta test-fn-var))) (println-repl "\n ****************\n") - (println-repl (:doc (meta test-fn-var))) (run-world ((deref test-fn-var)))) (def test-suite "The full test suite for all sensors/effectors." - [#'cortex.test.touch/test-skin - #'cortex.test.vision/test-two-eyes - #'cortex.test.hearing/test-advanced-hearing - #'cortex.test.body/test-proprioception - #'cortex.test.body/test-motor-control]) + [#'cortex.test.body/test-worm + #'cortex.test.vision/test-pipeline + #'cortex.test.vision/test-worm-vision + + #'cortex.test.hearing/test-java-hearing + #'cortex.test.hearing/test-worm-hearing + + #'cortex.test.touch/test-basic-touch + #'cortex.test.touch/test-worm-touch + + #'cortex.test.proprioception/test-proprioception + + #'cortex.test.movement/test-worm-movement + ]) + + + (defn run-suite "Run the entire test-suite." [] + (println-repl "\n ****************\n") (dorun (map run-test test-suite))) #+end_src diff -r 52de8a36edde -r 702b5c78c2de org/touch.org --- a/org/touch.org Thu Mar 01 06:24:17 2012 -0700 +++ b/org/touch.org Tue May 08 08:22:19 2012 -0500 @@ -531,6 +531,14 @@ (in-ns 'cortex.test.touch) (defn test-basic-touch + "Testing touch: + You should see a cube fall onto a table. There is a cross-shaped + display which reports the cube's sensation of touch. This display + should change when the cube hits the table, and whenever you hit + the cube with balls. + + Keys: + : fire ball" ([] (test-basic-touch false)) ([record?] (let [the-cube (doto (touch-cube) (body!)) @@ -632,6 +640,13 @@ (in-ns 'cortex.test.touch) (defn test-worm-touch + "Testing touch: + You will see the worm fall onto a table. There is a display which + reports the worm's sense of touch. It should change when the worm + hits the table and when you hit it with balls. + + Keys: + : fire ball" ([] (test-worm-touch false)) ([record?] (let [the-worm (doto (worm) (body!)) diff -r 52de8a36edde -r 702b5c78c2de org/vision.org --- a/org/vision.org Thu Mar 01 06:24:17 2012 -0700 +++ b/org/vision.org Tue May 08 08:22:19 2012 -0500 @@ -537,7 +537,7 @@ (in-ns 'cortex.test.vision) (defn change-color [obj color] - (println-repl obj) + ;;(println-repl obj) (if obj (.setColor (.getMaterial obj) "Color" color))) @@ -546,6 +546,18 @@ (fire-cannon-ball))) (defn test-worm-vision + "Testing vision: + You should see the worm suspended in mid-air, looking down at a + table. There are four small displays, one each for red, green blue, + and gray channels. You can fire balls of various colors, and the + four channels should react accordingly. + + Keys: + r : fire red-ball + b : fire blue-ball + g : fire green-ball + : fire white ball" + ([] (test-worm-vision false)) ([record?] (let [the-worm (doto (worm)(body!))