Mercurial > cortex
comparison org/body.org @ 69:39e4e1542e4a
updated test-suite
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 09 Dec 2011 23:11:28 -0600 |
parents | 1381a6ebd08b |
children | a1e421d9c485 |
comparison
equal
deleted
inserted
replaced
68:6cd5a034d855 | 69:39e4e1542e4a |
---|---|
129 ## note -- might want to add a lower dimensional, discrete version of | 129 ## note -- might want to add a lower dimensional, discrete version of |
130 ## this if it proves useful from a x-modal clustering perspective. | 130 ## this if it proves useful from a x-modal clustering perspective. |
131 | 131 |
132 * Examples | 132 * Examples |
133 | 133 |
134 #+srcname: test-body | 134 #+name: test-body |
135 #+begin_src clojure | 135 #+begin_src clojure |
136 (ns test.body | 136 (ns cortex.test.body |
137 (:use (cortex world util body)) | 137 (:use (cortex world util body)) |
138 (:import | 138 (:import |
139 com.jme3.math.Vector3f | 139 com.jme3.math.Vector3f |
140 com.jme3.math.ColorRGBA | 140 com.jme3.math.ColorRGBA |
141 com.jme3.bullet.joints.Point2PointJoint | 141 com.jme3.bullet.joints.Point2PointJoint |
198 Vector3f/ZERO | 198 Vector3f/ZERO |
199 Vector3f/ZERO | 199 Vector3f/ZERO |
200 Vector3f/ZERO])) | 200 Vector3f/ZERO])) |
201 | 201 |
202 (defn test-motor-control | 202 (defn test-motor-control |
203 "You should see a multi-segmented worm-like object fall onto the | 203 "Testing motor-control: |
204 You should see a multi-segmented worm-like object fall onto the | |
204 table and begin writhing and moving." | 205 table and begin writhing and moving." |
205 [] | 206 [] |
206 (let [worm (eve-worm) | 207 (let [worm (eve-worm) |
207 time (atom 0) | 208 time (atom 0) |
208 worm-motor-map (vector-motor-control worm)] | 209 worm-motor-map (vector-motor-control worm)] |
225 (Thread/sleep 20) | 226 (Thread/sleep 20) |
226 (dorun (worm-motor-map | 227 (dorun (worm-motor-map |
227 (worm-pattern @time))))))) | 228 (worm-pattern @time))))))) |
228 | 229 |
229 (defn test-proprioception | 230 (defn test-proprioception |
230 "You should see two foating bars, and a printout of pitch, yaw, and | 231 "Testing proprioception: |
232 You should see two foating bars, and a printout of pitch, yaw, and | |
231 roll. Pressing key-r/key-t should move the blue bar up and down and | 233 roll. Pressing key-r/key-t should move the blue bar up and down and |
232 change only the value of pitch. key-f/key-g moves it side to side | 234 change only the value of pitch. key-f/key-g moves it side to side |
233 and changes yaw. key-v/key-b will spin the blue segment clockwise | 235 and changes yaw. key-v/key-b will spin the blue segment clockwise |
234 and counterclockwise, and only affect roll." | 236 and counterclockwise, and only affect roll." |
235 [] | 237 [] |
267 "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))}) | 269 "key-b" (fn [_ pressed?] (reset! roll-right? pressed?))}) |
268 (fn [world] | 270 (fn [world] |
269 (set-gravity world (Vector3f. 0 0 0)) | 271 (set-gravity world (Vector3f. 0 0 0)) |
270 (.setMoveSpeed (.getFlyByCamera world) 50) | 272 (.setMoveSpeed (.getFlyByCamera world) 50) |
271 (.setRotationSpeed (.getFlyByCamera world) 50) | 273 (.setRotationSpeed (.getFlyByCamera world) 50) |
272 (light-up-everything world) | 274 (light-up-everything world)) |
273 (.setTimer world (NanoTimer.)) | |
274 ) | |
275 (fn [_ _] | 275 (fn [_ _] |
276 (if @move-up? | 276 (if @move-up? |
277 (.applyTorque control | 277 (.applyTorque control |
278 (.mult (.getPhysicsRotation control) | 278 (.mult (.getPhysicsRotation control) |
279 (Vector3f. 0 0 10)))) | 279 (Vector3f. 0 0 10)))) |
298 (.mult (.getPhysicsRotation control) | 298 (.mult (.getPhysicsRotation control) |
299 (Vector3f. 1 0 0)))) | 299 (Vector3f. 1 0 0)))) |
300 | 300 |
301 (if (= 0 (rem (swap! time inc) 2000)) | 301 (if (= 0 (rem (swap! time inc) 2000)) |
302 (do | 302 (do |
303 | |
304 (apply | 303 (apply |
305 (comp | 304 (comp |
306 println-repl | 305 println-repl |
307 #(format "pitch: %1.2f\nyaw: %1.2f\nroll: %1.2f\n" %1 %2 %3)) | 306 #(format "pitch: %1.2f\nyaw: %1.2f\nroll: %1.2f\n" %1 %2 %3)) |
308 (joint-proprioception joint)))))))) | 307 (joint-proprioception joint)))))))) |
750 #+begin_src clojure :tangle ../src/cortex/body.clj | 749 #+begin_src clojure :tangle ../src/cortex/body.clj |
751 <<proprioception>> | 750 <<proprioception>> |
752 <<motor-control>> | 751 <<motor-control>> |
753 #+end_src | 752 #+end_src |
754 | 753 |
755 #+begin_src clojure :tangle ../src/test/body.clj | 754 #+begin_src clojure :tangle ../src/cortex/test/body.clj |
756 <<test-body>> | 755 <<test-body>> |
757 #+end_src | 756 #+end_src |
758 | 757 |
759 | 758 |
760 | 759 |