comparison org/integration.org @ 281:7351c9c0c471

resurrected integration test.
author Robert McIntyre <rlm@mit.edu>
date Wed, 15 Feb 2012 11:13:12 -0700
parents 305439cec54d
children 2ad29b68ff22
comparison
equal deleted inserted replaced
280:301e91a6c2d1 281:7351c9c0c471
1 #+title: First attempt at a creature! 1 #+title:
2 #+author: Robert McIntyre 2 #+author: Robert McIntyre
3 #+email: rlm@mit.edu 3 #+email: rlm@mit.edu
4 #+description: 4 #+description:
5 #+keywords: simulation, jMonkeyEngine3, clojure 5 #+keywords: simulation, jMonkeyEngine3, clojure
6 #+SETUPFILE: ../../aurellem/org/setup.org 6 #+SETUPFILE: ../../aurellem/org/setup.org
7 #+INCLUDE: ../../aurellem/org/level-0.org 7 #+INCLUDE: ../../aurellem/org/level-0.org
8 8
9
10
11
12 * Intro 9 * Intro
13 So far, I've made the following senses -- 10
14 - Vision 11 This is the ultimate test which features all of the senses that I've
15 - Hearing 12 made so far. The blender file for the creature serves as an example of
16 - Touch 13 a fully equipped creature in terms of senses. You can find it [[../assets/Models/test-creature/hand.blend][here]].
17 - Proprioception
18
19 And one effector:
20 - Movement
21
22 However, the code so far has only enabled these senses, but has not
23 actually implemented them. For example, there is still a lot of work
24 to be done for vision. I need to be able to create an /eyeball/ in
25 simulation that can be moved around and see the world from different
26 angles. I also need to determine weather to use log-polar or cartesian
27 for the visual input, and I need to determine how/wether to
28 disceritise the visual input.
29
30 I also want to be able to visualize both the sensors and the
31 effectors in pretty pictures. This semi-retarted creature will be my
32 first attempt at bringing everything together.
33
34 * The creature's body
35
36 Still going to do an eve-like body in blender, but due to problems
37 importing the joints, etc into jMonkeyEngine3, I'm going to do all
38 the connecting here in clojure code, using the names of the individual
39 components and trial and error. Later, I'll maybe make some sort of
40 creature-building modifications to blender that support whatever
41 discritized senses I'm going to make.
42 14
43 #+name: integration 15 #+name: integration
44 #+begin_src clojure 16 #+begin_src clojure
45 (ns cortex.integration 17 (ns cortex.integration
46 "let's play!" 18 "let's play!"
47 {:author "Robert McIntyre"} 19 {:author "Robert McIntyre"}
48 (:use (cortex world util body 20 (:use (cortex world util body sense
49 hearing touch vision sense proprioception movement)) 21 hearing touch vision proprioception movement))
50 (:import (com.jme3.math ColorRGBA Vector3f)) 22 (:import (com.jme3.math ColorRGBA Vector3f))
23 (:import java.io.File)
51 (:import com.jme3.audio.AudioNode) 24 (:import com.jme3.audio.AudioNode)
52 (:import com.aurellem.capture.RatchetTimer)) 25 (:import com.aurellem.capture.RatchetTimer))
53 26
54 (def hand "Models/creature1/one.blend") 27 (dorun (cortex.import/mega-import-jme3))
55 28 (rlm.rlm-commands/help)
56 (def worm "Models/creature1/try-again.blend") 29
57 30 (def hand "Models/test-creature/hand.blend")
58 (defn test-creature [thing] 31
59 (let [x-axis 32 (def output-base (File. "/home/r/proj/cortex/render/hand"))
60 (box 1 0.01 0.01 :physical? false :color ColorRGBA/Red) 33
61 y-axis 34 (defn test-everything!
62 (box 0.01 1 0.01 :physical? false :color ColorRGBA/Green) 35 ([] (test-everything! false))
63 z-axis 36 ([record?]
64 (box 0.01 0.01 1 :physical? false :color ColorRGBA/Blue) 37 (let [me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
65 38
66 me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
67 bell (AudioNode. (asset-manager) 39 bell (AudioNode. (asset-manager)
68 "Sounds/pure.wav" false) 40 "Sounds/pure.wav" false)
69 41
70 fix-display 42
71 (runonce (fn [world] 43
72 (add-camera! world (.getCamera world) no-op))) 44 creature (doto (load-blender-model hand)
73 creature (doto (load-blender-model thing) (body!)) 45 (body!))
74 46
75 ;;;;;;;;;;;; Sensors/Effectors ;;;;;;;;;;;;;;;;;;;;;;;;;;;; 47 ;;;;;;;;;;;; Sensors/Effectors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
76 touch (touch! creature) 48 touch (touch! creature)
77 touch-display (view-touch) 49 touch-display (view-touch)
78 50
79 vision (vision! creature) 51 vision (vision! creature)
85 prop (proprioception! creature) 57 prop (proprioception! creature)
86 prop-display (view-proprioception) 58 prop-display (view-proprioception)
87 59
88 muscle-exertion (atom 0) 60 muscle-exertion (atom 0)
89 muscles (movement! creature) 61 muscles (movement! creature)
90 muscle-display (view-movement)] 62 muscle-display (view-movement)
91 63 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64
65 fix-display (gen-fix-display)]
92 (apply 66 (apply
93 world 67 world
94 (with-movement 68 (with-movement
95 (.getChild creature "worm-21") 69 (.getChild creature "palm")
96 ["key-r" "key-t" 70 ["key-r" "key-t"
97 "key-f" "key-g" 71 "key-f" "key-g"
98 "key-v" "key-b"] 72 "key-v" "key-b"]
99 [10 10 10 10 1 1] 73 [10 10 10 10 1 1]
100 [(nodify [creature 74 [(nodify [creature
101 (box 10 2 10 :position (Vector3f. 0 -9 0) 75 (box 10 2 10 :position (Vector3f. 0 -9 0)
102 :color ColorRGBA/Gray :mass 0) 76 :color ColorRGBA/Gray :mass 0)
103 x-axis y-axis z-axis
104 me]) 77 me])
105 (merge standard-debug-controls 78 (merge standard-debug-controls
106 {"key-return" 79 {"key-return"
107 (fn [_ value] 80 (fn [_ value]
108 (if value 81 (if value
116 "key-n" 89 "key-n"
117 (fn [_ value] 90 (fn [_ value]
118 (if value 91 (if value
119 (swap! muscle-exertion (fn [v] (- v 20)))))}) 92 (swap! muscle-exertion (fn [v] (- v 20)))))})
120 (fn [world] 93 (fn [world]
94 (.setTimer world (RatchetTimer. 60))
121 (light-up-everything world) 95 (light-up-everything world)
122 (enable-debug world) 96 (enable-debug world)
123 (add-camera! world 97 (add-camera! world
124 (add-eye! creature 98 (add-eye! creature
125 (.getChild 99 (.getChild
126 (.getChild creature "eyes") "eye")) 100 (.getChild creature "eyes") "eye"))
127 (comp (view-image) BufferedImage!)) 101 (comp (view-image) BufferedImage!))
128 (.setTimer world (RatchetTimer. 60)) 102 (speed-up world))
129 (speed-up world)
130 (set-gravity world (Vector3f. 0 0 0))
131 (comment
132 (com.aurellem.capture.Capture/captureVideo
133 world (file-str "/home/r/proj/ai-videos/hand"))))
134 (fn [world tpf] 103 (fn [world tpf]
135 (prop-display (prop)) 104 (prop-display (prop))
136 (touch-display (map #(% (.getRootNode world)) touch)) 105 (touch-display (map #(% (.getRootNode world)) touch))
137 (vision-display (map #(% world) vision)) 106 (vision-display (map #(% world) vision))
138 (hearing-display (map #(% world) hearing)) 107 (hearing-display (map #(% world) hearing))
139 (muscle-display (map #(% @muscle-exertion) muscles)) 108 (muscle-display (map #(% @muscle-exertion) muscles))
140 (.setLocalTranslation me (.getLocation (.getCamera world))) 109 (.setLocalTranslation me (.getLocation (.getCamera world)))
141 (fix-display world))])))) 110 (fix-display world))])))))
142 #+end_src 111 #+end_src
143
144 #+results: body-1
145 : #'cortex.silly/follow-test
146
147 112
148 * COMMENT purgatory 113 * COMMENT purgatory
149 #+begin_src clojure 114 #+begin_src clojure
150
151 (defn bullet-trans* [] 115 (defn bullet-trans* []
152 (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red 116 (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red
153 :position (Vector3f. 5 0 0) 117 :position (Vector3f. 5 0 0)
154 :mass 90) 118 :mass 90)
155 obj-b (sphere 0.5 :color ColorRGBA/Blue 119 obj-b (sphere 0.5 :color ColorRGBA/Blue