changeset 413:54ef2e06c3ef

gave main worm a consistent muscle order.
author Robert McIntyre <rlm@mit.edu>
date Wed, 19 Mar 2014 14:24:13 -0400
parents cc9957241076
children 634795361af8
files assets/Models/worm/worm.blend org/worm_learn.clj
diffstat 2 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file assets/Models/worm/worm.blend has changed
     2.1 --- a/org/worm_learn.clj	Wed Mar 19 13:21:49 2014 -0400
     2.2 +++ b/org/worm_learn.clj	Wed Mar 19 14:24:13 2014 -0400
     2.3 @@ -11,6 +11,10 @@
     2.4    (:import (com.aurellem.capture Capture IsoTimer))
     2.5    (:import (com.jme3.math Vector3f ColorRGBA)))
     2.6  
     2.7 +(import org.apache.commons.math3.transform.TransformType)
     2.8 +(import org.apache.commons.math3.transform.FastFourierTransformer)
     2.9 +(import org.apache.commons.math3.transform.DftNormalization)
    2.10 +
    2.11  (use 'clojure.pprint)
    2.12  (use 'clojure.set)
    2.13  (dorun (cortex.import/mega-import-jme3))
    2.14 @@ -58,10 +62,10 @@
    2.15          worm-keys
    2.16          ["key-f" "key-r"
    2.17           "key-g" "key-t"
    2.18 -         "key-y" "key-h"
    2.19 +         "key-h" "key-y"
    2.20           "key-j" "key-u"
    2.21 -         "key-i" "key-k"
    2.22 -         "key-o" "key-l"]]
    2.23 +         "key-k" "key-i"
    2.24 +         "key-l" "key-o"]]
    2.25      {:motor-control
    2.26       (fn [effectors]
    2.27        (doall
    2.28 @@ -83,11 +87,11 @@
    2.29  (def period 18)
    2.30  
    2.31  (def worm-muscle-labels
    2.32 -  [:base-up :base-down
    2.33 +  [:base-down :base-up
    2.34     :a-down :a-up
    2.35 -   :b-up :b-down
    2.36 +   :b-down :b-up
    2.37     :c-down :c-up
    2.38 -   :d-up :d-down])
    2.39 +   :d-down :d-up])
    2.40  
    2.41  (defn gen-wiggle [[flexor extensor :as muscle-pair] time-base]
    2.42    (let [period period
    2.43 @@ -166,10 +170,17 @@
    2.44        (- 1)
    2.45        (Math/abs)))
    2.46  
    2.47 +(defn fft [nums]
    2.48 +  (.transform
    2.49 +   (FastFourierTransformer. DftNormalization/UNITARY)
    2.50 +   (double-array nums) TransformType/FORWARD))
    2.51 +
    2.52 +(def indexed (partial map-indexed vector))
    2.53 +
    2.54  (defn wiggling?
    2.55    "Is the worm wiggling?"
    2.56    [experiences]
    2.57 -  (vector:last-n experiences 200)
    2.58 +  (map (comp first :muscle) (vector:last-n experiences 200))
    2.59    
    2.60  )
    2.61