changeset 188:22548d48cc85

added debug for vision
author Robert McIntyre <rlm@mit.edu>
date Sat, 04 Feb 2012 10:00:37 -0700
parents 6142e85f5825
children facc2ef3fe5c
files org/sense.org org/test-creature.org org/touch.org org/vision.org
diffstat 4 files changed, 38 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/sense.org	Sat Feb 04 09:42:19 2012 -0700
     1.2 +++ b/org/sense.org	Sat Feb 04 10:00:37 2012 -0700
     1.3 @@ -229,13 +229,20 @@
     1.4                               (range (count data)))))
     1.5        (dorun
     1.6         (map
     1.7 -        (fn [display gen data]
     1.8 -          (display (gen data)))
     1.9 -        @windows sense-display-kernel data)))))
    1.10 +        (fn [display datum]
    1.11 +          (display (sense-display-kernel datum)))
    1.12 +        @windows data)))))
    1.13  
    1.14 -  
    1.15 +(defn gray
    1.16 +  "Create a gray RGB pixel with R, G, and B set to 'num"
    1.17 +  [num]
    1.18 +  (+ num
    1.19 +     (bit-shift-left num 8)
    1.20 +     (bit-shift-left num 16)))
    1.21 +#+end_src
    1.22  
    1.23 -#+end_src
    1.24 +#+results: sense
    1.25 +: #'cortex.sense/gray
    1.26  
    1.27  
    1.28  * COMMENT generate source
     2.1 --- a/org/test-creature.org	Sat Feb 04 09:42:19 2012 -0700
     2.2 +++ b/org/test-creature.org	Sat Feb 04 10:00:37 2012 -0700
     2.3 @@ -109,20 +109,6 @@
     2.4  ;; higher level --- sense/effector
     2.5  ;; these are the functions that provide world i/o, chinese-room style
     2.6  
     2.7 -
     2.8 -(defn debug-vision-window
     2.9 -  "creates function that offers a debug view of sensor data"
    2.10 -  []
    2.11 -  (let [vi (view-image)]
    2.12 -    (fn 
    2.13 -      [[coords sensor-data]]
    2.14 -      (let [image (points->image coords)]
    2.15 -        (dorun
    2.16 -         (for [i (range (count coords))]
    2.17 -           (.setRGB image ((coords i) 0) ((coords i) 1)
    2.18 -                   (sensor-data i))))
    2.19 -        (vi image)))))
    2.20 -
    2.21  (defn debug-hearing-window
    2.22    "view audio data"
    2.23    [height]
    2.24 @@ -135,7 +121,7 @@
    2.25             (dorun
    2.26              (for [y (range height)]
    2.27                (let [raw-sensor (sensor-data x)]
    2.28 -                (.setRGB image x y (gray-scale raw-sensor)))))))
    2.29 +                (.setRGB image x y (gray raw-sensor)))))))
    2.30  
    2.31          (vi image)))))
    2.32          
    2.33 @@ -150,9 +136,9 @@
    2.34                       (load-blender-model thing)
    2.35                     (body!))
    2.36          touch (touch! creature)
    2.37 -        touch-view (view-touch)
    2.38 -        vision-data (vision! creature)
    2.39 -        vision-debug (map (fn [_] (debug-vision-window)) vision-data)
    2.40 +        touch-display (view-touch)
    2.41 +        vision (vision! creature)
    2.42 +        vision-display (view-vision)
    2.43          me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
    2.44          hearing-senses (hearing! creature)
    2.45          hearing-windows (map (fn [_] (debug-hearing-window 50))
    2.46 @@ -222,12 +208,11 @@
    2.47            
    2.48            (prop-debug (prop))
    2.49            
    2.50 -          (touch-view (map #(% (.getRootNode world)) touch))
    2.51 +          (touch-display (map #(% (.getRootNode world)) touch))
    2.52 +
    2.53 +          (vision-display (map #(% world) vision))
    2.54            
    2.55            (dorun
    2.56 -           (map #(%1 (%2 world))
    2.57 -                vision-debug vision-data))
    2.58 -          (dorun
    2.59             (map #(%1 (%2 world)) hearing-windows hearing-senses))
    2.60            
    2.61            
     3.1 --- a/org/touch.org	Sat Feb 04 09:42:19 2012 -0700
     3.2 +++ b/org/touch.org	Sat Feb 04 10:00:37 2012 -0700
     3.3 @@ -300,15 +300,10 @@
     3.4          (filter #(isa? (class %) Geometry)
     3.5                  (node-seq creature)))))
     3.6  
     3.7 -(defn gray
     3.8 -  "Create a gray RGB pixel with R, G, and B set to 'num"
     3.9 -  [num]
    3.10 -  (+ num
    3.11 -     (bit-shift-left num 8)
    3.12 -     (bit-shift-left num 16)))
    3.13 -
    3.14 -(defvar
    3.15 -  view-touch 
    3.16 +(defn view-touch 
    3.17 +  "Creates a function which accepts touch sensor-data and displays it
    3.18 +   to the screen."
    3.19 +  []
    3.20    (view-sense
    3.21     (fn 
    3.22       [[coords sensor-data]]
    3.23 @@ -317,9 +312,7 @@
    3.24          (for [i (range (count coords))]
    3.25            (.setRGB image ((coords i) 0) ((coords i) 1)
    3.26                     (gray (sensor-data i)))))
    3.27 -       image)))
    3.28 -  "Creates a function which accepts touch sensor-data and displays it
    3.29 -   as BufferedImages in JFrames.")
    3.30 +       image))))
    3.31   
    3.32  
    3.33  #+end_src
     4.1 --- a/org/vision.org	Sat Feb 04 09:42:19 2012 -0700
     4.2 +++ b/org/vision.org	Sat Feb 04 10:00:37 2012 -0700
     4.3 @@ -237,6 +237,20 @@
     4.4     (for [eye (eyes creature)]
     4.5       (vision-fn creature eye))))
     4.6  
     4.7 +(defvar 
     4.8 +  view-vision
     4.9 +  (view-sense
    4.10 +   (fn 
    4.11 +     [[coords sensor-data]]
    4.12 +     (let [image (points->image coords)]
    4.13 +       (dorun
    4.14 +        (for [i (range (count coords))]
    4.15 +          (.setRGB image ((coords i) 0) ((coords i) 1)
    4.16 +                   (sensor-data i))))
    4.17 +       image)))
    4.18 +  "Creates a function which accepts visual sensor-data and displays it
    4.19 +   to the screen.")
    4.20 +
    4.21  #+end_src
    4.22  
    4.23