Mercurial > cortex
comparison org/sense.org @ 306:7e7f8d6d9ec5
massive spellchecking
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 18 Feb 2012 10:59:41 -0700 |
parents | 23aadf376e9d |
children | 5d448182c807 |
comparison
equal
deleted
inserted
replaced
305:19c43ec6958d | 306:7e7f8d6d9ec5 |
---|---|
5 #+keywords: simulation, jMonkeyEngine3, clojure, simulated senses | 5 #+keywords: simulation, jMonkeyEngine3, clojure, simulated senses |
6 #+SETUPFILE: ../../aurellem/org/setup.org | 6 #+SETUPFILE: ../../aurellem/org/setup.org |
7 #+INCLUDE: ../../aurellem/org/level-0.org | 7 #+INCLUDE: ../../aurellem/org/level-0.org |
8 | 8 |
9 * Blender Utilities | 9 * Blender Utilities |
10 In blender, any object can be assigned an arbitray number of key-value | 10 In blender, any object can be assigned an arbitrary number of key-value |
11 pairs which are called "Custom Properties". These are accessable in | 11 pairs which are called "Custom Properties". These are accessible in |
12 jMonkyeEngine when blender files are imported with the | 12 jMonkeyEngine when blender files are imported with the |
13 =BlenderLoader=. =meta-data= extracts these properties. | 13 =BlenderLoader=. =meta-data= extracts these properties. |
14 | 14 |
15 #+name: blender-1 | 15 #+name: blender-1 |
16 #+begin_src clojure | 16 #+begin_src clojure |
17 (defn meta-data | 17 (defn meta-data |
53 the brain. Intersect the spinal nerves with a guillotining plane and | 53 the brain. Intersect the spinal nerves with a guillotining plane and |
54 you will see all of the sensory data of the skin revealed in a roughly | 54 you will see all of the sensory data of the skin revealed in a roughly |
55 circular two-dimensional image which is the cross section of the | 55 circular two-dimensional image which is the cross section of the |
56 spinal cord. Points on this image that are close together in this | 56 spinal cord. Points on this image that are close together in this |
57 circle represent touch sensors that are /probably/ close together on | 57 circle represent touch sensors that are /probably/ close together on |
58 the skin, although there is of course some cutting and rerangement | 58 the skin, although there is of course some cutting and rearrangement |
59 that has to be done to transfer the complicated surface of the skin | 59 that has to be done to transfer the complicated surface of the skin |
60 onto a two dimensional image. | 60 onto a two dimensional image. |
61 | 61 |
62 Most human senses consist of many discrete sensors of various | 62 Most human senses consist of many discrete sensors of various |
63 properties distributed along a surface at various densities. For | 63 properties distributed along a surface at various densities. For |
82 | 82 |
83 To make a sense, interpret the UV-image as describing the distribution | 83 To make a sense, interpret the UV-image as describing the distribution |
84 of that senses sensors. To get different types of sensors, you can | 84 of that senses sensors. To get different types of sensors, you can |
85 either use a different color for each type of sensor, or use multiple | 85 either use a different color for each type of sensor, or use multiple |
86 UV-maps, each labeled with that sensor type. I generally use a white | 86 UV-maps, each labeled with that sensor type. I generally use a white |
87 pixel to mean the presense of a sensor and a black pixel to mean the | 87 pixel to mean the presence of a sensor and a black pixel to mean the |
88 absense of a sensor, and use one UV-map for each sensor-type within a | 88 absence of a sensor, and use one UV-map for each sensor-type within a |
89 given sense. The paths to the images are not stored as the actual | 89 given sense. The paths to the images are not stored as the actual |
90 UV-map of the blender object but are instead referenced in the | 90 UV-map of the blender object but are instead referenced in the |
91 meta-data of the node. | 91 meta-data of the node. |
92 | 92 |
93 #+CAPTION: The UV-map for an enlongated icososphere. The white dots each represent a touch sensor. They are dense in the regions that describe the tip of the finger, and less dense along the dorsal side of the finger opposite the tip. | 93 #+CAPTION: The UV-map for an elongated icososphere. The white dots each represent a touch sensor. They are dense in the regions that describe the tip of the finger, and less dense along the dorsal side of the finger opposite the tip. |
94 #+ATTR_HTML: width="300" | 94 #+ATTR_HTML: width="300" |
95 [[../images/finger-UV.png]] | 95 [[../images/finger-UV.png]] |
96 | 96 |
97 #+CAPTION: Ventral side of the UV-mapped finger. Notice the density of touch sensors at the tip. | 97 #+CAPTION: Ventral side of the UV-mapped finger. Notice the density of touch sensors at the tip. |
98 #+ATTR_HTML: width="300" | 98 #+ATTR_HTML: width="300" |
154 | 154 |
155 ** Topology | 155 ** Topology |
156 | 156 |
157 Information from the senses is transmitted to the brain via bundles of | 157 Information from the senses is transmitted to the brain via bundles of |
158 axons, whether it be the optic nerve or the spinal cord. While these | 158 axons, whether it be the optic nerve or the spinal cord. While these |
159 bundles more or less perserve the overall topology of a sense's | 159 bundles more or less preserve the overall topology of a sense's |
160 two-dimensional surface, they do not perserve the percise euclidean | 160 two-dimensional surface, they do not preserve the precise euclidean |
161 distances between every sensor. =collapse= is here to smoosh the | 161 distances between every sensor. =collapse= is here to smoosh the |
162 sensors described by a UV-map into a contigous region that still | 162 sensors described by a UV-map into a contiguous region that still |
163 perserves the topology of the original sense. | 163 preserves the topology of the original sense. |
164 | 164 |
165 #+name: topology-2 | 165 #+name: topology-2 |
166 #+begin_src clojure | 166 #+begin_src clojure |
167 (in-ns 'cortex.sense) | 167 (in-ns 'cortex.sense) |
168 | 168 |
178 (range (- center num-below) | 178 (range (- center num-below) |
179 (+ center num-above)))) | 179 (+ center num-above)))) |
180 | 180 |
181 (defn collapse | 181 (defn collapse |
182 "Take a sequence of pairs of integers and collapse them into a | 182 "Take a sequence of pairs of integers and collapse them into a |
183 contigous bitmap with no \"holes\" or negative entries, as close to | 183 contiguous bitmap with no \"holes\" or negative entries, as close to |
184 the origin [0 0] as the shape permits. The order of the points is | 184 the origin [0 0] as the shape permits. The order of the points is |
185 preserved. | 185 preserved. |
186 | 186 |
187 eg. | 187 eg. |
188 (collapse [[-5 5] [5 5] --> [[0 1] [1 1] | 188 (collapse [[-5 5] [5 5] --> [[0 1] [1 1] |
222 min-y (apply min (map second squeezed))] | 222 min-y (apply min (map second squeezed))] |
223 (map (fn [[x y]] | 223 (map (fn [[x y]] |
224 [(- x min-x) | 224 [(- x min-x) |
225 (- y min-y)]) | 225 (- y min-y)]) |
226 squeezed)) | 226 squeezed)) |
227 point-correspondance | 227 point-correspondence |
228 (zipmap (sort points) (sort relocated)) | 228 (zipmap (sort points) (sort relocated)) |
229 | 229 |
230 original-order | 230 original-order |
231 (vec (map point-correspondance points))] | 231 (vec (map point-correspondence points))] |
232 original-order))) | 232 original-order))) |
233 #+end_src | 233 #+end_src |
234 * Viewing Sense Data | 234 * Viewing Sense Data |
235 | 235 |
236 It's vital to /see/ the sense data to make sure that everything is | 236 It's vital to /see/ the sense data to make sure that everything is |
243 #+name: view-senses | 243 #+name: view-senses |
244 #+begin_src clojure | 244 #+begin_src clojure |
245 (in-ns 'cortex.sense) | 245 (in-ns 'cortex.sense) |
246 | 246 |
247 (defn view-image | 247 (defn view-image |
248 "Initailizes a JPanel on which you may draw a BufferedImage. | 248 "Initializes a JPanel on which you may draw a BufferedImage. |
249 Returns a function that accepts a BufferedImage and draws it to the | 249 Returns a function that accepts a BufferedImage and draws it to the |
250 JPanel. If given a directory it will save the images as png files | 250 JPanel. If given a directory it will save the images as png files |
251 starting at 0000000.png and incrementing from there." | 251 starting at 0000000.png and incrementing from there." |
252 ([#^File save] | 252 ([#^File save] |
253 (let [idx (atom -1) | 253 (let [idx (atom -1) |
307 (display (sense-display-kernel datum))) | 307 (display (sense-display-kernel datum))) |
308 @windows data)))))) | 308 @windows data)))))) |
309 | 309 |
310 | 310 |
311 (defn points->image | 311 (defn points->image |
312 "Take a collection of points and visuliaze it as a BufferedImage." | 312 "Take a collection of points and visualize it as a BufferedImage." |
313 [points] | 313 [points] |
314 (if (empty? points) | 314 (if (empty? points) |
315 (BufferedImage. 1 1 BufferedImage/TYPE_BYTE_BINARY) | 315 (BufferedImage. 1 1 BufferedImage/TYPE_BYTE_BINARY) |
316 (let [xs (vec (map first points)) | 316 (let [xs (vec (map first points)) |
317 ys (vec (map second points)) | 317 ys (vec (map second points)) |
346 and follow a particular object around. For these: | 346 and follow a particular object around. For these: |
347 | 347 |
348 - Create a single top-level empty node whose name is the name of the sense | 348 - Create a single top-level empty node whose name is the name of the sense |
349 - Add empty nodes which each contain meta-data relevant | 349 - Add empty nodes which each contain meta-data relevant |
350 to the sense, including a UV-map describing the number/distribution | 350 to the sense, including a UV-map describing the number/distribution |
351 of sensors if applicipable. | 351 of sensors if applicable. |
352 - Make each empty-node the child of the top-level | 352 - Make each empty-node the child of the top-level |
353 node. =sense-nodes= below generates functions to find these children. | 353 node. =sense-nodes= below generates functions to find these children. |
354 | 354 |
355 For touch, store the path to the UV-map which describes touch-sensors in the | 355 For touch, store the path to the UV-map which describes touch-sensors in the |
356 meta-data of the object to which that map applies. | 356 meta-data of the object to which that map applies. |
536 #+name: sense-header | 536 #+name: sense-header |
537 #+begin_src clojure | 537 #+begin_src clojure |
538 (ns cortex.sense | 538 (ns cortex.sense |
539 "Here are functions useful in the construction of two or more | 539 "Here are functions useful in the construction of two or more |
540 sensors/effectors." | 540 sensors/effectors." |
541 {:author "Robert McInytre"} | 541 {:author "Robert McIntyre"} |
542 (:use (cortex world util)) | 542 (:use (cortex world util)) |
543 (:import ij.process.ImageProcessor) | 543 (:import ij.process.ImageProcessor) |
544 (:import jme3tools.converters.ImageToAwt) | 544 (:import jme3tools.converters.ImageToAwt) |
545 (:import java.awt.image.BufferedImage) | 545 (:import java.awt.image.BufferedImage) |
546 (:import com.jme3.collision.CollisionResults) | 546 (:import com.jme3.collision.CollisionResults) |