|
| 1 | +; |
| 2 | +; btree-eva.scm |
| 3 | +; |
| 4 | +; Eva behavior tree (for the Eva blender model animations). |
| 5 | +; |
| 6 | +; Runs a set of defined behaviors that express Eva's personality. |
| 7 | +; This version integrates the OpenCog chatbot. |
| 8 | +; |
| 9 | +; The currently-defined behaviors include acknowledging new people who |
| 10 | +; enter the room, rotating attention between multiple occupants of the |
| 11 | +; room, falling asleep when bored (i.e. the room is empty), and acting |
| 12 | +; surprised when someone leaves unexpectedly. |
| 13 | +; |
| 14 | +; HOWTO: |
| 15 | +; Run the main loop: |
| 16 | +; (run) |
| 17 | +; Pause the main loop: |
| 18 | +; (halt) |
| 19 | +; |
| 20 | +; Make sure that you did a `cmake` and `make install` first! |
| 21 | +; |
| 22 | +; Unit testing: See `unit-test.scm` and also notes in `behavior.scm`. |
| 23 | +; |
| 24 | + |
| 25 | +(add-to-load-path "/usr/local/share/opencog/scm") |
| 26 | + |
| 27 | +(use-modules (opencog)) |
| 28 | +(use-modules (opencog query)) ; XXX work-around relex2logic bug |
| 29 | + |
| 30 | +; Start the cogsserver. It is used by the face-tracker to poke data |
| 31 | +; into the atomspace. |
| 32 | +(use-modules (opencog cogserver)) |
| 33 | +(start-cogserver "../scripts/opencog.conf") |
| 34 | + |
| 35 | +; Load the behavior trees. |
| 36 | +(use-modules (opencog exec)) ; needed for cog-evaluate! in put_atoms.py |
| 37 | +(use-modules (opencog eva-model)) ; needed for defines in put_atoms.py |
| 38 | +(use-modules (opencog eva-behavior)) |
| 39 | + |
| 40 | +; Load the Eva personality configuration. |
| 41 | +; (display %load-path) |
| 42 | +(add-to-load-path "../src") |
| 43 | +(load-from-path "cfg-eva.scm") ;;; <<<=== See, its Eva here! |
| 44 | + |
| 45 | +;; Call (run) to run the main loop, (halt) to pause the loop. |
| 46 | +;; The main loop runs in its own thread. |
| 47 | +(define (run) (behavior-tree-run)) |
| 48 | +(define (halt) (behavior-tree-halt)) |
| 49 | + |
| 50 | +; --------------------------------------------------------- |
| 51 | +; Load the chat modules. |
| 52 | +; |
| 53 | +(use-modules (opencog nlp)) |
| 54 | +(use-modules (opencog nlp chatbot-eva)) |
| 55 | + |
| 56 | +; Work-around to weird bug: must load relex2logic at the top level. |
| 57 | +(use-modules (opencog nlp relex2logic)) |
| 58 | + |
| 59 | +; Work-around to circular dependency: define `dispatch-text` at the |
| 60 | +; top level of the guile executation environment. |
| 61 | +(define-public (dispatch-text txt) |
| 62 | +" |
| 63 | + dispatch-text TEXT |
| 64 | +
|
| 65 | + Pass the TEXT that STT heard into the OpenCog chatbot. |
| 66 | +" |
| 67 | + (call-with-new-thread |
| 68 | + ; Must run in a new thread, else it deadlocks in python, |
| 69 | + ; since the text processing results in python calls. |
| 70 | + ; (lambda () (process-query "luser" (cog-name txt))) |
| 71 | + (lambda () (grounded-talk "luser" (cog-name txt))) |
| 72 | + ) |
| 73 | + (stv 1 1) |
| 74 | +) |
| 75 | + |
| 76 | +; --------------------------------------------------------- |
| 77 | +; Run the hacky garbage collection loop. |
| 78 | +(run-behavior-tree-gc) |
| 79 | + |
| 80 | +; Silence the output. |
| 81 | +*unspecified* |
| 82 | + |
| 83 | +;; Actually set it running, by default. |
| 84 | +(all-threads) ; print out the curent threads. |
| 85 | +(run) |
0 commit comments