# HG changeset patch # User Robert McIntyre # Date 1328374837 25200 # Node ID 22548d48cc85c81f2668ebbe135e815463bd538c # Parent 6142e85f58252f777cac90a86d3abb59c552bf82 added debug for vision diff -r 6142e85f5825 -r 22548d48cc85 org/sense.org --- a/org/sense.org Sat Feb 04 09:42:19 2012 -0700 +++ b/org/sense.org Sat Feb 04 10:00:37 2012 -0700 @@ -229,13 +229,20 @@ (range (count data))))) (dorun (map - (fn [display gen data] - (display (gen data))) - @windows sense-display-kernel data))))) + (fn [display datum] + (display (sense-display-kernel datum))) + @windows data))))) - +(defn gray + "Create a gray RGB pixel with R, G, and B set to 'num" + [num] + (+ num + (bit-shift-left num 8) + (bit-shift-left num 16))) +#+end_src -#+end_src +#+results: sense +: #'cortex.sense/gray * COMMENT generate source diff -r 6142e85f5825 -r 22548d48cc85 org/test-creature.org --- a/org/test-creature.org Sat Feb 04 09:42:19 2012 -0700 +++ b/org/test-creature.org Sat Feb 04 10:00:37 2012 -0700 @@ -109,20 +109,6 @@ ;; higher level --- sense/effector ;; these are the functions that provide world i/o, chinese-room style - -(defn debug-vision-window - "creates function that offers a debug view of sensor data" - [] - (let [vi (view-image)] - (fn - [[coords sensor-data]] - (let [image (points->image coords)] - (dorun - (for [i (range (count coords))] - (.setRGB image ((coords i) 0) ((coords i) 1) - (sensor-data i)))) - (vi image))))) - (defn debug-hearing-window "view audio data" [height] @@ -135,7 +121,7 @@ (dorun (for [y (range height)] (let [raw-sensor (sensor-data x)] - (.setRGB image x y (gray-scale raw-sensor))))))) + (.setRGB image x y (gray raw-sensor))))))) (vi image))))) @@ -150,9 +136,9 @@ (load-blender-model thing) (body!)) touch (touch! creature) - touch-view (view-touch) - vision-data (vision! creature) - vision-debug (map (fn [_] (debug-vision-window)) vision-data) + touch-display (view-touch) + vision (vision! creature) + vision-display (view-vision) me (sphere 0.5 :color ColorRGBA/Blue :physical? false) hearing-senses (hearing! creature) hearing-windows (map (fn [_] (debug-hearing-window 50)) @@ -222,12 +208,11 @@ (prop-debug (prop)) - (touch-view (map #(% (.getRootNode world)) touch)) + (touch-display (map #(% (.getRootNode world)) touch)) + + (vision-display (map #(% world) vision)) (dorun - (map #(%1 (%2 world)) - vision-debug vision-data)) - (dorun (map #(%1 (%2 world)) hearing-windows hearing-senses)) diff -r 6142e85f5825 -r 22548d48cc85 org/touch.org --- a/org/touch.org Sat Feb 04 09:42:19 2012 -0700 +++ b/org/touch.org Sat Feb 04 10:00:37 2012 -0700 @@ -300,15 +300,10 @@ (filter #(isa? (class %) Geometry) (node-seq creature))))) -(defn gray - "Create a gray RGB pixel with R, G, and B set to 'num" - [num] - (+ num - (bit-shift-left num 8) - (bit-shift-left num 16))) - -(defvar - view-touch +(defn view-touch + "Creates a function which accepts touch sensor-data and displays it + to the screen." + [] (view-sense (fn [[coords sensor-data]] @@ -317,9 +312,7 @@ (for [i (range (count coords))] (.setRGB image ((coords i) 0) ((coords i) 1) (gray (sensor-data i))))) - image))) - "Creates a function which accepts touch sensor-data and displays it - as BufferedImages in JFrames.") + image)))) #+end_src diff -r 6142e85f5825 -r 22548d48cc85 org/vision.org --- a/org/vision.org Sat Feb 04 09:42:19 2012 -0700 +++ b/org/vision.org Sat Feb 04 10:00:37 2012 -0700 @@ -237,6 +237,20 @@ (for [eye (eyes creature)] (vision-fn creature eye)))) +(defvar + view-vision + (view-sense + (fn + [[coords sensor-data]] + (let [image (points->image coords)] + (dorun + (for [i (range (count coords))] + (.setRGB image ((coords i) 0) ((coords i) 1) + (sensor-data i)))) + image))) + "Creates a function which accepts visual sensor-data and displays it + to the screen.") + #+end_src