# HG changeset patch # User Robert McIntyre # Date 1395182050 14400 # Node ID 40b67bb71430e1acd382047951689f1a8a81cf02 # Parent 9b4a4da08b784d0f3c0afa3b7b8143ee84efb80a save progress. diff -r 9b4a4da08b78 -r 40b67bb71430 org/worm_learn.clj --- a/org/worm_learn.clj Mon Mar 17 20:52:16 2014 -0400 +++ b/org/worm_learn.clj Tue Mar 18 18:34:10 2014 -0400 @@ -9,7 +9,8 @@ (:import com.aurellem.capture.RatchetTimer) (:import (com.aurellem.capture Capture IsoTimer)) (:import (com.jme3.math Vector3f ColorRGBA))) - + +(use 'clojure.pprint) (dorun (cortex.import/mega-import-jme3)) (rlm.rlm-commands/help) @@ -26,7 +27,7 @@ (defn motor-control-program "Create a function which will execute the motor script" - [muscle-positions + [muscle-labels script] (let [current-frame (atom -1) keyed-script (group-by first script) @@ -39,7 +40,7 @@ (doall (map (fn [effector power] (effector (int power))) effectors - (map #(@current-forces % 0) muscle-positions))))))) + (map #(@current-forces % 0) muscle-labels))))))) (defn worm-direct-control "Create keybindings and a muscle control program that will enable @@ -96,8 +97,8 @@ [(+ time-base (+ (* 2 period) 2)) extensor 0]])) (def wiggle-script - (mapcat gen-wiggle (repeat 40 [:a-down :a-up]) - (range 100 10000 (+ 3 (* period 2))))) + (mapcat gen-wiggle (repeat 4000 [:a-down :a-up]) + (range 100 1000000 (+ 3 (* period 2))))) ;; Normally, we'd use unsupervised/supervised machine learning to pick @@ -132,28 +133,40 @@ "Does the worm form a majestic circle (one end touching the other)?" [experiences] (and (curled? experiences) - true)) + true)) ;; TODO: add code here. (defn vector:last-n [v n] (let [c (count v)] (if (< c n) v (subvec v (- c n) c)))) +(defn touch-average [[coords touch]] + (/ (average (map first touch)) (average (map second touch)))) + +(defn floor-contact [[coords contact :as touch]] + (let [raw-average + (average + (map + first + (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))))) + + (defn wiggling? "Is the worm wiggling?" [experiences] - (vector:last-n + (vector:last-n experiences 200) - -)) - - - - - -(defn resting? - "Is the worm on the ground in a neutral position?" - []) +) (def standard-world-view [(Vector3f. 4.207176, -3.7366982, 3.0816958) @@ -223,7 +236,11 @@ :proprioception proprioception-data :muscle muscle-data}) (if (curled? @experiences) (println "Curled")) - (if (straight? @experiences) (println "Straight")) + ;;(if (straight? @experiences) (println "Straight")) + (println-repl + (apply format "%.2f %.2f %.2f %.2f %.2f\n" + (map floor-contact touch-data))) + ) (muscle-display muscle-data diff -r 9b4a4da08b78 -r 40b67bb71430 thesis/org/roadmap.org --- a/thesis/org/roadmap.org Mon Mar 17 20:52:16 2014 -0400 +++ b/thesis/org/roadmap.org Tue Mar 18 18:34:10 2014 -0400 @@ -193,6 +193,7 @@ CLOCK: [2014-03-17 Mon 17:31]--[2014-03-17 Mon 17:42] => 0:11 *** TODO complete three phi-stream action predicatates; test them with debug control SCHEDULED: <2014-03-17 Mon> + CLOCK: [2014-03-17 Mon 19:19] *** TODO create test videos, also record positions of worm segments SCHEDULED: <2014-03-17 Mon> *** TODO complete proprioception based movement lookup in phi-space