# HG changeset patch # User Robert McIntyre # Date 1328375595 25200 # Node ID facc2ef3fe5caf4506f942a7cbaa4928978f0106 # Parent 22548d48cc85c81f2668ebbe135e815463bd538c added hearing debug view. diff -r 22548d48cc85 -r facc2ef3fe5c org/hearing.org --- a/org/hearing.org Sat Feb 04 10:00:37 2012 -0700 +++ b/org/hearing.org Sat Feb 04 10:13:15 2012 -0700 @@ -760,6 +760,7 @@ (:use (cortex world util sense)) (:use clojure.contrib.def) (:import java.nio.ByteBuffer) + (:import java.awt.image.BufferedImage) (:import org.tritonus.share.sampled.FloatSampleTools) (:import (com.aurellem.capture.audio SoundProcessor AudioSendRenderer)) @@ -857,8 +858,28 @@ (for [ear (ears creature)] (hearing-fn creature ear))) +(defn view-hearing + "Creates a function which accepts a list of auditory data and + display each element of the list to the screen as an image." + [] + (view-sense + (fn [[coords sensor-data]] + (let [height 50 + image (BufferedImage. (count coords) height + BufferedImage/TYPE_INT_RGB)] + (dorun + (for [x (range (count coords))] + (dorun + (for [y (range height)] + (let [raw-sensor (sensor-data x)] + (.setRGB image x y (gray raw-sensor))))))) + image)))) + #+end_src +#+results: ears +: #'cortex.hearing/hearing! + * Example #+name: test-hearing diff -r 22548d48cc85 -r facc2ef3fe5c org/test-creature.org --- a/org/test-creature.org Sat Feb 04 10:00:37 2012 -0700 +++ b/org/test-creature.org Sat Feb 04 10:13:15 2012 -0700 @@ -132,24 +132,28 @@ (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green) z-axis (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue) - creature (doto - (load-blender-model thing) - (body!)) + + creature (doto (load-blender-model thing) (body!)) + touch (touch! creature) 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)) - hearing-senses) - bell (AudioNode. (asset-manager) - "Sounds/pure.wav" false) + + hearing (hearing! creature) + hearing-display (view-hearing) + prop (proprioception! creature) prop-debug (proprioception-debug-window) muscle-fns (movement! creature) - ;; dream + + + me (sphere 0.5 :color ColorRGBA/Blue :physical? false) + bell (AudioNode. (asset-manager) + "Sounds/pure.wav" false) + fix-display (runonce (fn [world] (add-camera! world (.getCamera world) no-op))) ] @@ -211,10 +215,8 @@ (touch-display (map #(% (.getRootNode world)) touch)) (vision-display (map #(% world) vision)) - - (dorun - (map #(%1 (%2 world)) hearing-windows hearing-senses)) - + + (hearing-display (map #(% world) hearing)) ;;(println-repl (vision-data)) (.setLocalTranslation me (.getLocation (.getCamera world))) diff -r 22548d48cc85 -r facc2ef3fe5c org/touch.org --- a/org/touch.org Sat Feb 04 10:00:37 2012 -0700 +++ b/org/touch.org Sat Feb 04 10:13:15 2012 -0700 @@ -301,8 +301,8 @@ (node-seq creature))))) (defn view-touch - "Creates a function which accepts touch sensor-data and displays it - to the screen." + "Creates a function which accepts a list of touch sensor-data and + displays each element to the screen." [] (view-sense (fn diff -r 22548d48cc85 -r facc2ef3fe5c org/vision.org --- a/org/vision.org Sat Feb 04 10:00:37 2012 -0700 +++ b/org/vision.org Sat Feb 04 10:13:15 2012 -0700 @@ -237,8 +237,10 @@ (for [eye (eyes creature)] (vision-fn creature eye)))) -(defvar - view-vision +(defn view-vision + "Creates a function which accepts a list of visual sensor-data and + displays each element of the list to the screen." + [] (view-sense (fn [[coords sensor-data]] @@ -247,9 +249,7 @@ (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.") + image)))) #+end_src