changeset 460:763d13f77e03

merge in laptop changes.
author Robert McIntyre <rlm@mit.edu>
date Thu, 27 Mar 2014 17:57:01 -0400
parents a86555b02916 (diff) 26c13c42481f (current diff)
children b345650a0baa
files java/build.xml java/src/com/aurellem/opencv/OpenCV.java org/ideas.org org/touch.org org/util.org
diffstat 7 files changed, 157 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/body.org	Thu Mar 27 17:56:25 2014 -0400
     1.2 +++ b/org/body.org	Thu Mar 27 17:57:01 2014 -0400
     1.3 @@ -179,6 +179,9 @@
     1.4        no-op)))
     1.5  #+end_src
     1.6  
     1.7 +#+results: test-2
     1.8 +: #'cortex.test.body/test-hand-2
     1.9 +
    1.10  #+begin_html
    1.11  <div class="figure">
    1.12  <center>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/org/depth-map.org	Thu Mar 27 17:57:01 2014 -0400
     2.3 @@ -0,0 +1,67 @@
     2.4 +
     2.5 +#+begin_src clojure
     2.6 +(ns cortex.depth-map
     2.7 +  "lol depth maps."
     2.8 +  {:author "Robert McIntyre"}
     2.9 +  (:use (cortex world util body sense vision touch))
    2.10 +  (:import (com.jme3.scene Geometry Node Mesh))
    2.11 +  (:import com.jme3.collision.CollisionResults)
    2.12 +  (:import com.jme3.scene.VertexBuffer$Type)
    2.13 +
    2.14 +  (:import (com.jme3.math Triangle Vector3f Vector2f Ray Matrix4f)))
    2.15 +
    2.16 +(cortex.import/mega-import-jme3)
    2.17 +
    2.18 +(defn convert-pixel-to-ray
    2.19 +  [camera ray x y]
    2.20 +  (let [pixel-arrow
    2.21 +        (.getWorldCoordinates
    2.22 +         camera
    2.23 +         (Vector2f. (float x) (float y))
    2.24 +         ;; this is the "z depth" and can be anything, since
    2.25 +         ;; we only care about direction
    2.26 +         (float 1))
    2.27 +        ;; now that we have the direction of a pixel, subtract
    2.28 +        ray (Ray.)]
    2.29 +    (set-ray ray Matrix4f/IDENTITY (.getLocation camera)
    2.30 +             pixel-arrow) ray))
    2.31 +
    2.32 +(defn generate-depth-map-points
    2.33 +  "Generate a data structure representating the depth of the first
    2.34 +  object to collide with a ray from the camera's current position."
    2.35 +  [world camera]
    2.36 +  (let [width (.getWidth camera)
    2.37 +        height (.getHeight camera)
    2.38 +        pixels (for [x (range width) y (range height)]
    2.39 +                 [x y])
    2.40 +        temp-ray (Ray.)
    2.41 +        depths
    2.42 +        (for [[x y] pixels]
    2.43 +          (let [ray (convert-pixel-to-ray camera temp-ray x y)
    2.44 +                results (CollisionResults.)]
    2.45 +            (.collideWith world ray results)
    2.46 +            (if-let [closest (.getClosestCollision results)]
    2.47 +              (.hashCode (.getGeometry closest)) 0)))]
    2.48 +
    2.49 +    (zipmap pixels depths)))
    2.50 +
    2.51 +(defn test-world []
    2.52 +  (nodify [(floor*) (brick-wall*)]))
    2.53 +
    2.54 +(import com.aurellem.capture.RatchetTimer)
    2.55 +
    2.56 +(defn depth-map-test []
    2.57 +  (let [the-world (test-world)]
    2.58 +    (world
    2.59 +     the-world
    2.60 +     ;;controls
    2.61 +     standard-debug-controls
    2.62 +     ;;init
    2.63 +     (fn [world]
    2.64 +       (let [timer (RatchetTimer. 60)]
    2.65 +         (.setTimer world timer)
    2.66 +         (display-dilated-time world timer)))
    2.67 +     ;; update
    2.68 +     no-op)))
    2.69 +
    2.70 +#+end_src
    2.71 \ No newline at end of file
     3.1 --- a/org/gabor.org	Thu Mar 27 17:56:25 2014 -0400
     3.2 +++ b/org/gabor.org	Thu Mar 27 17:57:01 2014 -0400
     3.3 @@ -177,68 +177,6 @@
     3.4    (println (.dump kernel)))
     3.5                             
     3.6  
     3.7 -(def brick-length 0.48)
     3.8 -(def brick-width 0.24)
     3.9 -(def brick-height 0.12)
    3.10 -(def gravity (Vector3f. 0 -9.81 0))
    3.11 -
    3.12 -
    3.13 -(defn brick* [position]
    3.14 -  (println "get brick.")
    3.15 -  (doto (box brick-length brick-height brick-width
    3.16 -	     :position position :name "brick"
    3.17 -	     :material "Common/MatDefs/Misc/Unshaded.j3md"
    3.18 -	     :texture "Textures/Terrain/BrickWall/BrickWall.jpg"
    3.19 -	     :mass 34)
    3.20 -    (->
    3.21 -     (.getMesh)
    3.22 -     (.scaleTextureCoordinates (Vector2f. 1 0.5)))
    3.23 -    (.setShadowMode RenderQueue$ShadowMode/CastAndReceive)
    3.24 -    )
    3.25 -  )
    3.26 -
    3.27 -
    3.28 -(defn floor*
    3.29 -  "make a sturdy, unmovable physical floor"
    3.30 -  []
    3.31 -  (box 10 0.1 5 :name "floor" :mass 0 
    3.32 -       :color ColorRGBA/Gray :position (Vector3f. 0 0 0)))
    3.33 -
    3.34 -(defn floor* []
    3.35 -  (doto (box 10 0.1 5 :name "floor" ;10 0.1 5 ; 240 0.1 240
    3.36 -	     :material "Common/MatDefs/Misc/Unshaded.j3md"
    3.37 -	     :texture "Textures/BronzeCopper030.jpg"
    3.38 -	     :position (Vector3f. 0 0 0 )
    3.39 -	     :mass 0)
    3.40 -    (->
    3.41 -     (.getMesh)
    3.42 -     (.scaleTextureCoordinates (Vector2f. 3 6)));64 64
    3.43 -    (->
    3.44 -     (.getMaterial)
    3.45 -     (.getTextureParam "ColorMap")
    3.46 -     (.getTextureValue)
    3.47 -     (.setWrap Texture$WrapMode/Repeat))
    3.48 -    (.setShadowMode RenderQueue$ShadowMode/Receive)
    3.49 -  ))
    3.50 -
    3.51 -
    3.52 -(defn brick-wall* []
    3.53 -  (let [node (Node. "brick-wall")]
    3.54 -    (dorun
    3.55 -     (map
    3.56 -      (comp  #(.attachChild node %) brick*)
    3.57 -       (for [y (range 10)
    3.58 -	     x (range 4)
    3.59 -	     z (range 1)]
    3.60 -       	    (Vector3f.
    3.61 -       	     (+ (* 2 x brick-length)
    3.62 -		(if (even? (+ y z)) 
    3.63 -		  (/ brick-length 4) (/ brick-length -4)))
    3.64 -       	     (+ (* brick-height (inc (* 2 y))))
    3.65 -	     (* 2 z brick-width) ))))
    3.66 -    (.setShadowMode node RenderQueue$ShadowMode/CastAndReceive)
    3.67 -    node))
    3.68 -
    3.69  (import com.aurellem.capture.Capture)
    3.70  
    3.71  (import java.io.File)
     4.1 --- a/org/ideas.org	Thu Mar 27 17:56:25 2014 -0400
     4.2 +++ b/org/ideas.org	Thu Mar 27 17:57:01 2014 -0400
     4.3 @@ -2,6 +2,11 @@
     4.4  
     4.5  * Brainstorming different sensors and effectors.
     4.6  
     4.7 +** toys 
     4.8 +Make toys in the world with "docking points," which would attach
     4.9 +together in physically stable ways. Could make analogs to legos,
    4.10 +tinker toys, and lincoln logs. 
    4.11 +
    4.12  Every sense that we have should have an effector that changes what
    4.13  that sense (or others who have that sense) experiences.
    4.14  
     5.1 --- a/org/integration.org	Thu Mar 27 17:56:25 2014 -0400
     5.2 +++ b/org/integration.org	Thu Mar 27 17:57:01 2014 -0400
     5.3 @@ -225,6 +225,18 @@
     5.4  (import com.aurellem.capture.Capture)
     5.5  
     5.6  (defn test-integration 
     5.7 +  "Testing Everything!
     5.8 +
     5.9 +   You will see an articulated hand fall onto the table. It has all
    5.10 +   senses including:
    5.11 +     - Vision, 4 channels
    5.12 +     - Hearing
    5.13 +     - Touch
    5.14 +     - Proprioceptoin
    5.15 +     - Muscle Tension
    5.16 +
    5.17 +    Keys:
    5.18 +    <space> : fire ball"
    5.19    ([] (test-integration false))
    5.20    ([record?]
    5.21    (let [me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
     6.1 --- a/org/touch.org	Thu Mar 27 17:56:25 2014 -0400
     6.2 +++ b/org/touch.org	Thu Mar 27 17:57:01 2014 -0400
     6.3 @@ -388,7 +388,6 @@
     6.4    (.normalizeLocal (.getDirection ray)))
     6.5  
     6.6  (import com.jme3.math.FastMath)
     6.7 -
     6.8   
     6.9  (defn touch-kernel
    6.10    "Constructs a function which will return tactile sensory data from
     7.1 --- a/org/util.org	Thu Mar 27 17:56:25 2014 -0400
     7.2 +++ b/org/util.org	Thu Mar 27 17:57:01 2014 -0400
     7.3 @@ -59,6 +59,7 @@
     7.4    "Import ALL the jme classes. For REPL use."
     7.5    []
     7.6    (dorun
     7.7 +   (import com.aurellem.capture.IsoTimer)
     7.8     (map (comp permissive-import symbol) (jme-class-names))))
     7.9  #+end_src  
    7.10  
    7.11 @@ -74,11 +75,11 @@
    7.12  imports:
    7.13  
    7.14  #+begin_src clojure :exports both :results output
    7.15 -(println (clojure.core/count (cortex.import/jme-classes)) "classes")
    7.16 +(println (clojure.core/count (cortex.import/jme-class-names)) "classes")
    7.17  #+end_src
    7.18  
    7.19  #+results:
    7.20 -: 955 classes
    7.21 +: 938 classes
    7.22  
    7.23  
    7.24  * Utilities
    7.25 @@ -368,6 +369,73 @@
    7.26                        (into-array String ["blend"]))) model))
    7.27  
    7.28  
    7.29 +
    7.30 +(def brick-length 0.48)
    7.31 +(def brick-width 0.24)
    7.32 +(def brick-height 0.12)
    7.33 +(def gravity (Vector3f. 0 -9.81 0))
    7.34 +
    7.35 +(import com.jme3.math.Vector2f)
    7.36 +(import com.jme3.renderer.queue.RenderQueue$ShadowMode)
    7.37 +(import com.jme3.texture.Texture$WrapMode)
    7.38 +
    7.39 +(defn brick* [position]
    7.40 +  (println "get brick.")
    7.41 +  (doto (box brick-length brick-height brick-width
    7.42 +	     :position position :name "brick"
    7.43 +	     :material "Common/MatDefs/Misc/Unshaded.j3md"
    7.44 +	     :texture "Textures/Terrain/BrickWall/BrickWall.jpg"
    7.45 +	     :mass 34)
    7.46 +    (->
    7.47 +     (.getMesh)
    7.48 +     (.scaleTextureCoordinates (Vector2f. 1 0.5)))
    7.49 +    (.setShadowMode RenderQueue$ShadowMode/CastAndReceive)
    7.50 +    )
    7.51 +  )
    7.52 +
    7.53 +
    7.54 +(defn floor*
    7.55 +  "make a sturdy, unmovable physical floor"
    7.56 +  []
    7.57 +  (box 10 0.1 5 :name "floor" :mass 0 
    7.58 +       :color ColorRGBA/Gray :position (Vector3f. 0 0 0)))
    7.59 +
    7.60 +(defn floor* []
    7.61 +  (doto (box 10 0.1 5 :name "floor" ;10 0.1 5 ; 240 0.1 240
    7.62 +	     :material "Common/MatDefs/Misc/Unshaded.j3md"
    7.63 +	     :texture "Textures/BronzeCopper030.jpg"
    7.64 +	     :position (Vector3f. 0 0 0 )
    7.65 +	     :mass 0)
    7.66 +    (->
    7.67 +     (.getMesh)
    7.68 +     (.scaleTextureCoordinates (Vector2f. 3 6)));64 64
    7.69 +    (->
    7.70 +     (.getMaterial)
    7.71 +     (.getTextureParam "ColorMap")
    7.72 +     (.getTextureValue)
    7.73 +     (.setWrap Texture$WrapMode/Repeat))
    7.74 +    (.setShadowMode RenderQueue$ShadowMode/Receive)
    7.75 +  ))
    7.76 +
    7.77 +
    7.78 +(defn brick-wall* []
    7.79 +  (let [node (Node. "brick-wall")]
    7.80 +    (dorun
    7.81 +     (map
    7.82 +      (comp  #(.attachChild node %) brick*)
    7.83 +       (for [y (range 10)
    7.84 +	     x (range 4)
    7.85 +	     z (range 1)]
    7.86 +       	    (Vector3f.
    7.87 +       	     (+ (* 2 x brick-length)
    7.88 +		(if (even? (+ y z)) 
    7.89 +		  (/ brick-length 4) (/ brick-length -4)))
    7.90 +       	     (+ (* brick-height (inc (* 2 y))))
    7.91 +	     (* 2 z brick-width) ))))
    7.92 +    (.setShadowMode node RenderQueue$ShadowMode/CastAndReceive)
    7.93 +    node))
    7.94 +
    7.95 +
    7.96  #+end_src
    7.97  
    7.98