Mercurial > cortex
changeset 407:bd6d03596ea8
add worm segment to demonstrate self-organizing touch maps.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 18 Mar 2014 19:53:42 -0400 |
parents | 40b67bb71430 |
children | 3b4012b42611 |
files | assets/Models/worm/worm-single-segment.blend org/worm_learn.clj thesis/org/roadmap.org |
diffstat | 3 files changed, 94 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
1.1 Binary file assets/Models/worm/worm-single-segment.blend has changed
2.1 --- a/org/worm_learn.clj Tue Mar 18 18:34:10 2014 -0400 2.2 +++ b/org/worm_learn.clj Tue Mar 18 19:53:42 2014 -0400 2.3 @@ -143,6 +143,17 @@ 2.4 (defn touch-average [[coords touch]] 2.5 (/ (average (map first touch)) (average (map second touch)))) 2.6 2.7 +(def worm-segment-touch-bottom 2.8 + [[8 15] [8 16] [8 17] [8 18] [8 19] [8 20] [8 21] [8 22] [9 15] 2.9 + [9 16] [9 17] [9 18] [9 19] [9 20] [9 21] [9 22] [10 15] [10 16] 2.10 + [10 17] [10 18] [10 19] [10 20] [10 21] [10 22] [11 15] [11 16] 2.11 + [11 17] [11 18] [11 19] [11 20] [11 21] [11 22] [12 15] [12 16] 2.12 + [12 17] [12 18] [12 19] [12 20] [12 21] [12 22] [13 15] [13 16] 2.13 + [13 17] [13 18] [13 19] [13 20] [13 21] [13 22] [14 15] [14 16] 2.14 + [14 17] [14 18] [14 19] [14 20] [14 21] [14 22]]) 2.15 + 2.16 + 2.17 + 2.18 (defn floor-contact [[coords contact :as touch]] 2.19 (let [raw-average 2.20 (average 2.21 @@ -151,13 +162,7 @@ 2.22 (vals 2.23 (select-keys 2.24 (zipmap coords contact) 2.25 - [[8 15] [8 16] [8 17] [8 18] [8 19] [8 20] [8 21] [8 22] [9 15] 2.26 - [9 16] [9 17] [9 18] [9 19] [9 20] [9 21] [9 22] [10 15] [10 16] 2.27 - [10 17] [10 18] [10 19] [10 20] [10 21] [10 22] [11 15] [11 16] 2.28 - [11 17] [11 18] [11 19] [11 20] [11 21] [11 22] [12 15] [12 16] 2.29 - [12 17] [12 18] [12 19] [12 20] [12 21] [12 22] [13 15] [13 16] 2.30 - [13 17] [13 18] [13 19] [13 20] [13 21] [13 22] [14 15] [14 16] 2.31 - [14 17] [14 18] [14 19] [14 20] [14 21] [14 22]]))))] 2.32 + ))))] 2.33 (Math/abs (- 1. (* 10 raw-average))))) 2.34 2.35 2.36 @@ -186,7 +191,10 @@ 2.37 :motor-control (:motor-control direct-control) 2.38 :keybindings (:keybindings direct-control) 2.39 :record nil 2.40 - :experiences nil})) 2.41 + :experiences nil 2.42 + :worm-model worm-model 2.43 + :end-frame nil})) 2.44 + 2.45 2.46 (defn dir! [file] 2.47 (if (not (.exists file)) 2.48 @@ -197,8 +205,10 @@ 2.49 (swap! experiences #(conj % data))) 2.50 2.51 (defn worm-world 2.52 - [& {:keys [record motor-control keybindings view experiences] :as settings}] 2.53 - (let [{:keys [record motor-control keybindings view]} 2.54 + [& {:keys [record motor-control keybindings view experiences 2.55 + worm-model end-frame] :as settings}] 2.56 + (let [{:keys [record motor-control keybindings view experiences 2.57 + worm-model end-frame]} 2.58 (merge (worm-world-defaults) settings) 2.59 worm (doto (worm-model) (body!)) 2.60 touch (touch! worm) 2.61 @@ -210,16 +220,16 @@ 2.62 muscle-display (view-movement) 2.63 2.64 floor (box 10 1 10 :position (Vector3f. 0 -10 0) 2.65 - :color ColorRGBA/Gray :mass 0)] 2.66 + :color ColorRGBA/Gray :mass 0) 2.67 + timer (IsoTimer. 60)] 2.68 2.69 (world 2.70 (nodify [worm floor]) 2.71 (merge standard-debug-controls keybindings) 2.72 (fn [world] 2.73 (position-camera world view) 2.74 - (let [timer (IsoTimer. 60)] 2.75 - (.setTimer world timer) 2.76 - (display-dilated-time world timer)) 2.77 + (.setTimer world timer) 2.78 + (display-dilated-time world timer) 2.79 (if record 2.80 (Capture/captureVideo 2.81 world 2.82 @@ -227,6 +237,8 @@ 2.83 (speed-up world) 2.84 (light-up-everything world)) 2.85 (fn [world tpf] 2.86 + (if (> (.getTime timer) end-frame) 2.87 + (.stop world)) 2.88 (let [muscle-data (motor-control muscles) 2.89 proprioception-data (prop) 2.90 touch-data (map #(% (.getRootNode world)) touch)] 2.91 @@ -237,10 +249,10 @@ 2.92 :muscle muscle-data}) 2.93 (if (curled? @experiences) (println "Curled")) 2.94 ;;(if (straight? @experiences) (println "Straight")) 2.95 - (println-repl 2.96 - (apply format "%.2f %.2f %.2f %.2f %.2f\n" 2.97 - (map floor-contact touch-data))) 2.98 - 2.99 + ;; (println-repl 2.100 + ;; (apply format "%.2f %.2f %.2f %.2f %.2f\n" 2.101 + ;; (map floor-contact touch-data))) 2.102 + 2.103 ) 2.104 (muscle-display 2.105 muscle-data 2.106 @@ -251,3 +263,61 @@ 2.107 (touch-display 2.108 touch-data 2.109 (if record (dir! (File. record "touch"))))))))) 2.110 + 2.111 + 2.112 +;; A demonstration of self organiging touch maps through experience. 2.113 + 2.114 +(def single-worm-segment-view 2.115 + [(Vector3f. 2.0681207, -6.1406755, 1.6106138) 2.116 + (Quaternion. -0.15558705, 0.843615, -0.3428654, -0.38281822)]) 2.117 + 2.118 +(def worm-single-segment-muscle-labels 2.119 + [:lift-1 :lift-2 :roll-1 :roll-2]) 2.120 + 2.121 +(defn touch-kinesthetics [] 2.122 + [[170 :lift-1 40] 2.123 + [190 :lift-1 20] 2.124 + [206 :lift-1 0] 2.125 + 2.126 + [400 :lift-2 40] 2.127 + [410 :lift-2 0] 2.128 + 2.129 + [570 :lift-2 40] 2.130 + [590 :lift-2 20] 2.131 + [606 :lift-2 0] 2.132 + 2.133 + [800 :lift-1 40] 2.134 + [809 :lift-1 0] 2.135 + 2.136 + [900 :roll-2 40] 2.137 + [905 :roll-2 20] 2.138 + [910 :roll-2 0] 2.139 + 2.140 + [1000 :roll-2 40] 2.141 + [1005 :roll-2 20] 2.142 + [1010 :roll-2 0] 2.143 + 2.144 + [1100 :roll-2 40] 2.145 + [1105 :roll-2 20] 2.146 + [1110 :roll-2 0] 2.147 + ]) 2.148 + 2.149 +(defn worm-segment-defaults [] 2.150 + (let [direct-control (worm-direct-control worm-muscle-labels 40)] 2.151 + (merge (worm-world-defaults) 2.152 + {:worm-model single-worm-segment 2.153 + :view single-worm-segment-view 2.154 + :motor-control 2.155 + (motor-control-program 2.156 + worm-single-segment-muscle-labels 2.157 + (touch-kinesthetics))}))) 2.158 + 2.159 +(defn single-worm-segment [] 2.160 + (load-blender-model "Models/worm/worm-single-segment.blend")) 2.161 + 2.162 + 2.163 +(defn pure-touch? 2.164 + "This is worm specific code to determine if a large region of touch 2.165 + sensors is either all on or all off." 2.166 + [[coords touch :as touch-data]] 2.167 + (= (set (map first touch)) #{(float 0.1) (float 0.0)})) 2.168 \ No newline at end of file
3.1 --- a/thesis/org/roadmap.org Tue Mar 18 18:34:10 2014 -0400 3.2 +++ b/thesis/org/roadmap.org Tue Mar 18 19:53:42 2014 -0400 3.3 @@ -191,9 +191,14 @@ 3.4 *** DONE add phi-space output to debug control 3.5 CLOSED: [2014-03-17 Mon 17:42] SCHEDULED: <2014-03-17 Mon> 3.6 CLOCK: [2014-03-17 Mon 17:31]--[2014-03-17 Mon 17:42] => 0:11 3.7 + 3.8 +*** TODO complete automatic touch partitioning 3.9 +*** TODO complete cyclic predicate 3.10 *** TODO complete three phi-stream action predicatates; test them with debug control 3.11 SCHEDULED: <2014-03-17 Mon> 3.12 - CLOCK: [2014-03-17 Mon 19:19] 3.13 + CLOCK: [2014-03-18 Tue 18:36] 3.14 + CLOCK: [2014-03-18 Tue 18:34]--[2014-03-18 Tue 18:36] => 0:02 3.15 + CLOCK: [2014-03-17 Mon 19:19]--[2014-03-17 Mon 21:19] => 2:00 3.16 *** TODO create test videos, also record positions of worm segments 3.17 SCHEDULED: <2014-03-17 Mon> 3.18 *** TODO complete proprioception based movement lookup in phi-space