annotate org/body.org @ 169:94b79c191fc7

renamed some functions in vision.org
author Robert McIntyre <rlm@mit.edu>
date Sat, 04 Feb 2012 04:23:32 -0700
parents 33278bf028e7
children 0b9ae09eaec3
rev   line source
rlm@0 1 #+title: The BODY!!!
rlm@0 2 #+author: Robert McIntyre
rlm@0 3 #+email: rlm@mit.edu
rlm@4 4 #+description: Simulating a body (movement, touch, propioception) in jMonkeyEngine3.
rlm@4 5 #+SETUPFILE: ../../aurellem/org/setup.org
rlm@4 6 #+INCLUDE: ../../aurellem/org/level-0.org
rlm@4 7
rlm@64 8 * Proprioception
rlm@66 9 #+name: proprioception
rlm@0 10 #+begin_src clojure
rlm@44 11 (ns cortex.body
rlm@160 12 (:use (cortex world util sense))
rlm@64 13 (:import
rlm@64 14 com.jme3.math.Vector3f
rlm@64 15 com.jme3.math.Quaternion
rlm@64 16 com.jme3.math.Vector2f
rlm@64 17 com.jme3.math.Matrix3f
rlm@135 18 com.jme3.bullet.control.RigidBodyControl
rlm@135 19 com.jme3.collision.CollisionResults
rlm@150 20 com.jme3.bounding.BoundingBox
rlm@150 21 com.jme3.scene.Node))
rlm@133 22
rlm@160 23 (cortex.import/mega-import-jme3)
rlm@160 24
rlm@135 25 (defn jme-to-blender
rlm@135 26 "Convert from JME coordinates to Blender coordinates"
rlm@135 27 [#^Vector3f in]
rlm@135 28 (Vector3f. (.getX in)
rlm@135 29 (- (.getZ in))
rlm@135 30 (.getY in)))
rlm@135 31
rlm@160 32 (defn blender-to-jme
rlm@160 33 "Convert from Blender coordinates to JME coordinates"
rlm@160 34 [#^Vector3f in]
rlm@160 35 (Vector3f. (.getX in)
rlm@160 36 (.getZ in)
rlm@160 37 (- (.getY in))))
rlm@160 38
rlm@160 39
rlm@135 40 (defn joint-targets
rlm@135 41 "Return the two closest two objects to the joint object, ordered
rlm@135 42 from bottom to top according to the joint's rotation."
rlm@135 43 [#^Node parts #^Node joint]
rlm@135 44 (loop [radius (float 0.01)]
rlm@135 45 (let [results (CollisionResults.)]
rlm@135 46 (.collideWith
rlm@135 47 parts
rlm@135 48 (BoundingBox. (.getWorldTranslation joint)
rlm@135 49 radius radius radius)
rlm@135 50 results)
rlm@135 51 (let [targets
rlm@135 52 (distinct
rlm@135 53 (map #(.getGeometry %) results))]
rlm@135 54 (if (>= (count targets) 2)
rlm@135 55 (sort-by
rlm@135 56 #(let [v
rlm@135 57 (jme-to-blender
rlm@135 58 (.mult
rlm@135 59 (.inverse (.getWorldRotation joint))
rlm@135 60 (.subtract (.getWorldTranslation %)
rlm@135 61 (.getWorldTranslation joint))))]
rlm@135 62 (println-repl (.getName %) ":" v)
rlm@135 63 (.dot (Vector3f. 1 1 1)
rlm@135 64 v))
rlm@135 65 (take 2 targets))
rlm@135 66 (recur (float (* radius 2))))))))
rlm@135 67
rlm@135 68 (defn creature-joints
rlm@135 69 "Return the children of the creature's \"joints\" node."
rlm@135 70 [#^Node creature]
rlm@135 71 (if-let [joint-node (.getChild creature "joints")]
rlm@135 72 (seq (.getChildren joint-node))
rlm@135 73 (do (println-repl "could not find JOINTS node") [])))
rlm@135 74
rlm@160 75 (defmulti joint-dispatch
rlm@160 76 "Translate blender pseudo-joints into real JME joints."
rlm@160 77 (fn [constraints & _]
rlm@160 78 (:type constraints)))
rlm@141 79
rlm@160 80 (defmethod joint-dispatch :point
rlm@160 81 [constraints control-a control-b pivot-a pivot-b rotation]
rlm@160 82 (println-repl "creating POINT2POINT joint")
rlm@160 83 ;; bullet's point2point joints are BROKEN, so we must use the
rlm@160 84 ;; generic 6DOF joint instead of an actual Point2Point joint!
rlm@141 85
rlm@160 86 ;; should be able to do this:
rlm@160 87 (comment
rlm@160 88 (Point2PointJoint.
rlm@160 89 control-a
rlm@160 90 control-b
rlm@160 91 pivot-a
rlm@160 92 pivot-b))
rlm@141 93
rlm@160 94 ;; but instead we must do this:
rlm@160 95 (println-repl "substuting 6DOF joint for POINT2POINT joint!")
rlm@160 96 (doto
rlm@160 97 (SixDofJoint.
rlm@160 98 control-a
rlm@160 99 control-b
rlm@160 100 pivot-a
rlm@160 101 pivot-b
rlm@160 102 false)
rlm@160 103 (.setLinearLowerLimit Vector3f/ZERO)
rlm@160 104 (.setLinearUpperLimit Vector3f/ZERO)
rlm@160 105 ;;(.setAngularLowerLimit (Vector3f. 1 1 1))
rlm@160 106 ;;(.setAngularUpperLimit (Vector3f. 0 0 0))
rlm@141 107
rlm@160 108 ))
rlm@160 109
rlm@160 110
rlm@160 111 (defmethod joint-dispatch :hinge
rlm@160 112 [constraints control-a control-b pivot-a pivot-b rotation]
rlm@160 113 (println-repl "creating HINGE joint")
rlm@160 114 (let [axis
rlm@160 115 (if-let
rlm@160 116 [axis (:axis constraints)]
rlm@160 117 axis
rlm@160 118 Vector3f/UNIT_X)
rlm@160 119 [limit-1 limit-2] (:limit constraints)
rlm@160 120 hinge-axis
rlm@160 121 (.mult
rlm@160 122 rotation
rlm@160 123 (blender-to-jme axis))]
rlm@160 124 (doto
rlm@160 125 (HingeJoint.
rlm@160 126 control-a
rlm@160 127 control-b
rlm@160 128 pivot-a
rlm@160 129 pivot-b
rlm@160 130 hinge-axis
rlm@160 131 hinge-axis)
rlm@160 132 (.setLimit limit-1 limit-2))))
rlm@160 133
rlm@160 134 (defmethod joint-dispatch :cone
rlm@160 135 [constraints control-a control-b pivot-a pivot-b rotation]
rlm@160 136 (let [limit-xz (:limit-xz constraints)
rlm@160 137 limit-xy (:limit-xy constraints)
rlm@160 138 twist (:twist constraints)]
rlm@160 139
rlm@160 140 (println-repl "creating CONE joint")
rlm@160 141 (println-repl rotation)
rlm@160 142 (println-repl
rlm@160 143 "UNIT_X --> " (.mult rotation (Vector3f. 1 0 0)))
rlm@160 144 (println-repl
rlm@160 145 "UNIT_Y --> " (.mult rotation (Vector3f. 0 1 0)))
rlm@160 146 (println-repl
rlm@160 147 "UNIT_Z --> " (.mult rotation (Vector3f. 0 0 1)))
rlm@160 148 (doto
rlm@160 149 (ConeJoint.
rlm@160 150 control-a
rlm@160 151 control-b
rlm@160 152 pivot-a
rlm@160 153 pivot-b
rlm@160 154 rotation
rlm@160 155 rotation)
rlm@160 156 (.setLimit (float limit-xz)
rlm@160 157 (float limit-xy)
rlm@160 158 (float twist)))))
rlm@160 159
rlm@160 160 (defn connect
rlm@160 161 "here are some examples:
rlm@160 162 {:type :point}
rlm@160 163 {:type :hinge :limit [0 (/ Math/PI 2)] :axis (Vector3f. 0 1 0)}
rlm@160 164 (:axis defaults to (Vector3f. 1 0 0) if not provided for hinge joints)
rlm@160 165
rlm@160 166 {:type :cone :limit-xz 0]
rlm@160 167 :limit-xy 0]
rlm@160 168 :twist 0]} (use XZY rotation mode in blender!)"
rlm@160 169 [#^Node obj-a #^Node obj-b #^Node joint]
rlm@160 170 (let [control-a (.getControl obj-a RigidBodyControl)
rlm@160 171 control-b (.getControl obj-b RigidBodyControl)
rlm@160 172 joint-center (.getWorldTranslation joint)
rlm@160 173 joint-rotation (.toRotationMatrix (.getWorldRotation joint))
rlm@160 174 pivot-a (world-to-local obj-a joint-center)
rlm@160 175 pivot-b (world-to-local obj-b joint-center)]
rlm@160 176
rlm@160 177 (if-let [constraints
rlm@160 178 (map-vals
rlm@160 179 eval
rlm@160 180 (read-string
rlm@160 181 (meta-data joint "joint")))]
rlm@160 182 ;; A side-effect of creating a joint registers
rlm@160 183 ;; it with both physics objects which in turn
rlm@160 184 ;; will register the joint with the physics system
rlm@160 185 ;; when the simulation is started.
rlm@160 186 (do
rlm@160 187 (println-repl "creating joint between"
rlm@160 188 (.getName obj-a) "and" (.getName obj-b))
rlm@160 189 (joint-dispatch constraints
rlm@160 190 control-a control-b
rlm@160 191 pivot-a pivot-b
rlm@160 192 joint-rotation))
rlm@160 193 (println-repl "could not find joint meta-data!"))))
rlm@160 194
rlm@160 195
rlm@160 196
rlm@160 197
rlm@160 198 (defn assemble-creature [#^Node pieces joints]
rlm@160 199 (dorun
rlm@160 200 (map
rlm@160 201 (fn [geom]
rlm@160 202 (let [physics-control
rlm@160 203 (RigidBodyControl.
rlm@160 204 (HullCollisionShape.
rlm@160 205 (.getMesh geom))
rlm@160 206 (if-let [mass (meta-data geom "mass")]
rlm@160 207 (do
rlm@160 208 (println-repl
rlm@160 209 "setting" (.getName geom) "mass to" (float mass))
rlm@160 210 (float mass))
rlm@160 211 (float 1)))]
rlm@160 212
rlm@160 213 (.addControl geom physics-control)))
rlm@160 214 (filter #(isa? (class %) Geometry )
rlm@160 215 (node-seq pieces))))
rlm@160 216 (dorun
rlm@160 217 (map
rlm@160 218 (fn [joint]
rlm@160 219 (let [[obj-a obj-b] (joint-targets pieces joint)]
rlm@160 220 (connect obj-a obj-b joint)))
rlm@160 221 joints))
rlm@160 222 pieces)
rlm@160 223
rlm@160 224
rlm@160 225 ;; TODO implement a function that adds joints in the style of the
rlm@160 226 ;; other sense functions
rlm@160 227
rlm@160 228
rlm@141 229
rlm@145 230 (import java.awt.image.BufferedImage)
rlm@141 231
rlm@145 232 (defn draw-sprite [image sprite x y color ]
rlm@145 233 (dorun
rlm@145 234 (for [[u v] sprite]
rlm@145 235 (.setRGB image (+ u x) (+ v y) color))))
rlm@145 236
rlm@145 237 (defn view-angle
rlm@145 238 "create a debug view of an angle"
rlm@145 239 [color]
rlm@145 240 (let [image (BufferedImage. 50 50 BufferedImage/TYPE_INT_RGB)
rlm@145 241 previous (atom [25 25])
rlm@145 242 sprite [[0 0] [0 1]
rlm@145 243 [0 -1] [-1 0] [1 0]]]
rlm@145 244 (fn [angle]
rlm@145 245 (let [angle (float angle)]
rlm@145 246 (let [position
rlm@145 247 [(+ 25 (int (* 20 (Math/cos angle))))
rlm@145 248 (+ 25 (int (* -20 (Math/sin angle))))]]
rlm@145 249 (draw-sprite image sprite (@previous 0) (@previous 1) 0x000000)
rlm@145 250 (draw-sprite image sprite (position 0) (position 1) color)
rlm@145 251 (reset! previous position))
rlm@145 252 image))))
rlm@145 253
rlm@145 254 (defn proprioception-debug-window
rlm@145 255 []
rlm@145 256 (let [heading (view-angle 0xFF0000)
rlm@145 257 pitch (view-angle 0x00FF00)
rlm@145 258 roll (view-angle 0xFFFFFF)
rlm@145 259 v-heading (view-image)
rlm@145 260 v-pitch (view-image)
rlm@145 261 v-roll (view-image)
rlm@145 262 ]
rlm@145 263 (fn [prop-data]
rlm@145 264 (dorun
rlm@145 265 (map
rlm@145 266 (fn [[h p r]]
rlm@145 267 (v-heading (heading h))
rlm@145 268 (v-pitch (pitch p))
rlm@145 269 (v-roll (roll r)))
rlm@145 270 prop-data)))))
rlm@145 271
rlm@145 272
rlm@64 273 #+end_src
rlm@63 274
rlm@133 275 #+results: proprioception
rlm@145 276 : #'cortex.body/proprioception-debug-window
rlm@133 277
rlm@65 278 * Motor Control
rlm@66 279 #+name: motor-control
rlm@64 280 #+begin_src clojure
rlm@64 281 (in-ns 'cortex.body)
rlm@63 282
rlm@63 283 ;; surprisingly enough, terristerial creatures only move by using
rlm@63 284 ;; torque applied about their joints. There's not a single straight
rlm@63 285 ;; line of force in the human body at all! (A straight line of force
rlm@63 286 ;; would correspond to some sort of jet or rocket propulseion.)
rlm@63 287
rlm@63 288 (defn vector-motor-control
rlm@63 289 "Create a function that accepts a sequence of Vector3f objects that
rlm@63 290 describe the torque to be applied to each part of the body."
rlm@63 291 [body]
rlm@63 292 (let [nodes (node-seq body)
rlm@63 293 controls (keep #(.getControl % RigidBodyControl) nodes)]
rlm@63 294 (fn [torques]
rlm@63 295 (map #(.applyTorque %1 %2)
rlm@63 296 controls torques))))
rlm@64 297 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rlm@64 298 #+end_src
rlm@64 299
rlm@64 300 ## note -- might want to add a lower dimensional, discrete version of
rlm@64 301 ## this if it proves useful from a x-modal clustering perspective.
rlm@63 302
rlm@64 303 * Examples
rlm@63 304
rlm@69 305 #+name: test-body
rlm@64 306 #+begin_src clojure
rlm@69 307 (ns cortex.test.body
rlm@64 308 (:use (cortex world util body))
rlm@135 309 (:require cortex.silly)
rlm@64 310 (:import
rlm@64 311 com.jme3.math.Vector3f
rlm@64 312 com.jme3.math.ColorRGBA
rlm@64 313 com.jme3.bullet.joints.Point2PointJoint
rlm@64 314 com.jme3.bullet.control.RigidBodyControl
rlm@145 315 com.jme3.system.NanoTimer
rlm@145 316 com.jme3.math.Quaternion))
rlm@63 317
rlm@64 318 (defn worm-segments
rlm@64 319 "Create multiple evenly spaced box segments. They're fabulous!"
rlm@64 320 [segment-length num-segments interstitial-space radius]
rlm@64 321 (letfn [(nth-segment
rlm@64 322 [n]
rlm@64 323 (box segment-length radius radius :mass 0.1
rlm@64 324 :position
rlm@64 325 (Vector3f.
rlm@64 326 (* 2 n (+ interstitial-space segment-length)) 0 0)
rlm@64 327 :name (str "worm-segment" n)
rlm@64 328 :color (ColorRGBA/randomColor)))]
rlm@64 329 (map nth-segment (range num-segments))))
rlm@63 330
rlm@64 331 (defn connect-at-midpoint
rlm@64 332 "Connect two physics objects with a Point2Point joint constraint at
rlm@64 333 the point equidistant from both objects' centers."
rlm@64 334 [segmentA segmentB]
rlm@64 335 (let [centerA (.getWorldTranslation segmentA)
rlm@64 336 centerB (.getWorldTranslation segmentB)
rlm@64 337 midpoint (.mult (.add centerA centerB) (float 0.5))
rlm@64 338 pivotA (.subtract midpoint centerA)
rlm@64 339 pivotB (.subtract midpoint centerB)
rlm@64 340
rlm@64 341 ;; A side-effect of creating a joint registers
rlm@64 342 ;; it with both physics objects which in turn
rlm@64 343 ;; will register the joint with the physics system
rlm@64 344 ;; when the simulation is started.
rlm@64 345 joint (Point2PointJoint.
rlm@64 346 (.getControl segmentA RigidBodyControl)
rlm@64 347 (.getControl segmentB RigidBodyControl)
rlm@64 348 pivotA
rlm@64 349 pivotB)]
rlm@64 350 segmentB))
rlm@63 351
rlm@64 352 (defn eve-worm
rlm@72 353 "Create a worm-like body bound by invisible joint constraints."
rlm@64 354 []
rlm@64 355 (let [segments (worm-segments 0.2 5 0.1 0.1)]
rlm@64 356 (dorun (map (partial apply connect-at-midpoint)
rlm@64 357 (partition 2 1 segments)))
rlm@64 358 (nodify "worm" segments)))
rlm@63 359
rlm@64 360 (defn worm-pattern
rlm@64 361 "This is a simple, mindless motor control pattern that drives the
rlm@64 362 second segment of the worm's body at an offset angle with
rlm@64 363 sinusoidally varying strength."
rlm@64 364 [time]
rlm@64 365 (let [angle (* Math/PI (/ 9 20))
rlm@63 366 direction (Vector3f. 0 (Math/sin angle) (Math/cos angle))]
rlm@63 367 [Vector3f/ZERO
rlm@63 368 (.mult
rlm@63 369 direction
rlm@63 370 (float (* 2 (Math/sin (* Math/PI 2 (/ (rem time 300 ) 300))))))
rlm@63 371 Vector3f/ZERO
rlm@63 372 Vector3f/ZERO
rlm@63 373 Vector3f/ZERO]))
rlm@60 374
rlm@64 375 (defn test-motor-control
rlm@69 376 "Testing motor-control:
rlm@69 377 You should see a multi-segmented worm-like object fall onto the
rlm@64 378 table and begin writhing and moving."
rlm@60 379 []
rlm@64 380 (let [worm (eve-worm)
rlm@60 381 time (atom 0)
rlm@63 382 worm-motor-map (vector-motor-control worm)]
rlm@60 383 (world
rlm@60 384 (nodify [worm
rlm@60 385 (box 10 0.5 10 :position (Vector3f. 0 -5 0) :mass 0
rlm@60 386 :color ColorRGBA/Gray)])
rlm@60 387 standard-debug-controls
rlm@60 388 (fn [world]
rlm@60 389 (enable-debug world)
rlm@60 390 (light-up-everything world)
rlm@63 391 (comment
rlm@63 392 (com.aurellem.capture.Capture/captureVideo
rlm@63 393 world
rlm@63 394 (file-str "/home/r/proj/cortex/tmp/moving-worm")))
rlm@63 395 )
rlm@60 396
rlm@60 397 (fn [_ _]
rlm@60 398 (swap! time inc)
rlm@64 399 (Thread/sleep 20)
rlm@60 400 (dorun (worm-motor-map
rlm@60 401 (worm-pattern @time)))))))
rlm@60 402
rlm@130 403
rlm@135 404
rlm@130 405 (defn join-at-point [obj-a obj-b world-pivot]
rlm@130 406 (cortex.silly/joint-dispatch
rlm@130 407 {:type :point}
rlm@130 408 (.getControl obj-a RigidBodyControl)
rlm@130 409 (.getControl obj-b RigidBodyControl)
rlm@130 410 (cortex.silly/world-to-local obj-a world-pivot)
rlm@130 411 (cortex.silly/world-to-local obj-b world-pivot)
rlm@130 412 nil
rlm@130 413 ))
rlm@130 414
rlm@133 415 (import com.jme3.bullet.collision.PhysicsCollisionObject)
rlm@130 416
rlm@130 417 (defn blab-* []
rlm@130 418 (let [hand (box 0.5 0.2 0.2 :position (Vector3f. 0 0 0)
rlm@130 419 :mass 0 :color ColorRGBA/Green)
rlm@130 420 finger (box 0.5 0.2 0.2 :position (Vector3f. 2.4 0 0)
rlm@130 421 :mass 1 :color ColorRGBA/Red)
rlm@130 422 connection-point (Vector3f. 1.2 0 0)
rlm@130 423 root (nodify [hand finger])]
rlm@130 424
rlm@130 425 (join-at-point hand finger (Vector3f. 1.2 0 0))
rlm@130 426
rlm@130 427 (.setCollisionGroup
rlm@130 428 (.getControl hand RigidBodyControl)
rlm@130 429 PhysicsCollisionObject/COLLISION_GROUP_NONE)
rlm@130 430 (world
rlm@130 431 root
rlm@130 432 standard-debug-controls
rlm@130 433 (fn [world]
rlm@130 434 (enable-debug world)
rlm@130 435 (.setTimer world (com.aurellem.capture.RatchetTimer. 60))
rlm@130 436 (set-gravity world Vector3f/ZERO)
rlm@130 437 )
rlm@130 438 no-op)))
rlm@133 439 (comment
rlm@133 440
rlm@133 441 (defn proprioception-debug-window
rlm@133 442 []
rlm@133 443 (let [time (atom 0)]
rlm@133 444 (fn [prop-data]
rlm@133 445 (if (= 0 (rem (swap! time inc) 40))
rlm@133 446 (println-repl prop-data)))))
rlm@133 447 )
rlm@133 448
rlm@131 449 (comment
rlm@131 450 (dorun
rlm@131 451 (map
rlm@131 452 (comp
rlm@131 453 println-repl
rlm@131 454 (fn [[p y r]]
rlm@131 455 (format
rlm@131 456 "pitch: %1.2f\nyaw: %1.2f\nroll: %1.2f\n"
rlm@131 457 p y r)))
rlm@131 458 prop-data)))
rlm@131 459
rlm@130 460
rlm@130 461
rlm@137 462
rlm@64 463 (defn test-proprioception
rlm@69 464 "Testing proprioception:
rlm@69 465 You should see two foating bars, and a printout of pitch, yaw, and
rlm@64 466 roll. Pressing key-r/key-t should move the blue bar up and down and
rlm@64 467 change only the value of pitch. key-f/key-g moves it side to side
rlm@64 468 and changes yaw. key-v/key-b will spin the blue segment clockwise
rlm@64 469 and counterclockwise, and only affect roll."
rlm@60 470 []
rlm@145 471 (let [hand (box 0.2 1 0.2 :position (Vector3f. 0 0 0)
rlm@142 472 :mass 0 :color ColorRGBA/Green :name "hand")
rlm@145 473 finger (box 0.2 1 0.2 :position (Vector3f. 0 2.4 0)
rlm@132 474 :mass 1 :color ColorRGBA/Red :name "finger")
rlm@133 475 joint-node (box 0.1 0.05 0.05 :color ColorRGBA/Yellow
rlm@145 476 :position (Vector3f. 0 1.2 0)
rlm@145 477 :rotation (doto (Quaternion.)
rlm@145 478 (.fromAngleAxis
rlm@145 479 (/ Math/PI 2)
rlm@145 480 (Vector3f. 0 0 1)))
rlm@133 481 :physical? false)
rlm@145 482 joint (join-at-point hand finger (Vector3f. 0 1.2 0 ))
rlm@135 483 creature (nodify [hand finger joint-node])
rlm@145 484 finger-control (.getControl finger RigidBodyControl)
rlm@145 485 hand-control (.getControl hand RigidBodyControl)]
rlm@145 486
rlm@145 487
rlm@145 488 (let
rlm@135 489 ;; *******************************************
rlm@137 490
rlm@145 491 [floor (box 10 10 10 :position (Vector3f. 0 -15 0)
rlm@135 492 :mass 0 :color ColorRGBA/Gray)
rlm@137 493
rlm@137 494 root (nodify [creature floor])
rlm@133 495 prop (joint-proprioception creature joint-node)
rlm@139 496 prop-view (proprioception-debug-window)
rlm@139 497
rlm@139 498 controls
rlm@139 499 (merge standard-debug-controls
rlm@140 500 {"key-o"
rlm@139 501 (fn [_ _] (.setEnabled finger-control true))
rlm@140 502 "key-p"
rlm@139 503 (fn [_ _] (.setEnabled finger-control false))
rlm@140 504 "key-k"
rlm@140 505 (fn [_ _] (.setEnabled hand-control true))
rlm@140 506 "key-l"
rlm@140 507 (fn [_ _] (.setEnabled hand-control false))
rlm@139 508 "key-i"
rlm@139 509 (fn [world _] (set-gravity world (Vector3f. 0 0 0)))
rlm@142 510 "key-period"
rlm@142 511 (fn [world _]
rlm@142 512 (.setEnabled finger-control false)
rlm@142 513 (.setEnabled hand-control false)
rlm@142 514 (.rotate creature (doto (Quaternion.)
rlm@142 515 (.fromAngleAxis
rlm@142 516 (float (/ Math/PI 15))
rlm@142 517 (Vector3f. 0 0 -1))))
rlm@142 518
rlm@142 519 (.setEnabled finger-control true)
rlm@142 520 (.setEnabled hand-control true)
rlm@142 521 (set-gravity world (Vector3f. 0 0 0))
rlm@142 522 )
rlm@142 523
rlm@142 524
rlm@139 525 }
rlm@139 526 )
rlm@130 527
rlm@139 528 ]
rlm@139 529 (comment
rlm@139 530 (.setCollisionGroup
rlm@139 531 (.getControl hand RigidBodyControl)
rlm@139 532 PhysicsCollisionObject/COLLISION_GROUP_NONE)
rlm@139 533 )
rlm@140 534 (apply
rlm@140 535 world
rlm@140 536 (with-movement
rlm@140 537 hand
rlm@140 538 ["key-y" "key-u" "key-h" "key-j" "key-n" "key-m"]
rlm@140 539 [10 10 10 10 1 1]
rlm@140 540 (with-movement
rlm@140 541 finger
rlm@140 542 ["key-r" "key-t" "key-f" "key-g" "key-v" "key-b"]
rlm@145 543 [1 1 10 10 10 10]
rlm@140 544 [root
rlm@140 545 controls
rlm@140 546 (fn [world]
rlm@140 547 (.setTimer world (com.aurellem.capture.RatchetTimer. 60))
rlm@140 548 (set-gravity world (Vector3f. 0 0 0))
rlm@140 549 (light-up-everything world))
rlm@145 550 (fn [_ _] (prop-view (list (prop))))]))))))
rlm@138 551
rlm@64 552 #+end_src
rlm@56 553
rlm@130 554 #+results: test-body
rlm@130 555 : #'cortex.test.body/test-proprioception
rlm@130 556
rlm@60 557
rlm@63 558 * COMMENT code-limbo
rlm@61 559 #+begin_src clojure
rlm@61 560 ;;(.loadModel
rlm@61 561 ;; (doto (asset-manager)
rlm@61 562 ;; (.registerLoader BlenderModelLoader (into-array String ["blend"])))
rlm@61 563 ;; "Models/person/person.blend")
rlm@61 564
rlm@64 565
rlm@64 566 (defn load-blender-model
rlm@64 567 "Load a .blend file using an asset folder relative path."
rlm@64 568 [^String model]
rlm@64 569 (.loadModel
rlm@64 570 (doto (asset-manager)
rlm@64 571 (.registerLoader BlenderModelLoader (into-array String ["blend"])))
rlm@64 572 model))
rlm@64 573
rlm@64 574
rlm@61 575 (defn view-model [^String model]
rlm@61 576 (view
rlm@61 577 (.loadModel
rlm@61 578 (doto (asset-manager)
rlm@61 579 (.registerLoader BlenderModelLoader (into-array String ["blend"])))
rlm@61 580 model)))
rlm@61 581
rlm@61 582 (defn load-blender-scene [^String model]
rlm@61 583 (.loadModel
rlm@61 584 (doto (asset-manager)
rlm@61 585 (.registerLoader BlenderLoader (into-array String ["blend"])))
rlm@61 586 model))
rlm@61 587
rlm@61 588 (defn worm
rlm@61 589 []
rlm@61 590 (.loadModel (asset-manager) "Models/anim2/Cube.mesh.xml"))
rlm@61 591
rlm@61 592 (defn oto
rlm@61 593 []
rlm@61 594 (.loadModel (asset-manager) "Models/Oto/Oto.mesh.xml"))
rlm@61 595
rlm@61 596 (defn sinbad
rlm@61 597 []
rlm@61 598 (.loadModel (asset-manager) "Models/Sinbad/Sinbad.mesh.xml"))
rlm@61 599
rlm@61 600 (defn worm-blender
rlm@61 601 []
rlm@61 602 (first (seq (.getChildren (load-blender-model
rlm@61 603 "Models/anim2/simple-worm.blend")))))
rlm@61 604
rlm@61 605 (defn body
rlm@61 606 "given a node with a SkeletonControl, will produce a body sutiable
rlm@61 607 for AI control with movement and proprioception."
rlm@61 608 [node]
rlm@61 609 (let [skeleton-control (.getControl node SkeletonControl)
rlm@61 610 krc (KinematicRagdollControl.)]
rlm@61 611 (comment
rlm@61 612 (dorun
rlm@61 613 (map #(.addBoneName krc %)
rlm@61 614 ["mid2" "tail" "head" "mid1" "mid3" "mid4" "Dummy-Root" ""]
rlm@61 615 ;;"mid2" "mid3" "tail" "head"]
rlm@61 616 )))
rlm@61 617 (.addControl node krc)
rlm@61 618 (.setRagdollMode krc)
rlm@61 619 )
rlm@61 620 node
rlm@61 621 )
rlm@61 622 (defn show-skeleton [node]
rlm@61 623 (let [sd
rlm@61 624
rlm@61 625 (doto
rlm@61 626 (SkeletonDebugger. "aurellem-skel-debug"
rlm@61 627 (skel node))
rlm@61 628 (.setMaterial (green-x-ray)))]
rlm@61 629 (.attachChild node sd)
rlm@61 630 node))
rlm@61 631
rlm@61 632
rlm@61 633
rlm@61 634 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rlm@61 635
rlm@61 636 ;; this could be a good way to give objects special properties like
rlm@61 637 ;; being eyes and the like
rlm@61 638
rlm@61 639 (.getUserData
rlm@61 640 (.getChild
rlm@61 641 (load-blender-model "Models/property/test.blend") 0)
rlm@61 642 "properties")
rlm@61 643
rlm@61 644 ;; the properties are saved along with the blender file.
rlm@61 645 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rlm@61 646
rlm@61 647
rlm@61 648
rlm@61 649
rlm@61 650 (defn init-debug-skel-node
rlm@61 651 [f debug-node skeleton]
rlm@61 652 (let [bones
rlm@61 653 (map #(.getBone skeleton %)
rlm@61 654 (range (.getBoneCount skeleton)))]
rlm@61 655 (dorun (map #(.setUserControl % true) bones))
rlm@61 656 (dorun (map (fn [b]
rlm@61 657 (println (.getName b)
rlm@61 658 " -- " (f b)))
rlm@61 659 bones))
rlm@61 660 (dorun
rlm@61 661 (map #(.attachChild
rlm@61 662 debug-node
rlm@61 663 (doto
rlm@61 664 (sphere 0.1
rlm@61 665 :position (f %)
rlm@61 666 :physical? false)
rlm@61 667 (.setMaterial (green-x-ray))))
rlm@61 668 bones)))
rlm@61 669 debug-node)
rlm@61 670
rlm@61 671 (import jme3test.bullet.PhysicsTestHelper)
rlm@61 672
rlm@61 673
rlm@61 674 (defn test-zzz [the-worm world value]
rlm@61 675 (if (not value)
rlm@61 676 (let [skeleton (skel the-worm)]
rlm@61 677 (println-repl "enabling bones")
rlm@61 678 (dorun
rlm@61 679 (map
rlm@61 680 #(.setUserControl (.getBone skeleton %) true)
rlm@61 681 (range (.getBoneCount skeleton))))
rlm@61 682
rlm@61 683
rlm@61 684 (let [b (.getBone skeleton 2)]
rlm@61 685 (println-repl "moving " (.getName b))
rlm@61 686 (println-repl (.getLocalPosition b))
rlm@61 687 (.setUserTransforms b
rlm@61 688 Vector3f/UNIT_X
rlm@61 689 Quaternion/IDENTITY
rlm@61 690 ;;(doto (Quaternion.)
rlm@61 691 ;; (.fromAngles (/ Math/PI 2)
rlm@61 692 ;; 0
rlm@61 693 ;; 0
rlm@61 694
rlm@61 695 (Vector3f. 1 1 1))
rlm@61 696 )
rlm@61 697
rlm@61 698 (println-repl "hi! <3"))))
rlm@61 699
rlm@61 700
rlm@61 701 (defn test-ragdoll []
rlm@61 702
rlm@61 703 (let [the-worm
rlm@61 704
rlm@61 705 ;;(.loadModel (asset-manager) "Models/anim2/Cube.mesh.xml")
rlm@61 706 (doto (show-skeleton (worm-blender))
rlm@61 707 (.setLocalTranslation (Vector3f. 0 10 0))
rlm@61 708 ;;(worm)
rlm@61 709 ;;(oto)
rlm@61 710 ;;(sinbad)
rlm@61 711 )
rlm@61 712 ]
rlm@61 713
rlm@61 714
rlm@61 715 (.start
rlm@61 716 (world
rlm@61 717 (doto (Node.)
rlm@61 718 (.attachChild the-worm))
rlm@61 719 {"key-return" (fire-cannon-ball)
rlm@61 720 "key-space" (partial test-zzz the-worm)
rlm@61 721 }
rlm@61 722 (fn [world]
rlm@61 723 (light-up-everything world)
rlm@61 724 (PhysicsTestHelper/createPhysicsTestWorld
rlm@61 725 (.getRootNode world)
rlm@61 726 (asset-manager)
rlm@61 727 (.getPhysicsSpace
rlm@61 728 (.getState (.getStateManager world) BulletAppState)))
rlm@61 729 (set-gravity world Vector3f/ZERO)
rlm@61 730 ;;(.setTimer world (NanoTimer.))
rlm@61 731 ;;(org.lwjgl.input.Mouse/setGrabbed false)
rlm@61 732 )
rlm@61 733 no-op
rlm@61 734 )
rlm@61 735
rlm@61 736
rlm@61 737 )))
rlm@61 738
rlm@61 739
rlm@61 740 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rlm@61 741 ;;; here is the ragdoll stuff
rlm@61 742
rlm@61 743 (def worm-mesh (.getMesh (.getChild (worm-blender) 0)))
rlm@61 744 (def mesh worm-mesh)
rlm@61 745
rlm@61 746 (.getFloatBuffer mesh VertexBuffer$Type/Position)
rlm@61 747 (.getFloatBuffer mesh VertexBuffer$Type/BoneWeight)
rlm@61 748 (.getData (.getBuffer mesh VertexBuffer$Type/BoneIndex))
rlm@61 749
rlm@61 750
rlm@61 751 (defn position [index]
rlm@61 752 (.get
rlm@61 753 (.getFloatBuffer worm-mesh VertexBuffer$Type/Position)
rlm@61 754 index))
rlm@61 755
rlm@61 756 (defn bones [index]
rlm@61 757 (.get
rlm@61 758 (.getData (.getBuffer mesh VertexBuffer$Type/BoneIndex))
rlm@61 759 index))
rlm@61 760
rlm@61 761 (defn bone-weights [index]
rlm@61 762 (.get
rlm@61 763 (.getFloatBuffer mesh VertexBuffer$Type/BoneWeight)
rlm@61 764 index))
rlm@61 765
rlm@61 766
rlm@61 767
rlm@61 768 (defn vertex-bones [vertex]
rlm@61 769 (vec (map (comp int bones) (range (* vertex 4) (+ (* vertex 4) 4)))))
rlm@61 770
rlm@61 771 (defn vertex-weights [vertex]
rlm@61 772 (vec (map (comp float bone-weights) (range (* vertex 4) (+ (* vertex 4) 4)))))
rlm@61 773
rlm@61 774 (defn vertex-position [index]
rlm@61 775 (let [offset (* index 3)]
rlm@61 776 (Vector3f. (position offset)
rlm@61 777 (position (inc offset))
rlm@61 778 (position (inc(inc offset))))))
rlm@61 779
rlm@61 780 (def vertex-info (juxt vertex-position vertex-bones vertex-weights))
rlm@61 781
rlm@61 782 (defn bone-control-color [index]
rlm@61 783 (get {[1 0 0 0] ColorRGBA/Red
rlm@61 784 [1 2 0 0] ColorRGBA/Magenta
rlm@61 785 [2 0 0 0] ColorRGBA/Blue}
rlm@61 786 (vertex-bones index)
rlm@61 787 ColorRGBA/White))
rlm@61 788
rlm@61 789 (defn influence-color [index bone-num]
rlm@61 790 (get
rlm@61 791 {(float 0) ColorRGBA/Blue
rlm@61 792 (float 0.5) ColorRGBA/Green
rlm@61 793 (float 1) ColorRGBA/Red}
rlm@61 794 ;; find the weight of the desired bone
rlm@61 795 ((zipmap (vertex-bones index)(vertex-weights index))
rlm@61 796 bone-num)
rlm@61 797 ColorRGBA/Blue))
rlm@61 798
rlm@61 799 (def worm-vertices (set (map vertex-info (range 60))))
rlm@61 800
rlm@61 801
rlm@61 802 (defn test-info []
rlm@61 803 (let [points (Node.)]
rlm@61 804 (dorun
rlm@61 805 (map #(.attachChild points %)
rlm@61 806 (map #(sphere 0.01
rlm@61 807 :position (vertex-position %)
rlm@61 808 :color (influence-color % 1)
rlm@61 809 :physical? false)
rlm@61 810 (range 60))))
rlm@61 811 (view points)))
rlm@61 812
rlm@61 813
rlm@61 814 (defrecord JointControl [joint physics-space]
rlm@61 815 PhysicsControl
rlm@61 816 (setPhysicsSpace [this space]
rlm@61 817 (dosync
rlm@61 818 (ref-set (:physics-space this) space))
rlm@61 819 (.addJoint space (:joint this)))
rlm@61 820 (update [this tpf])
rlm@61 821 (setSpatial [this spatial])
rlm@61 822 (render [this rm vp])
rlm@61 823 (getPhysicsSpace [this] (deref (:physics-space this)))
rlm@61 824 (isEnabled [this] true)
rlm@61 825 (setEnabled [this state]))
rlm@61 826
rlm@61 827 (defn add-joint
rlm@61 828 "Add a joint to a particular object. When the object is added to the
rlm@61 829 PhysicsSpace of a simulation, the joint will also be added"
rlm@61 830 [object joint]
rlm@61 831 (let [control (JointControl. joint (ref nil))]
rlm@61 832 (.addControl object control))
rlm@61 833 object)
rlm@61 834
rlm@61 835
rlm@61 836 (defn hinge-world
rlm@61 837 []
rlm@61 838 (let [sphere1 (sphere)
rlm@61 839 sphere2 (sphere 1 :position (Vector3f. 3 3 3))
rlm@61 840 joint (Point2PointJoint.
rlm@61 841 (.getControl sphere1 RigidBodyControl)
rlm@61 842 (.getControl sphere2 RigidBodyControl)
rlm@61 843 Vector3f/ZERO (Vector3f. 3 3 3))]
rlm@61 844 (add-joint sphere1 joint)
rlm@61 845 (doto (Node. "hinge-world")
rlm@61 846 (.attachChild sphere1)
rlm@61 847 (.attachChild sphere2))))
rlm@61 848
rlm@61 849
rlm@61 850 (defn test-joint []
rlm@61 851 (view (hinge-world)))
rlm@61 852
rlm@61 853 ;; (defn copier-gen []
rlm@61 854 ;; (let [count (atom 0)]
rlm@61 855 ;; (fn [in]
rlm@61 856 ;; (swap! count inc)
rlm@61 857 ;; (clojure.contrib.duck-streams/copy
rlm@61 858 ;; in (File. (str "/home/r/tmp/mao-test/clojure-images/"
rlm@61 859 ;; ;;/home/r/tmp/mao-test/clojure-images
rlm@61 860 ;; (format "%08d.png" @count)))))))
rlm@61 861 ;; (defn decrease-framerate []
rlm@61 862 ;; (map
rlm@61 863 ;; (copier-gen)
rlm@61 864 ;; (sort
rlm@61 865 ;; (map first
rlm@61 866 ;; (partition
rlm@61 867 ;; 4
rlm@61 868 ;; (filter #(re-matches #".*.png$" (.getCanonicalPath %))
rlm@61 869 ;; (file-seq
rlm@61 870 ;; (file-str
rlm@61 871 ;; "/home/r/media/anime/mao-temp/images"))))))))
rlm@61 872
rlm@61 873
rlm@61 874
rlm@61 875 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rlm@61 876
rlm@61 877 (defn proprioception
rlm@61 878 "Create a proprioception map that reports the rotations of the
rlm@61 879 various limbs of the creature's body"
rlm@61 880 [creature]
rlm@61 881 [#^Node creature]
rlm@61 882 (let [
rlm@61 883 nodes (node-seq creature)
rlm@61 884 joints
rlm@61 885 (map
rlm@61 886 :joint
rlm@61 887 (filter
rlm@61 888 #(isa? (class %) JointControl)
rlm@61 889 (reduce
rlm@61 890 concat
rlm@61 891 (map (fn [node]
rlm@61 892 (map (fn [num] (.getControl node num))
rlm@61 893 (range (.getNumControls node))))
rlm@61 894 nodes))))]
rlm@61 895 (fn []
rlm@61 896 (reduce concat (map relative-positions (list (first joints)))))))
rlm@61 897
rlm@61 898
rlm@63 899 (defn skel [node]
rlm@63 900 (doto
rlm@63 901 (.getSkeleton
rlm@63 902 (.getControl node SkeletonControl))
rlm@63 903 ;; this is necessary to force the skeleton to have accurate world
rlm@63 904 ;; transforms before it is rendered to the screen.
rlm@63 905 (.resetAndUpdate)))
rlm@63 906
rlm@63 907 (defn green-x-ray []
rlm@63 908 (doto (Material. (asset-manager)
rlm@63 909 "Common/MatDefs/Misc/Unshaded.j3md")
rlm@63 910 (.setColor "Color" ColorRGBA/Green)
rlm@63 911 (-> (.getAdditionalRenderState)
rlm@63 912 (.setDepthTest false))))
rlm@63 913
rlm@63 914 (defn test-worm []
rlm@63 915 (.start
rlm@63 916 (world
rlm@63 917 (doto (Node.)
rlm@63 918 ;;(.attachChild (point-worm))
rlm@63 919 (.attachChild (load-blender-model
rlm@63 920 "Models/anim2/joint-worm.blend"))
rlm@63 921
rlm@63 922 (.attachChild (box 10 1 10
rlm@63 923 :position (Vector3f. 0 -2 0) :mass 0
rlm@63 924 :color (ColorRGBA/Gray))))
rlm@63 925 {
rlm@63 926 "key-space" (fire-cannon-ball)
rlm@63 927 }
rlm@63 928 (fn [world]
rlm@63 929 (enable-debug world)
rlm@63 930 (light-up-everything world)
rlm@63 931 ;;(.setTimer world (NanoTimer.))
rlm@63 932 )
rlm@63 933 no-op)))
rlm@63 934
rlm@63 935
rlm@63 936
rlm@63 937 ;; defunct movement stuff
rlm@63 938 (defn torque-controls [control]
rlm@63 939 (let [torques
rlm@63 940 (concat
rlm@63 941 (map #(Vector3f. 0 (Math/sin %) (Math/cos %))
rlm@63 942 (range 0 (* Math/PI 2) (/ (* Math/PI 2) 20)))
rlm@63 943 [Vector3f/UNIT_X])]
rlm@63 944 (map (fn [torque-axis]
rlm@63 945 (fn [torque]
rlm@63 946 (.applyTorque
rlm@63 947 control
rlm@63 948 (.mult (.mult (.getPhysicsRotation control)
rlm@63 949 torque-axis)
rlm@63 950 (float
rlm@63 951 (* (.getMass control) torque))))))
rlm@63 952 torques)))
rlm@63 953
rlm@63 954 (defn motor-map
rlm@63 955 "Take a creature and generate a function that will enable fine
rlm@63 956 grained control over all the creature's limbs."
rlm@63 957 [#^Node creature]
rlm@63 958 (let [controls (keep #(.getControl % RigidBodyControl)
rlm@63 959 (node-seq creature))
rlm@63 960 limb-controls (reduce concat (map torque-controls controls))
rlm@63 961 body-control (partial map #(%1 %2) limb-controls)]
rlm@63 962 body-control))
rlm@63 963
rlm@63 964 (defn test-motor-map
rlm@63 965 "see how torque works."
rlm@63 966 []
rlm@63 967 (let [finger (box 3 0.5 0.5 :position (Vector3f. 0 2 0)
rlm@63 968 :mass 1 :color ColorRGBA/Green)
rlm@63 969 motor-map (motor-map finger)]
rlm@63 970 (world
rlm@63 971 (nodify [finger
rlm@63 972 (box 10 0.5 10 :position (Vector3f. 0 -5 0) :mass 0
rlm@63 973 :color ColorRGBA/Gray)])
rlm@63 974 standard-debug-controls
rlm@63 975 (fn [world]
rlm@63 976 (set-gravity world Vector3f/ZERO)
rlm@63 977 (light-up-everything world)
rlm@63 978 (.setTimer world (NanoTimer.)))
rlm@63 979 (fn [_ _]
rlm@145 980 (dorun (motor-map [0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
rlm@145 981 0]))))))
rlm@145 982
rlm@145 983 (defn joint-proprioception [#^Node parts #^Node joint]
rlm@145 984 (let [[obj-a obj-b] (joint-targets parts joint)
rlm@145 985 joint-rot (.getWorldRotation joint)
rlm@145 986 pre-inv-a (.inverse (.getWorldRotation obj-a))
rlm@145 987 x (.mult pre-inv-a (.mult joint-rot Vector3f/UNIT_X))
rlm@145 988 y (.mult pre-inv-a (.mult joint-rot Vector3f/UNIT_Y))
rlm@145 989 z (.mult pre-inv-a (.mult joint-rot Vector3f/UNIT_Z))
rlm@145 990
rlm@145 991 x Vector3f/UNIT_Y
rlm@145 992 y Vector3f/UNIT_Z
rlm@145 993 z Vector3f/UNIT_X
rlm@145 994
rlm@145 995
rlm@145 996 tmp-rot-a (.getWorldRotation obj-a)]
rlm@145 997 (println-repl "x:" (.mult tmp-rot-a x))
rlm@145 998 (println-repl "y:" (.mult tmp-rot-a y))
rlm@145 999 (println-repl "z:" (.mult tmp-rot-a z))
rlm@145 1000 (println-repl "rot-a" (.getWorldRotation obj-a))
rlm@145 1001 (println-repl "rot-b" (.getWorldRotation obj-b))
rlm@145 1002 (println-repl "joint-rot" joint-rot)
rlm@145 1003 ;; this function will report proprioceptive information for the
rlm@145 1004 ;; joint.
rlm@145 1005 (fn []
rlm@145 1006 ;; x is the "twist" axis, y and z are the "bend" axes
rlm@145 1007 (let [rot-a (.getWorldRotation obj-a)
rlm@145 1008 ;;inv-a (.inverse rot-a)
rlm@145 1009 rot-b (.getWorldRotation obj-b)
rlm@145 1010 ;;relative (.mult rot-b inv-a)
rlm@145 1011 basis (doto (Matrix3f.)
rlm@145 1012 (.setColumn 0 (.mult rot-a x))
rlm@145 1013 (.setColumn 1 (.mult rot-a y))
rlm@145 1014 (.setColumn 2 (.mult rot-a z)))
rlm@145 1015 rotation-about-joint
rlm@145 1016 (doto (Quaternion.)
rlm@145 1017 (.fromRotationMatrix
rlm@145 1018 (.mult (.invert basis)
rlm@145 1019 (.toRotationMatrix rot-b))))
rlm@145 1020 [yaw roll pitch]
rlm@145 1021 (seq (.toAngles rotation-about-joint nil))]
rlm@145 1022 ;;return euler angles of the quaternion around the new basis
rlm@145 1023 [yaw roll pitch]))))
rlm@145 1024
rlm@61 1025 #+end_src
rlm@0 1026
rlm@0 1027
rlm@0 1028
rlm@0 1029
rlm@0 1030
rlm@0 1031
rlm@0 1032
rlm@73 1033 * COMMENT generate Source
rlm@44 1034 #+begin_src clojure :tangle ../src/cortex/body.clj
rlm@64 1035 <<proprioception>>
rlm@64 1036 <<motor-control>>
rlm@0 1037 #+end_src
rlm@64 1038
rlm@69 1039 #+begin_src clojure :tangle ../src/cortex/test/body.clj
rlm@64 1040 <<test-body>>
rlm@64 1041 #+end_src
rlm@64 1042
rlm@64 1043
rlm@0 1044