# HG changeset patch # User Robert McIntyre # Date 1395186822 14400 # Node ID bd6d03596ea8312a6bd6e9e90ec91074df0fa97a # Parent 40b67bb71430e1acd382047951689f1a8a81cf02 add worm segment to demonstrate self-organizing touch maps. diff -r 40b67bb71430 -r bd6d03596ea8 assets/Models/worm/worm-single-segment.blend Binary file assets/Models/worm/worm-single-segment.blend has changed diff -r 40b67bb71430 -r bd6d03596ea8 org/worm_learn.clj --- a/org/worm_learn.clj Tue Mar 18 18:34:10 2014 -0400 +++ b/org/worm_learn.clj Tue Mar 18 19:53:42 2014 -0400 @@ -143,6 +143,17 @@ (defn touch-average [[coords touch]] (/ (average (map first touch)) (average (map second touch)))) +(def worm-segment-touch-bottom + [[8 15] [8 16] [8 17] [8 18] [8 19] [8 20] [8 21] [8 22] [9 15] + [9 16] [9 17] [9 18] [9 19] [9 20] [9 21] [9 22] [10 15] [10 16] + [10 17] [10 18] [10 19] [10 20] [10 21] [10 22] [11 15] [11 16] + [11 17] [11 18] [11 19] [11 20] [11 21] [11 22] [12 15] [12 16] + [12 17] [12 18] [12 19] [12 20] [12 21] [12 22] [13 15] [13 16] + [13 17] [13 18] [13 19] [13 20] [13 21] [13 22] [14 15] [14 16] + [14 17] [14 18] [14 19] [14 20] [14 21] [14 22]]) + + + (defn floor-contact [[coords contact :as touch]] (let [raw-average (average @@ -151,13 +162,7 @@ (vals (select-keys (zipmap coords contact) - [[8 15] [8 16] [8 17] [8 18] [8 19] [8 20] [8 21] [8 22] [9 15] - [9 16] [9 17] [9 18] [9 19] [9 20] [9 21] [9 22] [10 15] [10 16] - [10 17] [10 18] [10 19] [10 20] [10 21] [10 22] [11 15] [11 16] - [11 17] [11 18] [11 19] [11 20] [11 21] [11 22] [12 15] [12 16] - [12 17] [12 18] [12 19] [12 20] [12 21] [12 22] [13 15] [13 16] - [13 17] [13 18] [13 19] [13 20] [13 21] [13 22] [14 15] [14 16] - [14 17] [14 18] [14 19] [14 20] [14 21] [14 22]]))))] + ))))] (Math/abs (- 1. (* 10 raw-average))))) @@ -186,7 +191,10 @@ :motor-control (:motor-control direct-control) :keybindings (:keybindings direct-control) :record nil - :experiences nil})) + :experiences nil + :worm-model worm-model + :end-frame nil})) + (defn dir! [file] (if (not (.exists file)) @@ -197,8 +205,10 @@ (swap! experiences #(conj % data))) (defn worm-world - [& {:keys [record motor-control keybindings view experiences] :as settings}] - (let [{:keys [record motor-control keybindings view]} + [& {:keys [record motor-control keybindings view experiences + worm-model end-frame] :as settings}] + (let [{:keys [record motor-control keybindings view experiences + worm-model end-frame]} (merge (worm-world-defaults) settings) worm (doto (worm-model) (body!)) touch (touch! worm) @@ -210,16 +220,16 @@ muscle-display (view-movement) floor (box 10 1 10 :position (Vector3f. 0 -10 0) - :color ColorRGBA/Gray :mass 0)] + :color ColorRGBA/Gray :mass 0) + timer (IsoTimer. 60)] (world (nodify [worm floor]) (merge standard-debug-controls keybindings) (fn [world] (position-camera world view) - (let [timer (IsoTimer. 60)] - (.setTimer world timer) - (display-dilated-time world timer)) + (.setTimer world timer) + (display-dilated-time world timer) (if record (Capture/captureVideo world @@ -227,6 +237,8 @@ (speed-up world) (light-up-everything world)) (fn [world tpf] + (if (> (.getTime timer) end-frame) + (.stop world)) (let [muscle-data (motor-control muscles) proprioception-data (prop) touch-data (map #(% (.getRootNode world)) touch)] @@ -237,10 +249,10 @@ :muscle muscle-data}) (if (curled? @experiences) (println "Curled")) ;;(if (straight? @experiences) (println "Straight")) - (println-repl - (apply format "%.2f %.2f %.2f %.2f %.2f\n" - (map floor-contact touch-data))) - + ;; (println-repl + ;; (apply format "%.2f %.2f %.2f %.2f %.2f\n" + ;; (map floor-contact touch-data))) + ) (muscle-display muscle-data @@ -251,3 +263,61 @@ (touch-display touch-data (if record (dir! (File. record "touch"))))))))) + + +;; A demonstration of self organiging touch maps through experience. + +(def single-worm-segment-view + [(Vector3f. 2.0681207, -6.1406755, 1.6106138) + (Quaternion. -0.15558705, 0.843615, -0.3428654, -0.38281822)]) + +(def worm-single-segment-muscle-labels + [:lift-1 :lift-2 :roll-1 :roll-2]) + +(defn touch-kinesthetics [] + [[170 :lift-1 40] + [190 :lift-1 20] + [206 :lift-1 0] + + [400 :lift-2 40] + [410 :lift-2 0] + + [570 :lift-2 40] + [590 :lift-2 20] + [606 :lift-2 0] + + [800 :lift-1 40] + [809 :lift-1 0] + + [900 :roll-2 40] + [905 :roll-2 20] + [910 :roll-2 0] + + [1000 :roll-2 40] + [1005 :roll-2 20] + [1010 :roll-2 0] + + [1100 :roll-2 40] + [1105 :roll-2 20] + [1110 :roll-2 0] + ]) + +(defn worm-segment-defaults [] + (let [direct-control (worm-direct-control worm-muscle-labels 40)] + (merge (worm-world-defaults) + {:worm-model single-worm-segment + :view single-worm-segment-view + :motor-control + (motor-control-program + worm-single-segment-muscle-labels + (touch-kinesthetics))}))) + +(defn single-worm-segment [] + (load-blender-model "Models/worm/worm-single-segment.blend")) + + +(defn pure-touch? + "This is worm specific code to determine if a large region of touch + sensors is either all on or all off." + [[coords touch :as touch-data]] + (= (set (map first touch)) #{(float 0.1) (float 0.0)})) \ No newline at end of file diff -r 40b67bb71430 -r bd6d03596ea8 thesis/org/roadmap.org --- a/thesis/org/roadmap.org Tue Mar 18 18:34:10 2014 -0400 +++ b/thesis/org/roadmap.org Tue Mar 18 19:53:42 2014 -0400 @@ -191,9 +191,14 @@ *** DONE add phi-space output to debug control CLOSED: [2014-03-17 Mon 17:42] SCHEDULED: <2014-03-17 Mon> CLOCK: [2014-03-17 Mon 17:31]--[2014-03-17 Mon 17:42] => 0:11 + +*** TODO complete automatic touch partitioning +*** TODO complete cyclic predicate *** TODO complete three phi-stream action predicatates; test them with debug control SCHEDULED: <2014-03-17 Mon> - CLOCK: [2014-03-17 Mon 19:19] + CLOCK: [2014-03-18 Tue 18:36] + CLOCK: [2014-03-18 Tue 18:34]--[2014-03-18 Tue 18:36] => 0:02 + CLOCK: [2014-03-17 Mon 19:19]--[2014-03-17 Mon 21:19] => 2:00 *** TODO create test videos, also record positions of worm segments SCHEDULED: <2014-03-17 Mon> *** TODO complete proprioception based movement lookup in phi-space