rlm@346
|
1
|
rlm@346
|
2
|
rlm@348
|
3 * A joint
|
rlm@348
|
4
|
rlm@348
|
5 The point of this joint is that it uses exploratory motor movements to
|
rlm@348
|
6 learn how to move to any particular position.
|
rlm@348
|
7
|
rlm@348
|
8 visual-information -- list of functions which must each be called with the
|
rlm@348
|
9 world the argument, each of which returns [topology data]. Each element
|
rlm@348
|
10 of data is a number between 0 and 255 representing the intensity of
|
rlm@348
|
11 the light recieved at that sensor.
|
rlm@348
|
12
|
rlm@348
|
13 proprioception -- list of nullary functions, one for each joint, which
|
rlm@348
|
14 return [heding pitch roll].
|
rlm@348
|
15
|
rlm@348
|
16 touch -- list of functions which must each be called with a Node
|
rlm@348
|
17 (normally the root node of the simulation) the argument, each of which
|
rlm@348
|
18 returns [topology data]. Each element of data is a posive float
|
rlm@348
|
19 between 0.0 and the max length of the "hairs" of which the touch sense
|
rlm@348
|
20 is composed.
|
rlm@348
|
21
|
rlm@348
|
22 movement -- list of functions, one for each muscle, which must be
|
rlm@348
|
23 called with an integer between 0 and the total number of muscle fibers
|
rlm@348
|
24 in the muscle. Each function returns a float which is (current-force/
|
rlm@348
|
25 total-possible-force).
|
rlm@348
|
26
|
rlm@343
|
27
|
rlm@347
|
28 #+name: load-creature
|
rlm@347
|
29 #+begin_src clojure
|
rlm@347
|
30 (in-ns 'cortex.joint)
|
rlm@343
|
31
|
rlm@347
|
32 (def joint "Models/joint/joint.blend")
|
rlm@347
|
33
|
rlm@347
|
34 (defn load-creature []
|
rlm@347
|
35 (load-blender-model joint))
|
rlm@347
|
36
|
rlm@347
|
37
|
rlm@348
|
38
|
rlm@348
|
39
|
rlm@348
|
40
|
rlm@347
|
41 (defn test-creature []
|
rlm@347
|
42 (let [me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
|
rlm@347
|
43 creature (doto (load-creature) (body!))
|
rlm@347
|
44
|
rlm@347
|
45 ;;;;;;;;;;;; Sensors/Effectors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
rlm@347
|
46 touch (touch! creature)
|
rlm@347
|
47 touch-display (view-touch)
|
rlm@347
|
48
|
rlm@348
|
49 vision (vision! creature)
|
rlm@348
|
50 vision-display (view-vision)
|
rlm@347
|
51
|
rlm@347
|
52 ;;hearing (hearing! creature)
|
rlm@347
|
53 ;;hearing-display (view-hearing)
|
rlm@347
|
54
|
rlm@347
|
55 prop (proprioception! creature)
|
rlm@347
|
56 prop-display (view-proprioception)
|
rlm@347
|
57
|
rlm@347
|
58 muscles (movement! creature)
|
rlm@347
|
59 muscle-display (view-movement)
|
rlm@347
|
60 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
rlm@347
|
61
|
rlm@347
|
62 fix-display (gen-fix-display)
|
rlm@347
|
63
|
rlm@347
|
64 floor (box 10 2 10 :position (Vector3f. 0 -9 0)
|
rlm@348
|
65 :color ColorRGBA/Gray :mass 0)]
|
rlm@347
|
66 (world
|
rlm@347
|
67 (nodify [floor me creature])
|
rlm@347
|
68 standard-debug-controls
|
rlm@347
|
69 (fn [world]
|
rlm@348
|
70 (let [timer (RatchetTimer. 60)]
|
rlm@348
|
71 (.setTimer world timer)
|
rlm@348
|
72 (display-dilated-time world timer)))
|
rlm@347
|
73 (fn [world tpf]
|
rlm@348
|
74 (.setLocalTranslation me (.getLocation (.getCamera world)))
|
rlm@347
|
75 (fix-display world)))))
|
rlm@347
|
76
|
rlm@347
|
77
|
rlm@347
|
78
|
rlm@347
|
79
|
rlm@347
|
80 #+end_src
|
rlm@343
|
81
|
rlm@343
|
82
|
rlm@343
|
83
|
rlm@343
|
84
|
rlm@343
|
85
|
rlm@343
|
86
|
rlm@343
|
87 * Headers
|
rlm@343
|
88 #+name: joint-header
|
rlm@343
|
89 #+begin_src clojure
|
rlm@343
|
90 (ns cortex.joint
|
rlm@347
|
91 (:require cortex.import)
|
rlm@347
|
92 (:use (cortex world util import body sense
|
rlm@347
|
93 hearing touch vision proprioception movement))
|
rlm@347
|
94 (:import java.io.File)
|
rlm@347
|
95 (:import (com.aurellem.capture RatchetTimer IsoTimer)))
|
rlm@347
|
96
|
rlm@343
|
97
|
rlm@343
|
98 (cortex.import/mega-import-jme3)
|
rlm@346
|
99 (rlm.rlm-commands/help)
|
rlm@343
|
100 #+end_src
|
rlm@343
|
101
|
rlm@343
|
102
|
rlm@343
|
103 * COMMENT Generate Source
|
rlm@343
|
104
|
rlm@343
|
105 #+begin_src clojure :tangle ../src/cortex/joint.clj
|
rlm@343
|
106 <<joint-header>>
|
rlm@347
|
107 <<load-creature>>
|
rlm@343
|
108 #+end_src
|
rlm@346
|
109
|