Mercurial > cortex
changeset 189:facc2ef3fe5c
added hearing debug view.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 04 Feb 2012 10:13:15 -0700 |
parents | 22548d48cc85 |
children | 2902aca33c6e |
files | org/hearing.org org/test-creature.org org/touch.org org/vision.org |
diffstat | 4 files changed, 44 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/org/hearing.org Sat Feb 04 10:00:37 2012 -0700 1.2 +++ b/org/hearing.org Sat Feb 04 10:13:15 2012 -0700 1.3 @@ -760,6 +760,7 @@ 1.4 (:use (cortex world util sense)) 1.5 (:use clojure.contrib.def) 1.6 (:import java.nio.ByteBuffer) 1.7 + (:import java.awt.image.BufferedImage) 1.8 (:import org.tritonus.share.sampled.FloatSampleTools) 1.9 (:import (com.aurellem.capture.audio 1.10 SoundProcessor AudioSendRenderer)) 1.11 @@ -857,8 +858,28 @@ 1.12 (for [ear (ears creature)] 1.13 (hearing-fn creature ear))) 1.14 1.15 +(defn view-hearing 1.16 + "Creates a function which accepts a list of auditory data and 1.17 + display each element of the list to the screen as an image." 1.18 + [] 1.19 + (view-sense 1.20 + (fn [[coords sensor-data]] 1.21 + (let [height 50 1.22 + image (BufferedImage. (count coords) height 1.23 + BufferedImage/TYPE_INT_RGB)] 1.24 + (dorun 1.25 + (for [x (range (count coords))] 1.26 + (dorun 1.27 + (for [y (range height)] 1.28 + (let [raw-sensor (sensor-data x)] 1.29 + (.setRGB image x y (gray raw-sensor))))))) 1.30 + image)))) 1.31 + 1.32 #+end_src 1.33 1.34 +#+results: ears 1.35 +: #'cortex.hearing/hearing! 1.36 + 1.37 * Example 1.38 1.39 #+name: test-hearing
2.1 --- a/org/test-creature.org Sat Feb 04 10:00:37 2012 -0700 2.2 +++ b/org/test-creature.org Sat Feb 04 10:13:15 2012 -0700 2.3 @@ -132,24 +132,28 @@ 2.4 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green) 2.5 z-axis 2.6 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue) 2.7 - creature (doto 2.8 - (load-blender-model thing) 2.9 - (body!)) 2.10 + 2.11 + creature (doto (load-blender-model thing) (body!)) 2.12 + 2.13 touch (touch! creature) 2.14 touch-display (view-touch) 2.15 + 2.16 vision (vision! creature) 2.17 vision-display (view-vision) 2.18 - me (sphere 0.5 :color ColorRGBA/Blue :physical? false) 2.19 - hearing-senses (hearing! creature) 2.20 - hearing-windows (map (fn [_] (debug-hearing-window 50)) 2.21 - hearing-senses) 2.22 - bell (AudioNode. (asset-manager) 2.23 - "Sounds/pure.wav" false) 2.24 + 2.25 + hearing (hearing! creature) 2.26 + hearing-display (view-hearing) 2.27 + 2.28 prop (proprioception! creature) 2.29 prop-debug (proprioception-debug-window) 2.30 2.31 muscle-fns (movement! creature) 2.32 - ;; dream 2.33 + 2.34 + 2.35 + me (sphere 0.5 :color ColorRGBA/Blue :physical? false) 2.36 + bell (AudioNode. (asset-manager) 2.37 + "Sounds/pure.wav" false) 2.38 + 2.39 fix-display (runonce 2.40 (fn [world] (add-camera! world (.getCamera world) no-op))) 2.41 ] 2.42 @@ -211,10 +215,8 @@ 2.43 (touch-display (map #(% (.getRootNode world)) touch)) 2.44 2.45 (vision-display (map #(% world) vision)) 2.46 - 2.47 - (dorun 2.48 - (map #(%1 (%2 world)) hearing-windows hearing-senses)) 2.49 - 2.50 + 2.51 + (hearing-display (map #(% world) hearing)) 2.52 2.53 ;;(println-repl (vision-data)) 2.54 (.setLocalTranslation me (.getLocation (.getCamera world)))
3.1 --- a/org/touch.org Sat Feb 04 10:00:37 2012 -0700 3.2 +++ b/org/touch.org Sat Feb 04 10:13:15 2012 -0700 3.3 @@ -301,8 +301,8 @@ 3.4 (node-seq creature))))) 3.5 3.6 (defn view-touch 3.7 - "Creates a function which accepts touch sensor-data and displays it 3.8 - to the screen." 3.9 + "Creates a function which accepts a list of touch sensor-data and 3.10 + displays each element to the screen." 3.11 [] 3.12 (view-sense 3.13 (fn
4.1 --- a/org/vision.org Sat Feb 04 10:00:37 2012 -0700 4.2 +++ b/org/vision.org Sat Feb 04 10:13:15 2012 -0700 4.3 @@ -237,8 +237,10 @@ 4.4 (for [eye (eyes creature)] 4.5 (vision-fn creature eye)))) 4.6 4.7 -(defvar 4.8 - view-vision 4.9 +(defn view-vision 4.10 + "Creates a function which accepts a list of visual sensor-data and 4.11 + displays each element of the list to the screen." 4.12 + [] 4.13 (view-sense 4.14 (fn 4.15 [[coords sensor-data]] 4.16 @@ -247,9 +249,7 @@ 4.17 (for [i (range (count coords))] 4.18 (.setRGB image ((coords i) 0) ((coords i) 1) 4.19 (sensor-data i)))) 4.20 - image))) 4.21 - "Creates a function which accepts visual sensor-data and displays it 4.22 - to the screen.") 4.23 + image)))) 4.24 4.25 #+end_src 4.26