changeset 321:702b5c78c2de

gathered all the tests into (run-suite), which should make testing vastly easier.
author Robert McIntyre <rlm@mit.edu>
date Tue, 08 May 2012 08:22:19 -0500
parents 52de8a36edde
children b6e2b65f43e4
files org/body.org org/hearing.org org/movement.org org/proprioception.org org/sense.org org/test.org org/touch.org org/vision.org
diffstat 8 files changed, 123 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/body.org	Thu Mar 01 06:24:17 2012 -0700
     1.2 +++ b/org/body.org	Tue May 08 08:22:19 2012 -0500
     1.3 @@ -135,8 +135,8 @@
     1.4                (.getMesh geom))
     1.5               (if-let [mass (meta-data geom "mass")]
     1.6                 (do
     1.7 -                 (println-repl
     1.8 -                  "setting" (.getName geom) "mass to" (float mass))
     1.9 +                 ;;(println-repl
    1.10 +                 ;; "setting" (.getName geom) "mass to" (float mass))
    1.11                   (float mass))
    1.12                 (float 1)))]
    1.13          (.addControl geom physics-control)))
    1.14 @@ -295,7 +295,7 @@
    1.15  
    1.16  (defmethod joint-dispatch :point
    1.17    [constraints control-a control-b pivot-a pivot-b rotation]
    1.18 -  (println-repl "creating POINT2POINT joint")
    1.19 +  ;;(println-repl "creating POINT2POINT joint")
    1.20    ;; bullet's point2point joints are BROKEN, so we must use the
    1.21    ;; generic 6DOF joint instead of an actual Point2Point joint!
    1.22  
    1.23 @@ -308,7 +308,7 @@
    1.24       pivot-b))
    1.25  
    1.26    ;; but instead we must do this:
    1.27 -  (println-repl "substituting 6DOF joint for POINT2POINT joint!")
    1.28 +  ;;(println-repl "substituting 6DOF joint for POINT2POINT joint!")
    1.29    (doto
    1.30        (SixDofJoint.
    1.31         control-a
    1.32 @@ -321,7 +321,7 @@
    1.33  
    1.34  (defmethod joint-dispatch :hinge
    1.35    [constraints control-a control-b pivot-a pivot-b rotation]
    1.36 -  (println-repl "creating HINGE joint")
    1.37 +  ;;(println-repl "creating HINGE joint")
    1.38    (let [axis
    1.39          (if-let
    1.40              [axis (:axis constraints)]
    1.41 @@ -348,14 +348,14 @@
    1.42          limit-xy (:limit-xy constraints)
    1.43          twist    (:twist constraints)]
    1.44      
    1.45 -    (println-repl "creating CONE joint")
    1.46 -    (println-repl rotation)
    1.47 -    (println-repl
    1.48 -     "UNIT_X --> " (.mult rotation (Vector3f. 1 0 0)))
    1.49 -    (println-repl
    1.50 -     "UNIT_Y --> " (.mult rotation (Vector3f. 0 1 0)))
    1.51 -    (println-repl
    1.52 -     "UNIT_Z --> " (.mult rotation (Vector3f. 0 0 1)))
    1.53 +    ;;(println-repl "creating CONE joint")
    1.54 +    ;;(println-repl rotation)
    1.55 +    ;;(println-repl
    1.56 +    ;; "UNIT_X --> " (.mult rotation (Vector3f. 1 0 0)))
    1.57 +    ;;(println-repl
    1.58 +    ;; "UNIT_Y --> " (.mult rotation (Vector3f. 0 1 0)))
    1.59 +    ;;(println-repl
    1.60 +    ;; "UNIT_Z --> " (.mult rotation (Vector3f. 0 0 1)))
    1.61      (doto
    1.62          (ConeJoint.
    1.63           control-a
    1.64 @@ -398,13 +398,14 @@
    1.65        ;; will register the joint with the physics system
    1.66        ;; when the simulation is started.
    1.67        (do
    1.68 -        (println-repl "creating joint between"
    1.69 -                      (.getName obj-a) "and" (.getName obj-b))
    1.70 +        ;;(println-repl "creating joint between"
    1.71 +        ;;              (.getName obj-a) "and" (.getName obj-b))
    1.72          (joint-dispatch constraints
    1.73                          control-a control-b
    1.74                          pivot-a pivot-b
    1.75                          joint-rotation))
    1.76 -      (println-repl "could not find joint meta-data!"))))
    1.77 +      ;;(println-repl "could not find joint meta-data!")
    1.78 +      )))
    1.79  #+end_src
    1.80  
    1.81  Creating joints is now a matter of applying =connect= to each joint
    1.82 @@ -507,6 +508,14 @@
    1.83              "Models/test-creature/worm.blend"))
    1.84  
    1.85  (defn test-worm
    1.86 +
    1.87 +  "Testing physical bodies: 
    1.88 +   You should see the the worm fall onto a table. You can fire
    1.89 +   physical balls at it and the worm should move upon being struck.
    1.90 +
    1.91 +   Keys:
    1.92 +     <space> : fire cannon ball."
    1.93 +
    1.94    ([] (test-worm false))
    1.95    ([record?]
    1.96       (let [timer (RatchetTimer. 60)]
    1.97 @@ -527,6 +536,9 @@
    1.98          no-op))))
    1.99  #+end_src
   1.100  
   1.101 +#+results: test-4
   1.102 +: #'cortex.test.body/test-worm
   1.103 +
   1.104  #+begin_html
   1.105  <div class="figure">
   1.106  <center>
     2.1 --- a/org/hearing.org	Thu Mar 01 06:24:17 2012 -0700
     2.2 +++ b/org/hearing.org	Tue May 08 08:22:19 2012 -0500
     2.3 @@ -1021,6 +1021,14 @@
     2.4  (in-ns 'cortex.test.hearing)
     2.5  
     2.6  (defn test-worm-hearing
     2.7 +  "Testing hearing:
     2.8 +   You will see the worm fall onto a table.  There is a long
     2.9 +   horizontal bar which shows the waveform of whatever the worm is
    2.10 +   hearing. When you play a sound, the bar should display a waveform.
    2.11 +
    2.12 +   Keys:
    2.13 +   <enter> : play sound"
    2.14 +
    2.15    ([] (test-worm-hearing false))
    2.16    ([record?] 
    2.17       (let [the-worm (doto (worm) (body!))
     3.1 --- a/org/movement.org	Thu Mar 01 06:24:17 2012 -0700
     3.2 +++ b/org/movement.org	Tue May 08 08:22:19 2012 -0500
     3.3 @@ -123,7 +123,7 @@
     3.4          (vec (map  #(float (* strength (/ % (last pool-integral))))
     3.5                pool-integral))
     3.6          control (.getControl target RigidBodyControl)]
     3.7 -    (println-repl (.getName target) axis)
     3.8 +    ;;(println-repl (.getName target) axis)
     3.9      (fn [n]
    3.10        (let [pool-index (max 0 (min n (dec (count pool))))
    3.11              force (forces pool-index)]
    3.12 @@ -186,6 +186,15 @@
    3.13  #+name: test-movement
    3.14  #+begin_src clojure
    3.15  (defn test-worm-movement
    3.16 +  "Testing movement:
    3.17 +   You should see the worm suspended in mid air and a display on the
    3.18 +   right which shows the current relative power being exerted by the
    3.19 +   muscle. As you increase muscle strength, the bar should fill with
    3.20 +   red, and the worm's upper segment should move.
    3.21 +
    3.22 +   Keys:
    3.23 +     h  : increase muscle exertion
    3.24 +     n  : decrease muscle exertion"
    3.25    ([] (test-worm-movement false))
    3.26    ([record?]
    3.27       (let [creature (doto (worm) (body!))
     4.1 --- a/org/proprioception.org	Thu Mar 01 06:24:17 2012 -0700
     4.2 +++ b/org/proprioception.org	Tue May 08 08:22:19 2012 -0500
     4.3 @@ -217,11 +217,23 @@
     4.4  
     4.5  (defn test-proprioception
     4.6    "Testing proprioception:
     4.7 -   You should see two floating bars, and a printout of pitch, yaw, and
     4.8 -   roll. Pressing key-r/key-t should move the blue bar up and down and
     4.9 -   change only the value of pitch. key-f/key-g moves it side to side
    4.10 -   and changes yaw. key-v/key-b will spin the blue segment clockwise
    4.11 -   and counterclockwise, and only affect roll."
    4.12 +   You should see two floating bars, and a display of pitch, yaw, and
    4.13 +   roll. The white dot measures pitch (spin around the long axis), the
    4.14 +   green dot measures yaw (in this case, rotation around a circle
    4.15 +   perpendicular to your line of view), and the red dot measures
    4.16 +   roll (rotation around a circle perlendicular to the the other two
    4.17 +   circles).
    4.18 +
    4.19 +   Keys:
    4.20 +     r : rotate along long axis
    4.21 +     t : opposite direction of rotation as <r>
    4.22 +     
    4.23 +     f : rotate in field of view
    4.24 +     g : opposite direction of rotation as <f>
    4.25 +
    4.26 +     v : rotate in final direction
    4.27 +     b : opposite direction of rotation as <v>"
    4.28 +
    4.29    ([] (test-proprioception false))
    4.30    ([record?]
    4.31       (let [hand    (box 0.2 1 0.2 :position (Vector3f. 0 0 0)
     5.1 --- a/org/sense.org	Thu Mar 01 06:24:17 2012 -0700
     5.2 +++ b/org/sense.org	Tue May 08 08:22:19 2012 -0500
     5.3 @@ -376,7 +376,8 @@
     5.4    (fn [#^Node creature]
     5.5      (if-let [sense-node (.getChild creature parent-name)]
     5.6        (seq (.getChildren sense-node))
     5.7 -      (do (println-repl "could not find" parent-name "node") []))))
     5.8 +      (do ;;(println-repl "could not find" parent-name "node") 
     5.9 +          []))))
    5.10  
    5.11  (defn closest-node
    5.12    "Return the physical node in creature which is closest to the given
     6.1 --- a/org/test.org	Thu Mar 01 06:24:17 2012 -0700
     6.2 +++ b/org/test.org	Tue May 08 08:22:19 2012 -0500
     6.3 @@ -11,9 +11,18 @@
     6.4  #+begin_src clojure 
     6.5  (ns cortex.test
     6.6    (:use cortex.util)
     6.7 -  (:require [cortex.test touch vision body hearing])
     6.8 +  (:require [cortex.test
     6.9 +             body
    6.10 +             vision
    6.11 +             hearing
    6.12 +             touch
    6.13 +             proprioception
    6.14 +             movement
    6.15 +
    6.16 +             ])
    6.17    (:import com.jme3.app.state.AppState
    6.18 -	   com.jme3.system.AppSettings))
    6.19 +	   com.jme3.system.AppSettings)
    6.20 +  (:import (com.jme3.math Triangle Vector3f Vector2f Ray Matrix4f)))
    6.21  
    6.22  (defn run-world
    6.23    "run the simulation and wait until it closes properly."
    6.24 @@ -44,21 +53,34 @@
    6.25    "print the docstring for the test, then run the simulation which it
    6.26    yields, waiting until it is terminated."
    6.27    [test-fn-var]
    6.28 +  (println-repl (:doc (meta test-fn-var)))
    6.29    (println-repl "\n ****************\n")
    6.30 -  (println-repl (:doc (meta test-fn-var)))
    6.31    (run-world ((deref test-fn-var))))
    6.32  
    6.33  (def test-suite
    6.34    "The full test suite for all sensors/effectors."
    6.35 -  [#'cortex.test.touch/test-skin
    6.36 -   #'cortex.test.vision/test-two-eyes
    6.37 -   #'cortex.test.hearing/test-advanced-hearing
    6.38 -   #'cortex.test.body/test-proprioception
    6.39 -   #'cortex.test.body/test-motor-control])
    6.40 +  [#'cortex.test.body/test-worm
    6.41  
    6.42 +   #'cortex.test.vision/test-pipeline
    6.43 +   #'cortex.test.vision/test-worm-vision
    6.44 +
    6.45 +   #'cortex.test.hearing/test-java-hearing
    6.46 +   #'cortex.test.hearing/test-worm-hearing
    6.47 +   
    6.48 +   #'cortex.test.touch/test-basic-touch
    6.49 +   #'cortex.test.touch/test-worm-touch
    6.50 +
    6.51 +   #'cortex.test.proprioception/test-proprioception
    6.52 +
    6.53 +   #'cortex.test.movement/test-worm-movement
    6.54 +   ])
    6.55 +   
    6.56 +   
    6.57 +   
    6.58  (defn run-suite
    6.59    "Run the entire test-suite."
    6.60    []
    6.61 +  (println-repl "\n ****************\n")
    6.62    (dorun (map run-test test-suite)))
    6.63  
    6.64  #+end_src
     7.1 --- a/org/touch.org	Thu Mar 01 06:24:17 2012 -0700
     7.2 +++ b/org/touch.org	Tue May 08 08:22:19 2012 -0500
     7.3 @@ -531,6 +531,14 @@
     7.4  (in-ns 'cortex.test.touch)
     7.5  
     7.6  (defn test-basic-touch
     7.7 +  "Testing touch:
     7.8 +   You should see a cube fall onto a table.  There is a cross-shaped
     7.9 +   display which reports the cube's sensation of touch. This display
    7.10 +   should change when the cube hits the table, and whenever you hit
    7.11 +   the cube with balls.
    7.12 +
    7.13 +   Keys:
    7.14 +     <space> : fire ball"
    7.15    ([] (test-basic-touch false))
    7.16    ([record?]
    7.17       (let [the-cube (doto (touch-cube) (body!))
    7.18 @@ -632,6 +640,13 @@
    7.19  (in-ns 'cortex.test.touch)
    7.20  
    7.21  (defn test-worm-touch 
    7.22 +  "Testing touch:
    7.23 +   You will see the worm fall onto a table.  There is a display which
    7.24 +   reports the worm's sense of touch. It should change when the worm
    7.25 +   hits the table and when you hit it with balls.
    7.26 +
    7.27 +   Keys:
    7.28 +     <space> : fire ball"
    7.29    ([] (test-worm-touch false))
    7.30    ([record?]
    7.31       (let [the-worm (doto (worm) (body!))
     8.1 --- a/org/vision.org	Thu Mar 01 06:24:17 2012 -0700
     8.2 +++ b/org/vision.org	Tue May 08 08:22:19 2012 -0500
     8.3 @@ -537,7 +537,7 @@
     8.4  (in-ns 'cortex.test.vision)
     8.5  
     8.6  (defn change-color [obj color]
     8.7 -  (println-repl obj)
     8.8 +  ;;(println-repl obj)
     8.9    (if obj
    8.10      (.setColor  (.getMaterial obj) "Color" color)))
    8.11  
    8.12 @@ -546,6 +546,18 @@
    8.13           (fire-cannon-ball)))
    8.14  
    8.15  (defn test-worm-vision 
    8.16 +  "Testing vision:
    8.17 +   You should see the worm suspended in mid-air, looking down at a
    8.18 +   table. There are four small displays, one each for red, green blue,
    8.19 +   and gray channels. You can fire balls of various colors, and the
    8.20 +   four channels should react accordingly.
    8.21 +
    8.22 +   Keys:
    8.23 +     r  : fire red-ball
    8.24 +     b  : fire blue-ball
    8.25 +     g  : fire green-ball
    8.26 +     <space> : fire white ball"
    8.27 +   
    8.28    ([] (test-worm-vision false))
    8.29    ([record?] 
    8.30       (let [the-worm (doto (worm)(body!))