comparison thesis/cortex.org @ 479:a5480a06d5fe

first draft of proprioception complete.
author Robert McIntyre <rlm@mit.edu>
date Fri, 28 Mar 2014 23:16:32 -0400
parents ba54df21fc7c
children ad76b8b05517
comparison
equal deleted inserted replaced
478:76d44e969289 479:a5480a06d5fe
10 #+caption: 10 #+caption:
11 #+caption: 11 #+caption:
12 #+caption: 12 #+caption:
13 #+name: name 13 #+name: name
14 #+begin_listing clojure 14 #+begin_listing clojure
15 #+BEGIN_SRC clojure
16 #+END_SRC
15 #+end_listing 17 #+end_listing
16 18
17 #+caption: 19 #+caption:
18 #+caption: 20 #+caption:
19 #+caption: 21 #+caption:
2048 #+ATTR_LaTeX: :width 15cm 2050 #+ATTR_LaTeX: :width 15cm
2049 [[./images/touch-cube.png]] 2051 [[./images/touch-cube.png]]
2050 2052
2051 ** Proprioception is the sense that makes everything ``real'' 2053 ** Proprioception is the sense that makes everything ``real''
2052 2054
2055 Close your eyes, and touch your nose with your right index finger.
2056 How did you do it? You could not see your hand, and neither your
2057 hand nor your nose could use the sense of touch to guide the path
2058 of your hand. There are no sound cues, and Taste and Smell
2059 certainly don't provide any help. You know where your hand is
2060 without your other senses because of Proprioception.
2061
2062 Humans can sometimes loose this sense through viral infections or
2063 damage to the spinal cord or brain, and when they do, they loose
2064 the ability to control their own bodies without looking directly at
2065 the parts they want to move. In [[http://en.wikipedia.org/wiki/The_Man_Who_Mistook_His_Wife_for_a_Hat][The Man Who Mistook His Wife for a
2066 Hat]], a woman named Christina looses this sense and has to learn how
2067 to move by carefully watching her arms and legs. She describes
2068 proprioception as the "eyes of the body, the way the body sees
2069 itself".
2070
2071 Proprioception in humans is mediated by [[http://en.wikipedia.org/wiki/Articular_capsule][joint capsules]], [[http://en.wikipedia.org/wiki/Muscle_spindle][muscle
2072 spindles]], and the [[http://en.wikipedia.org/wiki/Golgi_tendon_organ][Golgi tendon organs]]. These measure the relative
2073 positions of each body part by monitoring muscle strain and length.
2074
2075 It's clear that this is a vital sense for fluid, graceful movement.
2076 It's also particularly easy to implement in jMonkeyEngine.
2077
2078 My simulated proprioception calculates the relative angles of each
2079 joint from the rest position defined in the blender file. This
2080 simulates the muscle-spindles and joint capsules. I will deal with
2081 Golgi tendon organs, which calculate muscle strain, in the next
2082 section.
2083
2084 *** Helper functions
2085
2086 =absolute-angle= calculates the angle between two vectors,
2087 relative to a third axis vector. This angle is the number of
2088 radians you have to move counterclockwise around the axis vector
2089 to get from the first to the second vector. It is not commutative
2090 like a normal dot-product angle is.
2091
2092 The purpose of these functions is to build a system of angle
2093 measurement that is biologically plausable.
2094
2095
2096 #+caption: Program to measure angles along a vector
2097 #+name: helpers
2098 #+begin_listing clojure
2099 #+BEGIN_SRC clojure
2100 (defn right-handed?
2101 "true iff the three vectors form a right handed coordinate
2102 system. The three vectors do not have to be normalized or
2103 orthogonal."
2104 [vec1 vec2 vec3]
2105 (pos? (.dot (.cross vec1 vec2) vec3)))
2106
2107 (defn absolute-angle
2108 "The angle between 'vec1 and 'vec2 around 'axis. In the range
2109 [0 (* 2 Math/PI)]."
2110 [vec1 vec2 axis]
2111 (let [angle (.angleBetween vec1 vec2)]
2112 (if (right-handed? vec1 vec2 axis)
2113 angle (- (* 2 Math/PI) angle))))
2114 #+END_SRC
2115 #+end_listing
2116
2117
2118
2119 #+caption:
2120 #+caption:
2121 #+caption:
2122 #+caption:
2123 #+name: name
2124 #+begin_listing clojure
2125 #+BEGIN_SRC clojure
2126 #+END_SRC
2127 #+end_listing
2128
2129
2130 *** Proprioception Kernel
2131
2132 Given a joint, =proprioception-kernel= produces a function that
2133 calculates the Euler angles between the the objects the joint
2134 connects. The only tricky part here is making the angles relative
2135 to the joint's initial ``straightness''.
2136
2137 #+caption: Program to return biologially reasonable proprioceptive
2138 #+caption: data for each joint.
2139 #+name: proprioception
2140 #+begin_listing clojure
2141 #+BEGIN_SRC clojure
2142 (defn proprioception-kernel
2143 "Returns a function which returns proprioceptive sensory data when
2144 called inside a running simulation."
2145 [#^Node parts #^Node joint]
2146 (let [[obj-a obj-b] (joint-targets parts joint)
2147 joint-rot (.getWorldRotation joint)
2148 x0 (.mult joint-rot Vector3f/UNIT_X)
2149 y0 (.mult joint-rot Vector3f/UNIT_Y)
2150 z0 (.mult joint-rot Vector3f/UNIT_Z)]
2151 (fn []
2152 (let [rot-a (.clone (.getWorldRotation obj-a))
2153 rot-b (.clone (.getWorldRotation obj-b))
2154 x (.mult rot-a x0)
2155 y (.mult rot-a y0)
2156 z (.mult rot-a z0)
2157
2158 X (.mult rot-b x0)
2159 Y (.mult rot-b y0)
2160 Z (.mult rot-b z0)
2161 heading (Math/atan2 (.dot X z) (.dot X x))
2162 pitch (Math/atan2 (.dot X y) (.dot X x))
2163
2164 ;; rotate x-vector back to origin
2165 reverse
2166 (doto (Quaternion.)
2167 (.fromAngleAxis
2168 (.angleBetween X x)
2169 (let [cross (.normalize (.cross X x))]
2170 (if (= 0 (.length cross)) y cross))))
2171 roll (absolute-angle (.mult reverse Y) y x)]
2172 [heading pitch roll]))))
2173
2174 (defn proprioception!
2175 "Endow the creature with the sense of proprioception. Returns a
2176 sequence of functions, one for each child of the \"joints\" node in
2177 the creature, which each report proprioceptive information about
2178 that joint."
2179 [#^Node creature]
2180 ;; extract the body's joints
2181 (let [senses (map (partial proprioception-kernel creature)
2182 (joints creature))]
2183 (fn []
2184 (map #(%) senses))))
2185 #+END_SRC
2186 #+end_listing
2187
2188
2189 =proprioception!= maps =proprioception-kernel= across all the
2190 joints of the creature. It uses the same list of joints that
2191 =joints= uses. Proprioception is the easiest sense to implement in
2192 =CORTEX=, and it will play a crucial role when efficiently
2193 implementing empathy.
2194
2195 #+caption: In the upper right corner, the three proprioceptive
2196 #+caption: angle measurements are displayed. Red is yaw, Green is
2197 #+caption: pitch, and White is roll.
2198 #+name: proprio
2199 #+ATTR_LaTeX: :width 11cm
2200 [[./images/proprio.png]]
2201
2053 ** Muscles are both effectors and sensors 2202 ** Muscles are both effectors and sensors
2054 2203
2055 ** =CORTEX= brings complex creatures to life! 2204 ** =CORTEX= brings complex creatures to life!
2056 2205
2057 ** =CORTEX= enables many possiblities for further research 2206 ** =CORTEX= enables many possiblities for further research