Mercurial > cortex
comparison org/movement.org @ 304:2dfebf71053c
Merged Winston cover letter
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Sat, 18 Feb 2012 02:07:40 -0600 |
parents | 1eed471e2ebf |
children | 7e7f8d6d9ec5 |
comparison
equal
deleted
inserted
replaced
303:35d9e7d04d87 | 304:2dfebf71053c |
---|---|
12 Surprisingly enough, terristerial creatures only move by using torque | 12 Surprisingly enough, terristerial creatures only move by using torque |
13 applied about their joints. There's not a single straight line of | 13 applied about their joints. There's not a single straight line of |
14 force in the human body at all! (A straight line of force would | 14 force in the human body at all! (A straight line of force would |
15 correspond to some sort of jet or rocket propulsion.) | 15 correspond to some sort of jet or rocket propulsion.) |
16 | 16 |
17 *(next paragraph is from memory and needs to be checked!)* | 17 In humans, muscles are composed of muscle fibers which can contract to |
18 | 18 exert force. The muscle fibers which compose a muscle are partitioned |
19 In humans, muscles are composed of millions of sarcomeres, which can | 19 into discrete groups which are each controlled by a single alpha motor |
20 contract to exert force. A single motor neuron might control 100-1,000 | 20 neuton. A single alpha motor neuron might control as little as three |
21 sarcomeres. When the motor neuron is engaged by the brain, it | 21 or as many as one thousand muscle fibers. When the alpha motor neuron |
22 activates all of the sarcomeres to which it is attached. Some motor | 22 is engaged by the spinal cord, it activates all of the muscle fibers |
23 neurons command many sarcomeres, and some command only a few. The | 23 to which it is attached. The spinal cord generally engages the alpha |
24 spinal cord generally engages the motor neurons which control few | 24 motor neurons which control few muscle fibers before the motor neurons |
25 sarcomeres before the motor neurons which control many sarcomeres. | 25 which control many muscle fibers. This recruitment stragety allows |
26 This recruitment stragety allows for percise movements at low | 26 for percise movements at low strength. The collection of all motor |
27 strength. The collection of all motor neurons that control a muscle is | 27 neurons that control a muscle is called the motor pool. The brain |
28 called the motor pool. The brain essentially says "activate 30% of the | 28 essentially says "activate 30% of the motor pool" and the spinal cord |
29 motor pool" and the spinal cord recruits motor neurons untill 30% are | 29 recruits motor neurons untill 30% are activated. Since the |
30 activated. Since the distribution of power among motor neurons is | 30 distribution of power among motor neurons is unequal and recruitment |
31 unequal and recruitment goes from weakest to strongest, the first 30% | 31 goes from weakest to strongest, the first 30% of the motor pool might |
32 of the motor pool might be 5% of the strength of the muscle. | 32 be 5% of the strength of the muscle. |
33 | 33 |
34 My simulated muscles follow a similiar design: Each muscle is defined | 34 My simulated muscles follow a similiar design: Each muscle is defined |
35 by a 1-D array of numbers (the "motor pool"). Each entry in the array | 35 by a 1-D array of numbers (the "motor pool"). Each entry in the array |
36 represents a motor neuron which controlls a number of sarcomeres equal | 36 represents a motor neuron which controlls a number of muscle fibers |
37 to the value of the entry. A muscle also has a scalar :strength factor | 37 equal to the value of the entry. Each muscle has a scalar strength |
38 which determines the total force the muscle can exert when all motor | 38 factor which determines the total force the muscle can exert when all |
39 neurons are activated. The effector function for a muscle takes a | 39 motor neurons are activated. The effector function for a muscle takes |
40 number to index into the motor pool, and that number "activates" all | 40 a number to index into the motor pool, and then "activates" all the |
41 the motor neurons whose index is lower or equal to the number. Each | 41 motor neurons whose index is lower or equal to the number. Each |
42 motor-neuron will apply force in proportion to its value in the array. | 42 motor-neuron will apply force in proportion to its value in the array. |
43 Lower values cause less force. The lower values can be put at the | 43 Lower values cause less force. The lower values can be put at the |
44 "beginning" of the 1-D array to simulate the layout of actual human | 44 "beginning" of the 1-D array to simulate the layout of actual human |
45 muscles, which are capable of more percise movements when exerting | 45 muscles, which are capable of more percise movements when exerting |
46 less force. Or, the motor pool can simulate more exoitic recruitment | 46 less force. Or, the motor pool can simulate more exoitic recruitment |
116 (.mult (.getWorldRotation muscle) Vector3f/UNIT_Y) | 116 (.mult (.getWorldRotation muscle) Vector3f/UNIT_Y) |
117 strength (muscle-strength muscle) | 117 strength (muscle-strength muscle) |
118 | 118 |
119 pool (motor-pool muscle) | 119 pool (motor-pool muscle) |
120 pool-integral (reductions + pool) | 120 pool-integral (reductions + pool) |
121 force-index | 121 forces |
122 (vec (map #(float (* strength (/ % (last pool-integral)))) | 122 (vec (map #(float (* strength (/ % (last pool-integral)))) |
123 pool-integral)) | 123 pool-integral)) |
124 control (.getControl target RigidBodyControl)] | 124 control (.getControl target RigidBodyControl)] |
125 (println-repl (.getName target) axis) | |
125 (fn [n] | 126 (fn [n] |
126 (let [pool-index (max 0 (min n (dec (count pool)))) | 127 (let [pool-index (max 0 (min n (dec (count pool)))) |
127 force (force-index pool-index)] | 128 force (forces pool-index)] |
128 (.applyTorque control (.mult axis force)) | 129 (.applyTorque control (.mult axis force)) |
129 (float (/ force strength)))))) | 130 (float (/ force strength)))))) |
130 | 131 |
131 (defn movement! | 132 (defn movement! |
132 "Endow the creature with the power of movement. Returns a sequence | 133 "Endow the creature with the power of movement. Returns a sequence |
173 (view-sense movement-display-kernel)) | 174 (view-sense movement-display-kernel)) |
174 #+end_src | 175 #+end_src |
175 | 176 |
176 * Adding Touch to the Worm | 177 * Adding Touch to the Worm |
177 | 178 |
178 #+begin_src clojure | 179 To the worm, I add two new nodes which describe a single muscle. |
179 (defn test-movement | 180 |
180 ([] (test-movement false)) | 181 #+attr_html: width=755 |
182 #+caption: The node highlighted in orange is the parent node of all muscles in the worm. The arrow highlighted in yellow represents the creature's single muscle, which moves the top segment. The other nodes which are not highlighted are joints, eyes, and ears. | |
183 [[../images/worm-with-muscle.png]] | |
184 | |
185 #+name: test-movement | |
186 #+begin_src clojure | |
187 (defn test-worm-movement | |
188 ([] (test-worm-movement false)) | |
181 ([record?] | 189 ([record?] |
182 (let [creature (doto (worm) (body!)) | 190 (let [creature (doto (worm) (body!)) |
183 | 191 |
184 muscle-exertion (atom 0) | 192 muscle-exertion (atom 0) |
185 muscles (movement! creature) | 193 muscles (movement! creature) |
209 (set-gravity world (Vector3f. 0 0 0)) | 217 (set-gravity world (Vector3f. 0 0 0)) |
210 (.setLocation (.getCamera world) | 218 (.setLocation (.getCamera world) |
211 (Vector3f. -4.912815, 2.004171, 0.15710819)) | 219 (Vector3f. -4.912815, 2.004171, 0.15710819)) |
212 (.setRotation (.getCamera world) | 220 (.setRotation (.getCamera world) |
213 (Quaternion. 0.13828252, 0.65516764, | 221 (Quaternion. 0.13828252, 0.65516764, |
214 -0.12370994, 0.7323449)) | 222 -0.12370994, 0.7323449))) |
215 | |
216 (comment | |
217 (com.aurellem.capture.Capture/captureVideo | |
218 world (file-str "/home/r/proj/ai-videos/hand")))) | |
219 (fn [world tpf] | 223 (fn [world tpf] |
220 (muscle-display | 224 (muscle-display |
221 (map #(% @muscle-exertion) muscles) | 225 (map #(% @muscle-exertion) muscles) |
222 (if record? | 226 (if record? |
223 (File. "/home/r/proj/cortex/render/worm-muscles/muscles")))))))) | 227 (File. "/home/r/proj/cortex/render/worm-muscles/muscles")))))))) |
237 the power output of the muscle . Each jump causes 20 more motor neurons to | 241 the power output of the muscle . Each jump causes 20 more motor neurons to |
238 be recruited. Notice that the power output increases non-linearly | 242 be recruited. Notice that the power output increases non-linearly |
239 with motror neuron recruitement, similiar to a human muscle.</p> | 243 with motror neuron recruitement, similiar to a human muscle.</p> |
240 </div> | 244 </div> |
241 #+end_html | 245 #+end_html |
242 | |
243 | 246 |
244 ** Making the Worm Muscles Video | 247 ** Making the Worm Muscles Video |
245 #+name: magick7 | 248 #+name: magick7 |
246 #+begin_src clojure | 249 #+begin_src clojure |
247 (ns cortex.video.magick7 | 250 (ns cortex.video.magick7 |
302 (:use cortex.test.body) | 305 (:use cortex.test.body) |
303 (:use clojure.contrib.def) | 306 (:use clojure.contrib.def) |
304 (:import java.io.File) | 307 (:import java.io.File) |
305 (:import java.awt.image.BufferedImage) | 308 (:import java.awt.image.BufferedImage) |
306 (:import com.jme3.scene.Node) | 309 (:import com.jme3.scene.Node) |
307 (:import com.jme3.math.Vector3f) | 310 (:import (com.jme3.math Quaternion Vector3f)) |
308 (:import (com.aurellem.capture Capture RatchetTimer)) | 311 (:import (com.aurellem.capture Capture RatchetTimer)) |
309 (:import com.jme3.bullet.control.RigidBodyControl)) | 312 (:import com.jme3.bullet.control.RigidBodyControl)) |
310 | |
311 (cortex.import/mega-import-jme3) | |
312 #+end_src | 313 #+end_src |
313 | 314 |
314 * Source Listing | 315 * Source Listing |
315 - [[../src/cortex/movement.clj][cortex.movement]] | 316 - [[../src/cortex/movement.clj][cortex.movement]] |
316 - [[../src/cortex/test/movement.clj][cortex.test.movement]] | 317 - [[../src/cortex/test/movement.clj][cortex.test.movement]] |