Mercurial > cortex
comparison thesis/cortex.org @ 468:258078f78b33
insert argument about senses.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 28 Mar 2014 16:25:31 -0400 |
parents | ade64947d2bf |
children | ae10f35022ba |
comparison
equal
deleted
inserted
replaced
467:ade64947d2bf | 468:258078f78b33 |
---|---|
364 The most important archetictural decision of all is the choice to | 364 The most important archetictural decision of all is the choice to |
365 use a computer-simulated environemnt in the first place! The world | 365 use a computer-simulated environemnt in the first place! The world |
366 is a vast and rich place, and for now simulations are a very poor | 366 is a vast and rich place, and for now simulations are a very poor |
367 reflection of its complexity. It may be that there is a significant | 367 reflection of its complexity. It may be that there is a significant |
368 qualatative difference between dealing with senses in the real | 368 qualatative difference between dealing with senses in the real |
369 world and dealing with pale facilimilies of them in a | 369 world and dealing with pale facilimilies of them in a simulation. |
370 simulation. What are the advantages and disadvantages of a | 370 What are the advantages and disadvantages of a simulation vs. |
371 simulation vs. reality? | 371 reality? |
372 | 372 |
373 *** Simulation | 373 *** Simulation |
374 | 374 |
375 The advantages of virtual reality are that when everything is a | 375 The advantages of virtual reality are that when everything is a |
376 simulation, experiments in that simulation are absolutely | 376 simulation, experiments in that simulation are absolutely |
443 the simulation. The cost is that =CORTEX= can sometimes run slower | 443 the simulation. The cost is that =CORTEX= can sometimes run slower |
444 than real time. This can also be an advantage, however --- | 444 than real time. This can also be an advantage, however --- |
445 simulations of very simple creatures in =CORTEX= generally run at | 445 simulations of very simple creatures in =CORTEX= generally run at |
446 40x on my machine! | 446 40x on my machine! |
447 | 447 |
448 ** What is a sense? | |
449 | |
450 If =CORTEX= is to support a wide variety of senses, it would help | |
451 to have a better understanding of what a ``sense'' actually is! | |
452 While vision, touch, and hearing all seem like they are quite | |
453 different things, I was supprised to learn during the course of | |
454 this thesis that they (and all physical senses) can be expressed as | |
455 exactly the same mathematical object due to a dimensional argument! | |
456 | |
457 Human beings are three-dimensional objects, and the nerves that | |
458 transmit data from our various sense organs to our brain are | |
459 essentially one-dimensional. This leaves up to two dimensions in | |
460 which our sensory information may flow. For example, imagine your | |
461 skin: it is a two-dimensional surface around a three-dimensional | |
462 object (your body). It has discrete touch sensors embedded at | |
463 various points, and the density of these sensors corresponds to the | |
464 sensitivity of that region of skin. Each touch sensor connects to a | |
465 nerve, all of which eventually are bundled together as they travel | |
466 up the spinal cord to the brain. Intersect the spinal nerves with a | |
467 guillotining plane and you will see all of the sensory data of the | |
468 skin revealed in a roughly circular two-dimensional image which is | |
469 the cross section of the spinal cord. Points on this image that are | |
470 close together in this circle represent touch sensors that are | |
471 /probably/ close together on the skin, although there is of course | |
472 some cutting and rearrangement that has to be done to transfer the | |
473 complicated surface of the skin onto a two dimensional image. | |
474 | |
475 Most human senses consist of many discrete sensors of various | |
476 properties distributed along a surface at various densities. For | |
477 skin, it is Pacinian corpuscles, Meissner's corpuscles, Merkel's | |
478 disks, and Ruffini's endings, which detect pressure and vibration | |
479 of various intensities. For ears, it is the stereocilia distributed | |
480 along the basilar membrane inside the cochlea; each one is | |
481 sensitive to a slightly different frequency of sound. For eyes, it | |
482 is rods and cones distributed along the surface of the retina. In | |
483 each case, we can describe the sense with a surface and a | |
484 distribution of sensors along that surface. | |
485 | |
486 The neat idea is that every human sense can be effectively | |
487 described in terms of a surface containing embedded sensors. If the | |
488 sense had any more dimensions, then there wouldn't be enough room | |
489 in the spinal chord to transmit the information! | |
490 | |
491 Therefore, =CORTEX= must support the ability to create objects and | |
492 then be able to ``paint'' points along their surfaces to describe | |
493 each sense. | |
494 | |
495 Fortunately this idea is already a well known computer graphics | |
496 technique called called /UV-mapping/. The three-dimensional surface | |
497 of a model is cut and smooshed until it fits on a two-dimensional | |
498 image. You paint whatever you want on that image, and when the | |
499 three-dimensional shape is rendered in a game the smooshing and | |
500 cutting is reversed and the image appears on the three-dimensional | |
501 object. | |
502 | |
503 To make a sense, interpret the UV-image as describing the | |
504 distribution of that senses sensors. To get different types of | |
505 sensors, you can either use a different color for each type of | |
506 sensor, or use multiple UV-maps, each labeled with that sensor | |
507 type. I generally use a white pixel to mean the presence of a | |
508 sensor and a black pixel to mean the absence of a sensor, and use | |
509 one UV-map for each sensor-type within a given sense. | |
510 | |
511 #+CAPTION: The UV-map for an elongated icososphere. The white | |
512 #+caption: dots each represent a touch sensor. They are dense | |
513 #+caption: in the regions that describe the tip of the finger, | |
514 #+caption: and less dense along the dorsal side of the finger | |
515 #+caption: opposite the tip. | |
516 #+name: finger-UV | |
517 #+ATTR_latex: :width 10cm | |
518 [[./images/finger-UV.png]] | |
519 | |
520 #+caption: Ventral side of the UV-mapped finger. Notice the | |
521 #+caption: density of touch sensors at the tip. | |
522 #+name: finger-side-view | |
523 #+ATTR_LaTeX: :width 10cm | |
524 [[./images/finger-1.png]] | |
525 | |
526 | |
448 ** COMMENT Video game engines are a great starting point | 527 ** COMMENT Video game engines are a great starting point |
449 | 528 |
450 I did not need to write my own physics simulation code or shader to | 529 I did not need to write my own physics simulation code or shader to |
451 build =CORTEX=. Doing so would lead to a system that is impossible | 530 build =CORTEX=. Doing so would lead to a system that is impossible |
452 for anyone but myself to use anyway. Instead, I use a video game | 531 for anyone but myself to use anyway. Instead, I use a video game |
460 tools that can be co-opted to serve as touch, proprioception, and | 539 tools that can be co-opted to serve as touch, proprioception, and |
461 muscles. Since some games support split screen views, a good video | 540 muscles. Since some games support split screen views, a good video |
462 game engine will allow you to efficiently create multiple cameras | 541 game engine will allow you to efficiently create multiple cameras |
463 in the simulated world that can be used as eyes. Video game systems | 542 in the simulated world that can be used as eyes. Video game systems |
464 offer integrated asset management for things like textures and | 543 offer integrated asset management for things like textures and |
465 creatures models, providing an avenue for defining creatures. | 544 creatures models, providing an avenue for defining creatures. They |
466 Finally, because video game engines support a large number of | 545 also understand UV-mapping, since this technique is used to apply a |
467 users, if I don't stray too far from the base system, other | 546 texture to a model. Finally, because video game engines support a |
468 researchers can turn to this community for help when doing their | 547 large number of users, as long as =CORTEX= doesn't stray too far |
469 research. | 548 from the base system, other researchers can turn to this community |
549 for help when doing their research. | |
470 | 550 |
471 ** COMMENT =CORTEX= is based on jMonkeyEngine3 | 551 ** COMMENT =CORTEX= is based on jMonkeyEngine3 |
472 | 552 |
473 While preparing to build =CORTEX= I studied several video game | 553 While preparing to build =CORTEX= I studied several video game |
474 engines to see which would best serve as a base. The top contenders | 554 engines to see which would best serve as a base. The top contenders |
508 I chose jMonkeyEngine3 because it because it had the most features | 588 I chose jMonkeyEngine3 because it because it had the most features |
509 out of all the free projects I looked at, and because I could then | 589 out of all the free projects I looked at, and because I could then |
510 write my code in clojure, an implementation of =LISP= that runs on | 590 write my code in clojure, an implementation of =LISP= that runs on |
511 the JVM. | 591 the JVM. |
512 | 592 |
513 ** COMMENT Bodies are composed of segments connected by joints | 593 ** =CORTEX= uses Blender to create creature models |
514 | 594 |
515 For the simple worm-like creatures I will use later on in this | 595 For the simple worm-like creatures I will use later on in this |
516 thesis, I could define a simple API in =CORTEX= that would allow | 596 thesis, I could define a simple API in =CORTEX= that would allow |
517 one to create boxes, spheres, etc., and leave that API as the sole | 597 one to create boxes, spheres, etc., and leave that API as the sole |
518 way to create creatures. However, for =CORTEX= to truly be useful | 598 way to create creatures. However, for =CORTEX= to truly be useful |
519 for other projects, it needs to have a way to construct complicated | 599 for other projects, it needs a way to construct complicated |
520 creatures. If possible, it would be nice to leverage work that has | 600 creatures. If possible, it would be nice to leverage work that has |
521 already been done by the community of 3D modelers, or at least | 601 already been done by the community of 3D modelers, or at least |
522 enable people who are talented at moedling but not programming to | 602 enable people who are talented at moedling but not programming to |
523 design =CORTEX= creatures. | 603 design =CORTEX= creatures. |
524 | 604 |
525 Therefore, I use Blender, a free 3D modeling program, as the main | 605 Therefore, I use Blender, a free 3D modeling program, as the main |
526 way to create creatures in =CORTEX=. However, the creatures modeled | 606 way to create creatures in =CORTEX=. However, the creatures modeled |
527 in Blender must also be simple to simulate in jMonkeyEngine3's game | 607 in Blender must also be simple to simulate in jMonkeyEngine3's game |
528 engine, and must also be easy to rig with =CORTEX='s senses. | 608 engine, and must also be easy to rig with =CORTEX='s senses. I |
529 | 609 accomplish this with extensive use of Blender's ``empty nodes.'' |
530 While trying to find a good compromise for body-design, one option | 610 |
531 I ultimately rejected is to use blender's [[http://wiki.blender.org/index.php/Doc:2.6/Manual/Rigging/Armatures][armature]] system. The idea | 611 Empty nodes have no mass, physical presence, or appearance, but |
532 would have been to define a mesh which describes the creature's | 612 they can hold metadata and have names. I use a tree structure of |
533 entire body. To this you add a skeleton which deforms this mesh | 613 empty nodes to specify senses in the following manner: |
534 (called rigging). This technique is used extensively to model | 614 |
535 humans and create realistic animations. It is not a good technique | 615 - Create a single top-level empty node whose name is the name of |
536 for physical simulation, because deformable surfaces are hard to | 616 the sense. |
537 model. Humans work like a squishy bag with some hard bones to give | 617 - Add empty nodes which each contain meta-data relevant to the |
538 it shape. The bones are easy to simulate physically, but they | 618 sense, including a UV-map describing the number/distribution of |
539 interact with thr world though the skin, which is contiguous, but | 619 sensors if applicable. |
540 does not have a constant shape. In order to simulate skin you need | 620 - Make each empty-node the child of the top-level node. |
541 some way to continuously update the physical model of the skin | 621 |
542 along with the movement of the bones. Given that bullet is | 622 #+caption: An example of annoting a creature model with empty |
543 optimized for rigid, solid objects, this leads to unmanagable | 623 #+caption: nodes to describe the layout of senses. There are |
544 computation and incorrect simulation. | 624 #+caption: multiple empty nodes which each describe the position |
545 | 625 #+caption: of muscles, ears, eyes, or joints. |
546 Instead of using the human-like ``deformable bag of bones'' | 626 #+name: sense-nodes |
547 approach, I decided to base my body plans on multiple solid objects | 627 #+ATTR_LaTeX: :width 10cm |
548 that are connected by joints, inspired by the robot =EVE= from the | 628 [[./images/empty-sense-nodes.png]] |
549 movie WALL-E. | 629 |
630 | |
631 ** Bodies are composed of segments connected by joints | |
632 | |
633 Blender is a general purpose animation tool, which has been used in | |
634 the past to create high quality movies such as Sintel | |
635 \cite{sintel}. Though Blender can model and render even complicated | |
636 things like water, it is crucual to keep models that are meant to | |
637 be simulated as creatures simple. =Bullet=, which =CORTEX= uses | |
638 though jMonkeyEngine3, is a rigid-body physics system. This offers | |
639 a compromise between the expressiveness of a game level and the | |
640 speed at which it can be simulated, and it means that creatures | |
641 should be naturally expressed as rigid components held together by | |
642 joint constraints. | |
643 | |
644 But humans are more like a squishy bag with wrapped around some | |
645 hard bones which define the overall shape. When we move, our skin | |
646 bends and stretches to accomodate the new positions of our bones. | |
647 | |
648 One way to make bodies composed of rigid pieces connected by joints | |
649 /seem/ more human-like is to use an /armature/, (or /rigging/) | |
650 system, which defines a overall ``body mesh'' and defines how the | |
651 mesh deforms as a function of the position of each ``bone'' which | |
652 is a standard rigid body. This technique is used extensively to | |
653 model humans and create realistic animations. It is not a good | |
654 technique for physical simulation, however because it creates a lie | |
655 -- the skin is not a physical part of the simulation and does not | |
656 interact with any objects in the world or itself. Objects will pass | |
657 right though the skin until they come in contact with the | |
658 underlying bone, which is a physical object. Whithout simulating | |
659 the skin, the sense of touch has little meaning, and the creature's | |
660 own vision will lie to it about the true extent of its body. | |
661 Simulating the skin as a physical object requires some way to | |
662 continuously update the physical model of the skin along with the | |
663 movement of the bones, which is unacceptably slow compared to rigid | |
664 body simulation. | |
665 | |
666 Therefore, instead of using the human-like ``deformable bag of | |
667 bones'' approach, I decided to base my body plans on multiple solid | |
668 objects that are connected by joints, inspired by the robot =EVE= | |
669 from the movie WALL-E. | |
550 | 670 |
551 #+caption: =EVE= from the movie WALL-E. This body plan turns | 671 #+caption: =EVE= from the movie WALL-E. This body plan turns |
552 #+caption: out to be much better suited to my purposes than a more | 672 #+caption: out to be much better suited to my purposes than a more |
553 #+caption: human-like one. | 673 #+caption: human-like one. |
554 #+ATTR_LaTeX: :width 10cm | 674 #+ATTR_LaTeX: :width 10cm |
556 | 676 |
557 =EVE='s body is composed of several rigid components that are held | 677 =EVE='s body is composed of several rigid components that are held |
558 together by invisible joint constraints. This is what I mean by | 678 together by invisible joint constraints. This is what I mean by |
559 ``eve-like''. The main reason that I use eve-style bodies is for | 679 ``eve-like''. The main reason that I use eve-style bodies is for |
560 efficiency, and so that there will be correspondence between the | 680 efficiency, and so that there will be correspondence between the |
561 AI's vision and the physical presence of its body. Each individual | 681 AI's semses and the physical presence of its body. Each individual |
562 section is simulated by a separate rigid body that corresponds | 682 section is simulated by a separate rigid body that corresponds |
563 exactly with its visual representation and does not change. | 683 exactly with its visual representation and does not change. |
564 Sections are connected by invisible joints that are well supported | 684 Sections are connected by invisible joints that are well supported |
565 in jMonkeyEngine3. Bullet, the physics backend for jMonkeyEngine3, | 685 in jMonkeyEngine3. Bullet, the physics backend for jMonkeyEngine3, |
566 can efficiently simulate hundreds of rigid bodies connected by | 686 can efficiently simulate hundreds of rigid bodies connected by |
567 joints. Sections do not have to stay as one piece forever; they can | 687 joints. Just because sections are rigid does not mean they have to |
568 be dynamically replaced with multiple sections to simulate | 688 stay as one piece forever; they can be dynamically replaced with |
569 splitting in two. This could be used to simulate retractable claws | 689 multiple sections to simulate splitting in two. This could be used |
570 or =EVE='s hands, which are able to coalesce into one object in the | 690 to simulate retractable claws or =EVE='s hands, which are able to |
571 movie. | 691 coalesce into one object in the movie. |
572 | 692 |
573 *** Solidifying/Connecting the body | 693 *** Solidifying/Connecting the body |
574 | |
575 Importing bodies from =CORTEX= into blender involves encoding | |
576 metadata into the blender file that specifies the mass of each | |
577 component and the joints by which those components are connected. I | |
578 do this in Blender in two ways. First is by using the ``metadata'' | |
579 field of each solid object to specify the mass. Second is by using | |
580 Blender ``empty nodes'' to specify the position and type of each | |
581 joint. Empty nodes have no mass, physical presence, or appearance, | |
582 but they can hold metadata and have names. I use a tree structure | |
583 of empty nodes to specify joints. There is a parent node named | |
584 ``joints'', and a series of empty child nodes of the ``joints'' | |
585 node that each represent a single joint. | |
586 | 694 |
587 #+caption: View of the hand model in Blender showing the main ``joints'' | 695 #+caption: View of the hand model in Blender showing the main ``joints'' |
588 #+caption: node (highlighted in yellow) and its children which each | 696 #+caption: node (highlighted in yellow) and its children which each |
589 #+caption: represent a joint in the hand. Each joint node has metadata | 697 #+caption: represent a joint in the hand. Each joint node has metadata |
590 #+caption: specifying what sort of joint it is. | 698 #+caption: specifying what sort of joint it is. |
591 #+name: blender-hand | 699 #+name: blender-hand |
592 #+ATTR_LaTeX: :width 10cm | 700 #+ATTR_LaTeX: :width 10cm |
593 [[./images/hand-screenshot1.png]] | 701 [[./images/hand-screenshot1.png]] |
594 | |
595 | 702 |
596 =CORTEX= creates a creature in two steps: first, it traverses the | 703 =CORTEX= creates a creature in two steps: first, it traverses the |
597 nodes in the blender file and creates physical representations for | 704 nodes in the blender file and creates physical representations for |
598 any of them that have mass defined. | 705 any of them that have mass defined. |
599 | 706 |
827 #+caption: =CORTEX= gets one step closer to a full creature simulation | 934 #+caption: =CORTEX= gets one step closer to a full creature simulation |
828 #+caption: environment. | 935 #+caption: environment. |
829 #+name: name | 936 #+name: name |
830 #+ATTR_LaTeX: :width 15cm | 937 #+ATTR_LaTeX: :width 15cm |
831 [[./images/physical-hand.png]] | 938 [[./images/physical-hand.png]] |
939 | |
832 | 940 |
833 | 941 |
834 ** Eyes reuse standard video game components | 942 ** Eyes reuse standard video game components |
835 | 943 |
836 ** Hearing is hard; =CORTEX= does it right | 944 ** Hearing is hard; =CORTEX= does it right |