Mercurial > cortex
comparison thesis/cortex.org @ 488:21b9dcec8d71
incorporate appendix.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 29 Mar 2014 20:33:35 -0400 |
parents | 6d460ac3f5d0 |
children | c816594fbbe6 |
comparison
equal
deleted
inserted
replaced
487:19b55aaf4462 | 488:21b9dcec8d71 |
---|---|
2323 file. The function returned by =movement-kernel= is also a sense | 2323 file. The function returned by =movement-kernel= is also a sense |
2324 function: it returns the percent of the total muscle strength that | 2324 function: it returns the percent of the total muscle strength that |
2325 is currently being employed. This is analogous to muscle tension | 2325 is currently being employed. This is analogous to muscle tension |
2326 in humans and completes the sense of proprioception begun in the | 2326 in humans and completes the sense of proprioception begun in the |
2327 last section. | 2327 last section. |
2328 | 2328 |
2329 ** COMMENT =CORTEX= brings complex creatures to life! | 2329 ** COMMENT =CORTEX= brings complex creatures to life! |
2330 | 2330 |
2331 The ultimate test of =CORTEX= is to create a creature with the full | 2331 The ultimate test of =CORTEX= is to create a creature with the full |
2332 gamut of senses and put it though its paces. | 2332 gamut of senses and put it though its paces. |
2333 | 2333 |
3244 # An anatomical joke: | 3244 # An anatomical joke: |
3245 # - Training | 3245 # - Training |
3246 # - Skeletal imitation | 3246 # - Skeletal imitation |
3247 # - Sensory fleshing-out | 3247 # - Sensory fleshing-out |
3248 # - Classification | 3248 # - Classification |
3249 #+BEGIN_LaTeX | |
3250 \appendix | |
3251 #+END_LaTeX | |
3252 * COMMENT Appendix: =CORTEX= User Guide | |
3253 | |
3254 Those who write a thesis should endeavor to make their code not only | |
3255 accessable, but actually useable, as a way to pay back the community | |
3256 that made the thesis possible in the first place. This thesis would | |
3257 not be possible without Free Software such as jMonkeyEngine3, | |
3258 Blender, clojure, emacs, ffmpeg, and many other tools. That is why I | |
3259 have included this user guide, in the hope that someone else might | |
3260 find =CORTEX= useful. | |
3261 | |
3262 ** Obtaining =CORTEX= | |
3263 | |
3264 You can get cortex from its mercurial repository at | |
3265 http://hg.bortreb.com/cortex. You may also download =CORTEX= | |
3266 releases at http://aurellem.org/cortex/releases/. As a condition of | |
3267 making this thesis, I have also provided Professor Winston the | |
3268 =CORTEX= source, and he knows how to run the demos and get started. | |
3269 You may also email me at =cortex@aurellem.org= and I may help where | |
3270 I can. | |
3271 | |
3272 ** Running =CORTEX= | |
3273 | |
3274 =CORTEX= comes with README and INSTALL files that will guide you | |
3275 through installation and running the test suite. In particular you | |
3276 should look at test =cortex.test= which contains test suites that | |
3277 run through all senses and multiple creatures. | |
3278 | |
3279 ** Creating creatures | |
3280 | |
3281 Creatures are created using /Blender/, a free 3D modeling program. | |
3282 You will need Blender version 2.6 when using the =CORTEX= included | |
3283 in this thesis. You create a =CORTEX= creature in a similiar manner | |
3284 to modeling anything in Blender, except that you also create | |
3285 several trees of empty nodes which define the creature's senses. | |
3286 | |
3287 *** Mass | |
3288 | |
3289 To give an object mass in =CORTEX=, add a ``mass'' metadata label | |
3290 to the object with the mass in jMonkeyEngine units. Note that | |
3291 setting the mass to 0 causes the object to be immovable. | |
3292 | |
3293 *** Joints | |
3294 | |
3295 Joints are created by creating an empty node named =joints= and | |
3296 then creating any number of empty child nodes to represent your | |
3297 creature's joints. The joint will automatically connect the | |
3298 closest two physical objects. It will help to set the empty node's | |
3299 display mode to ``Arrows'' so that you can clearly see the | |
3300 direction of the axes. | |
3301 | |
3302 Joint nodes should have the following metadata under the ``joint'' | |
3303 label: | |
3304 | |
3305 #+BEGIN_SRC clojure | |
3306 ;; ONE OF the following, under the label "joint": | |
3307 {:type :point} | |
3308 | |
3309 ;; OR | |
3310 | |
3311 {:type :hinge | |
3312 :limit [<limit-low> <limit-high>] | |
3313 :axis (Vector3f. <x> <y> <z>)} | |
3314 ;;(:axis defaults to (Vector3f. 1 0 0) if not provided for hinge joints) | |
3315 | |
3316 ;; OR | |
3317 | |
3318 {:type :cone | |
3319 :limit-xz <lim-xz> | |
3320 :limit-xy <lim-xy> | |
3321 :twist <lim-twist>} ;(use XZY rotation mode in blender!) | |
3322 #+END_SRC | |
3323 | |
3324 *** Eyes | |
3325 | |
3326 Eyes are created by creating an empty node named =eyes= and then | |
3327 creating any number of empty child nodes to represent your | |
3328 creature's eyes. | |
3329 | |
3330 Eye nodes should have the following metadata under the ``eye'' | |
3331 label: | |
3332 | |
3333 #+BEGIN_SRC clojure | |
3334 {:red <red-retina-definition> | |
3335 :blue <blue-retina-definition> | |
3336 :green <green-retina-definition> | |
3337 :all <all-retina-definition> | |
3338 (<0xrrggbb> <custom-retina-image>)... | |
3339 } | |
3340 #+END_SRC | |
3341 | |
3342 Any of the color channels may be omitted. You may also include | |
3343 your own color selectors, and in fact :red is equivalent to | |
3344 0xFF0000 and so forth. The eye will be placed at the same position | |
3345 as the empty node and will bind to the neatest physical object. | |
3346 The eye will point outward from the X-axis of the node, and ``up'' | |
3347 will be in the direction of the X-axis of the node. It will help | |
3348 to set the empty node's display mode to ``Arrows'' so that you can | |
3349 clearly see the direction of the axes. | |
3350 | |
3351 Each retina file should contain white pixels whever you want to be | |
3352 sensitive to your chosen color. If you want the entire field of | |
3353 view, specify :all of 0xFFFFFF and a retinal map that is entirely | |
3354 white. | |
3355 | |
3356 Here is a sample retinal map: | |
3357 | |
3358 #+caption: An example retinal profile image. White pixels are | |
3359 #+caption: photo-sensitive elements. The distribution of white | |
3360 #+caption: pixels is denser in the middle and falls off at the | |
3361 #+caption: edges and is inspired by the human retina. | |
3362 #+name: retina | |
3363 #+ATTR_LaTeX: :width 7cm :placement [H] | |
3364 [[./images/retina-small.png]] | |
3365 | |
3366 *** Hearing | |
3367 | |
3368 Ears are created by creating an empty node named =ears= and then | |
3369 creating any number of empty child nodes to represent your | |
3370 creature's ears. | |
3371 | |
3372 Ear nodes do not require any metadata. | |
3373 | |
3374 The ear will bind to and follow the closest physical node. | |
3375 | |
3376 *** Touch | |
3377 | |
3378 Touch is handled similarly to mass. To make a particular object | |
3379 touch sensitive, add metadata of the following form under the | |
3380 object's ``touch'' metadata field: | |
3381 | |
3382 #+BEGIN_EXAMPLE | |
3383 <touch-UV-map-file-name> | |
3384 #+END_EXAMPLE | |
3385 | |
3386 You may also include an optional ``scale'' metadata number to | |
3387 specifiy the length of the touch feelers. The default is $0.1$, | |
3388 and this is generally sufficient. | |
3389 | |
3390 The touch UV should contain white pixels for each touch sensor. | |
3391 | |
3392 Here is an example touch-uv map that approximates a human finger, | |
3393 and its corresponding model. | |
3394 | |
3395 #+caption: This is the tactile-sensor-profile for the upper segment | |
3396 #+caption: of a fingertip. It defines regions of high touch sensitivity | |
3397 #+caption: (where there are many white pixels) and regions of low | |
3398 #+caption: sensitivity (where white pixels are sparse). | |
3399 #+name: guide-fingertip-UV | |
3400 #+ATTR_LaTeX: :width 9cm :placement [H] | |
3401 [[./images/finger-UV.png]] | |
3402 | |
3403 #+caption: The fingertip UV-image form above applied to a simple | |
3404 #+caption: model of a fingertip. | |
3405 #+name: guide-fingertip | |
3406 #+ATTR_LaTeX: :width 9cm :placement [H] | |
3407 [[./images/finger-2.png]] | |
3408 | |
3409 *** Propriocepotion | |
3410 | |
3411 Proprioception is tied to each joint node -- nothing special must | |
3412 be done in a blender model to enable proprioception other than | |
3413 creating joint nodes. | |
3414 | |
3415 *** Muscles | |
3416 | |
3417 Muscles are created by creating an empty node named =muscles= and | |
3418 then creating any number of empty child nodes to represent your | |
3419 creature's muscles. | |
3420 | |
3421 | |
3422 Muscle nodes should have the following metadata under the | |
3423 ``muscle'' label: | |
3424 | |
3425 #+BEGIN_EXAMPLE | |
3426 <muscle-profile-file-name> | |
3427 #+END_EXAMPLE | |
3428 | |
3429 Muscles should also have a ``strength'' metadata entry describing | |
3430 the muscle's total strength at full activation. | |
3431 | |
3432 Muscle profiles are simple images that contain the relative amount | |
3433 of muscle power in each simulated alpha motor neuron. The width of | |
3434 the image is the total size of the motor pool, and the redness of | |
3435 each neuron is the relative power of that motor pool. | |
3436 | |
3437 While the profile image can have any dimensions, only the first | |
3438 line of pixels is used to define the muscle. Here is a sample | |
3439 muscle profile image that defines a human-like muscle. | |
3440 | |
3441 #+caption: A muscle profile image that describes the strengths | |
3442 #+caption: of each motor neuron in a muscle. White is weakest | |
3443 #+caption: and dark red is strongest. This particular pattern | |
3444 #+caption: has weaker motor neurons at the beginning, just | |
3445 #+caption: like human muscle. | |
3446 #+name: muscle-recruit | |
3447 #+ATTR_LaTeX: :width 7cm :placement [H] | |
3448 [[./images/basic-muscle.png]] | |
3449 | |
3450 Muscles twist the nearest physical object about the muscle node's | |
3451 Z-axis. I recommend using the ``Single Arrow'' display mode for | |
3452 muscles and using the right hand rule to determine which way the | |
3453 muscle will twist. To make a segment that can twist in multiple | |
3454 directions, create multiple, differently aligned muscles. | |
3455 | |
3456 ** =CORTEX= API | |
3457 | |
3458 These are the some functions exposed by =CORTEX= for creating | |
3459 worlds and simulating creatures. These are in addition to | |
3460 jMonkeyEngine3's extensive library, which is documented elsewhere. | |
3461 | |
3462 *** Simulation | |
3463 - =(world root-node key-map setup-fn update-fn)= :: create | |
3464 a simulation. | |
3465 - /root-node/ :: a =com.jme3.scene.Node= object which | |
3466 contains all of the objects that should be in the | |
3467 simulation. | |
3468 | |
3469 - /key-map/ :: a map from strings describing keys to | |
3470 functions that should be executed whenever that key is | |
3471 pressed. the functions should take a SimpleApplication | |
3472 object and a boolean value. The SimpleApplication is the | |
3473 current simulation that is running, and the boolean is true | |
3474 if the key is being pressed, and false if it is being | |
3475 released. As an example, | |
3476 #+BEGIN_SRC clojure | |
3477 {"key-j" (fn [game value] (if value (println "key j pressed")))} | |
3478 #+END_SRC | |
3479 is a valid key-map which will cause the simulation to print | |
3480 a message whenever the 'j' key on the keyboard is pressed. | |
3481 | |
3482 - /setup-fn/ :: a function that takes a =SimpleApplication= | |
3483 object. It is called once when initializing the simulation. | |
3484 Use it to create things like lights, change the gravity, | |
3485 initialize debug nodes, etc. | |
3486 | |
3487 - /update-fn/ :: this function takes a =SimpleApplication= | |
3488 object and a float and is called every frame of the | |
3489 simulation. The float tells how many seconds is has been | |
3490 since the last frame was rendered, according to whatever | |
3491 clock jme is currently using. The default is to use IsoTimer | |
3492 which will result in this value always being the same. | |
3493 | |
3494 - =(position-camera world position rotation)= :: set the position | |
3495 of the simulation's main camera. | |
3496 | |
3497 - =(enable-debug world)= :: turn on debug wireframes for each | |
3498 simulated object. | |
3499 | |
3500 - =(set-gravity world gravity)= :: set the gravity of a running | |
3501 simulation. | |
3502 | |
3503 - =(box length width height & {options})= :: create a box in the | |
3504 simulation. Options is a hash map specifying texture, mass, | |
3505 etc. Possible options are =:name=, =:color=, =:mass=, | |
3506 =:friction=, =:texture=, =:material=, =:position=, | |
3507 =:rotation=, =:shape=, and =:physical?=. | |
3508 | |
3509 - =(sphere radius & {options})= :: create a sphere in the simulation. | |
3510 Options are the same as in =box=. | |
3511 | |
3512 - =(load-blender-model file-name)= :: create a node structure | |
3513 representing that described in a blender file. | |
3514 | |
3515 - =(light-up-everything world)= :: distribute a standard compliment | |
3516 of lights throught the simulation. Should be adequate for most | |
3517 purposes. | |
3518 | |
3519 - =(node-seq node)= :: return a recursuve list of the node's | |
3520 children. | |
3521 | |
3522 - =(nodify name children)= :: construct a node given a node-name and | |
3523 desired children. | |
3524 | |
3525 - =(add-element world element)= :: add an object to a running world | |
3526 simulation. | |
3527 | |
3528 - =(set-accuracy world accuracy)= :: change the accuracy of the | |
3529 world's physics simulator. | |
3530 | |
3531 - =(asset-manager)= :: get an /AssetManager/, a jMonkeyEngine | |
3532 construct that is useful for loading textures and is required | |
3533 for smooth interaction with jMonkeyEngine library functions. | |
3534 | |
3535 - =(load-bullet)= :: unpack native libraries and initialize | |
3536 blender. This function is required before other world building | |
3537 functions are called. | |
3538 | |
3539 | |
3540 *** Creature Manipulation / Import | |
3541 | |
3542 - =(body! creature)= :: give the creature a physical body. | |
3543 | |
3544 - =(vision! creature)= :: give the creature a sense of vision. | |
3545 Returns a list of functions which will each, when called | |
3546 during a simulation, return the vision data for the channel of | |
3547 one of the eyes. The functions are ordered depending on the | |
3548 alphabetical order of the names of the eye nodes in the | |
3549 blender file. The data returned by the functions is a vector | |
3550 containing the eye's /topology/, a vector of coordinates, and | |
3551 the eye's /data/, a vector of RGB values filtered by the eye's | |
3552 sensitivity. | |
3553 | |
3554 - =(hearing! creature)= :: give the creature a sense of hearing. | |
3555 Returns a list of functions, one for each ear, that when | |
3556 called will return a frame's worth of hearing data for that | |
3557 ear. The functions are ordered depending on the alphabetical | |
3558 order of the names of the ear nodes in the blender file. The | |
3559 data returned by the functions is an array PCM encoded wav | |
3560 data. | |
3561 | |
3562 - =(touch! creature)= :: give the creature a sense of touch. Returns | |
3563 a single function that must be called with the /root node/ of | |
3564 the world, and which will return a vector of /touch-data/ | |
3565 one entry for each touch sensitive component, each entry of | |
3566 which contains a /topology/ that specifies the distribution of | |
3567 touch sensors, and the /data/, which is a vector of | |
3568 =[activation, length]= pairs for each touch hair. | |
3569 | |
3570 - =(proprioception! creature)= :: give the creature the sense of | |
3571 proprioception. Returns a list of functions, one for each | |
3572 joint, that when called during a running simulation will | |
3573 report the =[headnig, pitch, roll]= of the joint. | |
3574 | |
3575 - =(movement! creature)= :: give the creature the power of movement. | |
3576 Creates a list of functions, one for each muscle, that when | |
3577 called with an integer, will set the recruitment of that | |
3578 muscle to that integer, and will report the current power | |
3579 being exerted by the muscle. Order of muscles is determined by | |
3580 the alphabetical sort order of the names of the muscle nodes. | |
3581 | |
3582 *** Visualization/Debug | |
3583 | |
3584 - =(view-vision)= :: create a function that when called with a list | |
3585 of visual data returned from the functions made by =vision!=, | |
3586 will display that visual data on the screen. | |
3587 | |
3588 - =(view-hearing)= :: same as =view-vision= but for hearing. | |
3589 | |
3590 - =(view-touch)= :: same as =view-vision= but for touch. | |
3591 | |
3592 - =(view-proprioception)= :: same as =view-vision= but for | |
3593 proprioception. | |
3594 | |
3595 - =(view-movement)= :: same as =view-vision= but for | |
3596 proprioception. | |
3597 | |
3598 - =(view anything)= :: =view= is a polymorphic function that allows | |
3599 you to inspect almost anything you could reasonably expect to | |
3600 be able to ``see'' in =CORTEX=. | |
3601 | |
3602 - =(text anything)= :: =text= is a polymorphic function that allows | |
3603 you to convert practically anything into a text string. | |
3604 | |
3605 - =(println-repl anything)= :: print messages to clojure's repl | |
3606 instead of the simulation's terminal window. | |
3607 | |
3608 - =(mega-import-jme3)= :: for experimenting at the REPL. This | |
3609 function will import all jMonkeyEngine3 classes for immediate | |
3610 use. | |
3611 | |
3612 - =(display-dialated-time world timer)= :: Shows the time as it is | |
3613 flowing in the simulation on a HUD display. | |
3614 | |
3615 | |
3616 |