diff --git a/src/README.md b/src/README.md index 2e1aa901..2398daee 100644 --- a/src/README.md +++ b/src/README.md @@ -185,3 +185,11 @@ A list of random ideas. (DefinedPredicateNode "Is interacting with someone?") Everything emitted to ROS is a state.... look for the behavior pubs. + +---------------- + +Pending bugs: +* (DefinedPredicateNode "Did someone leave?") being called much much + too often!!! ... why??? +* Psi hung ... for no apparent reason. + (psi-running?) (psi-get-loop-count) diff --git a/src/atomic-dbg.py b/src/atomic-dbg.py index e731c865..cd215ad3 100644 --- a/src/atomic-dbg.py +++ b/src/atomic-dbg.py @@ -174,10 +174,10 @@ def blink_rate(mean_node, var_node): return TruthValue(1, 1) def say_text(text_node): - text = text_node.name + text = text_node.name print "(Eva says: ", text, ")" - # evl.say_text(text) - return TruthValue(1, 1) + # evl.say_text(text) + return TruthValue(1, 1) # Return true as long as ROS is running. def ros_is_running(): diff --git a/src/behavior.scm b/src/behavior.scm index ba2b04a8..1f3cecda 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -129,7 +129,7 @@ ;; Show random expressions only if NOT talking (SequentialOr - ;(Not (DefinedPredicate "chatbot is listening")) + ;(Not (DefinedPredicate "chatbot is listening?")) (SequentialAnd (SequentialOrLink @@ -170,9 +170,8 @@ ;; If interaction is requested, then interact with that specific person. ;; Make sure we look at that person ... (DefineLink - (DefinedPredicate "Interaction requested") + (DefinedPredicate "Interaction requested action") (SequentialAnd - (DefinedPredicate "Someone requests interaction?") (True (DefinedPredicate "If sleeping then wake")) (True (DefinedPredicate "If bored then alert")) (DefinedPredicate "interact with requested person") @@ -198,7 +197,7 @@ ;; Respond to a new face becoming visible. ; -;; XXX TODO -- need to also do line 590, if interacting for a while +;; XXX TODO -- if interacting for a while ;; this alters probability of glance... (DefineLink (DefinedPredicate "Respond to new arrival") @@ -235,7 +234,6 @@ (DefineLink (DefinedPredicate "New arrival sequence") (SequentialAnd - (DefinedPredicate "Did someone arrive?") (True (DefinedPredicate "If sleeping then wake")) (True (DefinedPredicate "If bored then alert")) (DefinedPredicate "Respond to new arrival") @@ -244,9 +242,8 @@ ;; Check to see if someone left. (DefineLink - (DefinedPredicate "Someone left") + (DefinedPredicate "Someone left action") (SequentialAnd - (DefinedPredicate "Did someone leave?") (Put (DefinedPredicate "Publish behavior") (Concept "Someone left")) (Evaluation (GroundedPredicate "scm: print-msg") @@ -287,9 +284,6 @@ (DefineLink (DefinedPredicate "Interact with people") (SequentialAnd - ; True, if there is anyone visible. - (DefinedPredicate "Someone visible") - ; Say something, if no one else has said anything in a while. ; i.e. if are being ignored, then say something. ; (SequentialOr @@ -559,11 +553,9 @@ ; Things to do, if TTS vocalization just started. (DefineLink ; owyl "chatbot_speech_start()" method - (DefinedPredicate "Speech started?") + (DefinedPredicate "Speech started") (SequentialAnd - ; If the TTS vocalization started (chatbot started talking) ... - (DefinedPredicate "chatbot started talking") - ; ... then switch to face-study saccade ... + ; Switch to face-study saccade ... (Evaluation (GroundedPredicate "py:conversational_saccade") (ListLink)) ; ... and show one random gesture from "conversing" set. @@ -580,12 +572,12 @@ (ListLink (Node "--- Start talking"))) )) -; Currently used for scripted behaviors while STT doesnt publish accurate events. +; Currently used for scripted behaviors while STT doesn't publish +; accurate events. (DefineLink - (DefinedPredicate "Listening started?") + (DefinedPredicate "Listening started") (SequentialAnd - (DefinedPredicate "chatbot started listening") - ; ... then switch to face-study saccade ... + ; Switch to face-study saccade ... (Evaluation (GroundedPredicate "py:listening_saccade") (ListLink)) ; ... and show one random gesture from "conversing" set. @@ -604,11 +596,9 @@ ;; Things to do, if the chatbot is currently talking. (DefineLink - (DefinedPredicate "Speech ongoing?") + (DefinedPredicate "Speech ongoing") (SequentialAnd - ; If the chatbot currently talking ... - (DefinedPredicate "chatbot is talking") - ; ... then handle the various affect states. + ; Handle the various affect states. (SequentialOr (SequentialAnd ; If chatbot is happy ... @@ -664,12 +654,9 @@ ; Things to do, if the chattbot stopped talking. (DefineLink - (DefinedPredicate "Speech ended?") + (DefinedPredicate "Speech ended") (SequentialAnd - ; If the chatbot stopped talking ... - (DefinedPredicate "chatbot stopped talking") - - ; ... then switch back to exploration saccade ... + ; Switch back to exploration saccade ... (Evaluation (GroundedPredicate "py:explore_saccade") (ListLink)) @@ -689,12 +676,9 @@ ; Things to do, if stopped listening. (DefineLink - (DefinedPredicate "Listening ended?") + (DefinedPredicate "Listening ended") (SequentialAnd - ; If the chatbot stopped talking ... - (DefinedPredicate "chatbot stopped listening") - - ; ... then switch back to exploration saccade ... + ; Switch back to exploration saccade ... (Evaluation (GroundedPredicate "py:explore_saccade") (ListLink)) @@ -714,11 +698,9 @@ ; Things to do, if the chatbot is listening. (DefineLink - (DefinedPredicate "Listening?") + (DefinedPredicate "Listening ongoing") (SequentialAnd - ; If the chatbot stopped talking ... - (DefinedPredicate "chatbot is listening") - ; ... show one of the neutral-speech expressions + ; Show one of the neutral-speech expressions (SequentialOr (Not (DefinedPredicate "Time to change expression")) (Put (DefinedPredicateNode "Show random expression") @@ -765,11 +747,25 @@ (SatisfactionLink (SequentialAnd (SequentialOr - (DefinedPredicate "Skip Interaction?") - (DefinedPredicate "Interaction requested") - (DefinedPredicate "New arrival sequence") - (DefinedPredicate "Someone left") - (DefinedPredicate "Interact with people") + (DefinedPredicate "Skip Interaction?") + + (SequentialAnd + (DefinedPredicate "Someone requests interaction?") + (DefinedPredicate "Interaction requested action")) + + (SequentialAnd + (DefinedPredicate "Did someone arrive?") + (DefinedPredicate "New arrival sequence")) + + (SequentialAnd + (DefinedPredicate "Did someone leave?") + (DefinedPredicate "Someone left action")) + + ; True, if there is anyone visible. + (SequentialAnd + (DefinedPredicate "Someone visible?") + (DefinedPredicate "Interact with people")) + (DefinedPredicate "Nothing is happening") (True)) @@ -778,16 +774,39 @@ ;; but the chatbot is still smiling and yabbering. ;; If interaction is turned-off need keep alive gestures (SequentialOr - (DefinedPredicate "Speech started?") - (DefinedPredicate "Speech ongoing?") - (DefinedPredicate "Speech ended?") - (DefinedPredicate "Listening started?") - (DefinedPredicate "Listening?") - (DefinedPredicate "Listening ended?") + ; If the TTS vocalization started (chatbot started talking) ... + (SequentialAnd + (DefinedPredicate "chatbot started talking?") + (DefinedPredicate "Speech started")) + + ; If the chatbot currently talking ... + (SequentialAnd + (DefinedPredicate "chatbot is talking?") + (DefinedPredicate "Speech ongoing")) + + ; If the chatbot stopped talking ... + (SequentialAnd + (DefinedPredicate "chatbot stopped talking?") + (DefinedPredicate "Speech ended")) + + (SequentialAnd + (DefinedPredicate "chatbot started listening?") + (DefinedPredicate "Listening started")) + + ; If the chatbot stopped talking ... + (SequentialAnd + (DefinedPredicate "chatbot is listening?") + (DefinedPredicate "Listening ongoing")) + + ; If the chatbot stopped talking ... + (SequentialAnd + (DefinedPredicate "chatbot stopped listening?") + (DefinedPredicate "Listening ended")) + (SequentialAnd (DefinedPredicate "Skip Interaction?") - (DefinedPredicate "Keep alive") - ) + (DefinedPredicate "Keep alive")) + (True) ) diff --git a/src/btree-eva.scm b/src/btree-eva.scm index c73eb0dd..99562318 100644 --- a/src/btree-eva.scm +++ b/src/btree-eva.scm @@ -57,18 +57,18 @@ (use-modules (opencog nlp relex2logic)) ; Work-around to circular dependency: define `dispatch-text` at the -; top level of the guile executation environment. -(define-public (dispatch-text txt) +; top level of the guile execution environment. +(define-public (dispatch-text TXT-ATOM) " - dispatch-text TEXT + dispatch-text TXT-ATOM - Pass the TEXT that STT heard into the OpenCog chatbot. + Pass the TXT-ATOM that STT heard into the OpenCog chatbot. " (call-with-new-thread ; Must run in a new thread, else it deadlocks in python, ; since the text processing results in python calls. - ; (lambda () (process-query "luser" (cog-name txt))) - (lambda () (grounded-talk "luser" (cog-name txt))) + ; (lambda () (process-query "luser" (cog-name TXT-ATOM))) + (lambda () (grounded-talk "luser" (cog-name TXT-ATOM))) ) (stv 1 1) ) diff --git a/src/btree-psi.scm b/src/btree-psi.scm index 17ceefd6..4bc0e490 100644 --- a/src/btree-psi.scm +++ b/src/btree-psi.scm @@ -42,12 +42,33 @@ ; Load the Eva personality configuration. ; (display %load-path) (add-to-load-path "../src") -(load-from-path "cfg-eva.scm") ;;; <<<=== See, its Eva here! +; (load-from-path "cfg-eva.scm") ;;; <<<=== See, its Eva here! +(load-from-path "cfg-sophia.scm") ;;; <<<=== See, its Sophia here! + +;; Load the actual psi rules. +(load-from-path "psi-behavior.scm") + +; There MUST be a DefinedPredicateNode with exactly the name +; below in order for psi-run to work. Or we could just blow +; that off, and use our own loop... +(define loop-name (string-append psi-prefix-str "loop")) +(DefineLink + (DefinedPredicate loop-name) + (SatisfactionLink + (SequentialAnd + (Evaluation (GroundedPredicate "scm: psi-step") + (ListLink)) + (Evaluation (GroundedPredicate "scm: psi-run-continue?") + (ListLink)) + ; If ROS is dead, or the continue flag not set, + ; then stop running the behavior loop. + (DefinedPredicate "ROS is running?") + (DefinedPredicate loop-name)))) ;; Call (run) to run the main loop, (halt) to pause the loop. ;; The main loop runs in its own thread. -(define (run) (behavior-tree-run)) -(define (halt) (behavior-tree-halt)) +(define (run) (psi-run)) +(define (halt) (psi-halt)) ; --------------------------------------------------------- ; Load the chat modules. @@ -59,26 +80,26 @@ (use-modules (opencog nlp relex2logic)) ; Work-around to circular dependency: define `dispatch-text` at the -; top level of the guile executation environment. -(define-public (dispatch-text txt) +; top level of the guile execution environment. +(define-public (dispatch-text TXT-ATOM) " - dispatch-text TEXT + dispatch-text TXT-ATOM - Pass the TEXT that STT heard into the OpenCog chatbot. + Pass the TXT-ATOM that STT heard into the OpenCog chatbot. " (call-with-new-thread ; Must run in a new thread, else it deadlocks in python, ; since the text processing results in python calls. - ; (lambda () (process-query "luser" (cog-name txt))) - ; (lambda () (grounded-talk "luser" (cog-name txt))) - (lambda () (chat (cog-name txt))) + ; (lambda () (process-query "luser" (cog-name TXT-ATOM))) + ; (lambda () (grounded-talk "luser" (cog-name TXT-ATOM))) + (lambda () (chat (cog-name TXT-ATOM))) ) (stv 1 1) ) ; --------------------------------------------------------- ; Run the hacky garbage collection loop. -(run-behavior-tree-gc) +; (run-behavior-tree-gc) ; Silence the output. *unspecified* diff --git a/src/btree.scm b/src/btree.scm index 55449923..17350568 100644 --- a/src/btree.scm +++ b/src/btree.scm @@ -74,20 +74,20 @@ ;(use-modules (opencog nlp relex2logic)) ; Work-around to circular dependency: define `dispatch-text` at the -; top level of the guile executation environment. -(define-public (dispatch-text txt) +; top level of the guile execution environment. +(define-public (dispatch-text TXT-ATOM) " - dispatch-text TEXT + dispatch-text TXT-ATOM - Pass the TEXT that STT heard into the OpenCog chatbot. + Pass the TXT-ATOM that STT heard into the OpenCog chatbot. " ; (call-with-new-thread ; Must run in a new thread, else it deadlocks in python, ; since the text processing results in python calls. - ; (lambda () (process-query "luser" (cog-name txt))) - ; (lambda () (grounded-talk "luser" (cog-name txt))) + ; (lambda () (process-query "luser" (cog-name TXT-ATOM))) + ; (lambda () (grounded-talk "luser" (cog-name TXT-ATOM))) ; XXX Need to ... auuh load the chatbot... -; (lambda () (chat txt)) +; (lambda () (chat TXT-ATOM)) ; ) (stv 1 1) ) diff --git a/src/cfg-eva.scm b/src/cfg-eva.scm index 386353b3..c257e754 100644 --- a/src/cfg-eva.scm +++ b/src/cfg-eva.scm @@ -67,6 +67,19 @@ (emo-expr-spec "neutral-speech" "comprehending" 0.4 0.5 0.8 4 8) (emo-expr-spec "neutral-speech" "engaged" 0.4 0.5 0.8 4 8) +(emo-expr-spec "neutral-listen" "happy" 0.2 0.1 0.3 4 8) +(emo-expr-spec "neutral-listen" "comprehending" 0.4 0.5 0.8 4 8) +(emo-expr-spec "neutral-listen" "engaged" 0.4 0.5 0.8 4 8) + +(emo-expr-spec "neutral-keep-alive" "happy" 0.2 0.4 1.0 2 8) +(emo-expr-spec "neutral-keep-alive" "confused" 0.2 0.6 1.0 3 8) +(emo-expr-spec "neutral-keep-alive" "engaged" 0.2 0.4 1.0 4 9) +(emo-expr-spec "neutral-keep-alive" "amused" 0.2 0.3 1.0 2 5) +(emo-expr-spec "neutral-keep-alive" "recoil" 0.1 0.2 0.5 1 4) +(emo-expr-spec "neutral-keep-alive" "irritated" 0.1 0.1 0.7 1 4) +(emo-expr-spec "neutral-keep-alive" "angry" 0.1 0.1 0.6 1 4) +(emo-expr-spec "neutral-keep-alive" "bored" 0.1 0.1 1.0 3 7) + ; Used for imperatives, i.e. when she is verbally told to do something. ; Thus, we list all of them here. The probability column is ignored. ; The strength has to be 0.6 or more, or else blender doesn't play the @@ -155,6 +168,10 @@ ; (emo-gest-spec "chat-neg-think" "think-browsDown.003" 0.8 0.5 0.7 1 1 0.3 0.5) (emo-gest-spec "chat-neg-think" "noop" 0.2 0 0 1 1 0 0 ) +; Gestures to use during listening. +(emo-gest-spec "listening" "thoughtful" 0.4 0.7 1.0 1 1 0.6 0.8) +(emo-gest-spec "listening" "noop" 0.6 0.0 1.0 1 1 0.0 0.0) + ; Used for imperatives, i.e. when she is verbally told to do something. ; Thus, we list all of them here. The probability column is ignored. ; The shake and nod gestures are very weak, for some reason. diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index 8fd3afbf..74613eb5 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -8,25 +8,32 @@ (use-modules (opencog exec)) (use-modules (opencog openpsi)) ; +;; ------------------------------------------------------------------ + +(define (foobar x) +; (display "duuuuuuuude foobar pred-schema wrapper\n") +; (display x) (newline) + (cog-evaluate! x) + (Node "bad value")) ;; -(define (pred-2-schema pnode-str) - (DefineLink +(define (pred-2-schema pnode-str) + (DefineLink (DefinedSchemaNode pnode-str) - (ExecutionOutputLink (GroundedSchemaNode "scm: cog-evaluate!") + (ExecutionOutputLink (GroundedSchemaNode "scm: foobar") (ListLink (DefinedPredicateNode pnode-str)) ))) ;; (pred-2-schema "Interaction requested action") -(pred-2-schema "New arrival sequence action") +(pred-2-schema "New arrival sequence") (pred-2-schema "Someone left action") -(pred-2-schema "Interact with people action") -(pred-2-schema "Nothing is happening action") -(pred-2-schema "Speech started? action") -(pred-2-schema "Speech ongoing? action") -(pred-2-schema "Speech ended? action") -(pred-2-schema "Listening started? action") -(pred-2-schema "Listening? action") -(pred-2-schema "Listening ended? action") +(pred-2-schema "Interact with people") +(pred-2-schema "Nothing is happening") +(pred-2-schema "Speech started") +(pred-2-schema "Speech ongoing") +(pred-2-schema "Speech ended") +(pred-2-schema "Listening started") +(pred-2-schema "Listening ongoing") +(pred-2-schema "Listening ended") (pred-2-schema "Keep alive") ;; ;(DefineLink (DefinedPredicateNode "do-noop") (True)) @@ -36,118 +43,75 @@ (define speech-demand-satisfied (True)) (define face-demand (psi-demand "face interaction" 1)) (define speech-demand (psi-demand "speech interaction" 1)) -(define run-demand (psi-demand "run demand" 1)) - -;(psi-rule (list (DefinedPredicate "Interaction requested"))(DefinedSchemaNode "Interaction requested action") demand-satisfied (stv 1 1) face-demand) -;(psi-rule (list (DefinedPredicate "New arrival sequence")) (DefinedSchemaNode "New arrival sequence action") demand-satisfied (stv 1 1) face-demand) -;(psi-rule (list (DefinedPredicate "Someone left")) (DefinedSchemaNode "Someone left action") demand-satisfied (stv 1 1) face-demand) -;(psi-rule (list (DefinedPredicate "Interact with people")) (DefinedSchemaNode "Interact with people action") demand-satisfied (stv 1 1) face-demand) -;(psi-rule (list (DefinedPredicate "Nothing is happening")) (DefinedSchemaNode "Nothing is happening action") demand-satisfied (stv 1 1) face-demand) -;(psi-rule (list (DefinedPredicate "Speech started?")) (DefinedSchemaNode "Speech started? action") speech-demand-satisfied (stv 1 1) speech-demand) -;(psi-rule (list (DefinedPredicate "Speech ongoing?")) (DefinedSchemaNode "Speech ongoing? action") speech-demand-satisfied (stv 1 1) speech-demand) -;(psi-rule (list (DefinedPredicate "Speech ended?")) (DefinedSchemaNode "Speech ended? action") speech-demand-satisfied (stv 1 1) speech-demand) -;(psi-rule (list (DefinedPredicate "Skip Interaction?")) (DefinedSchemaNode "Keep alive") speech-demand-satisfied (stv 1 1) speech-demand) - - -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Interaction requested")) - (DefinedSchemaNode "Interaction requested action") +; (define run-demand (psi-demand "run demand" 1)) + +(DefineLink + (DefinedPredicate "Nothing happening?") + (NotLink + (SequentialOr + (DefinedPredicate "Someone requests interaction?") + (DefinedPredicate "Did someone arrive?") + (DefinedPredicate "Did someone leave?") + (DefinedPredicate "Someone visible?")))) + + +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "Someone requests interaction?")) + (DefinedSchemaNode "Interaction requested action") demand-satisfied (stv 1 1) face-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "New arrival sequence")) - (DefinedSchemaNode "New arrival sequence action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "Did someone arrive?")) + (DefinedSchemaNode "New arrival sequence") demand-satisfied (stv 1 1) face-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Someone left")) - (DefinedSchemaNode "Someone left action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "Did someone leave?")) + (DefinedSchemaNode "Someone left action") demand-satisfied (stv 1 1) face-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Interact with people")) - (DefinedSchemaNode "Interact with people action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "Someone visible?")) + (DefinedSchemaNode "Interact with people") demand-satisfied (stv 1 1) face-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Nothing is happening")) - (DefinedSchemaNode "Nothing is happening action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "Nothing happening?")) + (DefinedSchemaNode "Nothing is happening") demand-satisfied (stv 1 1) face-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Speech started?")) - (DefinedSchemaNode "Speech started? action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "chatbot started talking?")) + (DefinedSchemaNode "Speech started") speech-demand-satisfied (stv 1 1) speech-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Speech ongoing?")) - (DefinedSchemaNode "Speech ongoing? action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "chatbot is talking?")) + (DefinedSchemaNode "Speech ongoing") speech-demand-satisfied (stv 1 1) speech-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Speech ended?")) - (DefinedSchemaNode "Speech ended? action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "chatbot stopped talking?")) + (DefinedSchemaNode "Speech ended") speech-demand-satisfied (stv 1 1) speech-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Listening started?")) - (DefinedSchemaNode "Listening started? action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "chatbot started listening?")) + (DefinedSchemaNode "Listening started") speech-demand-satisfied (stv 1 1) speech-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Listening?")) - (DefinedSchemaNode "Listening? action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "chatbot is listening?")) + (DefinedSchemaNode "Listening ongoing") speech-demand-satisfied (stv 1 1) speech-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Listening ended?")) - (DefinedSchemaNode "Listening ended? action") +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) + (DefinedPredicate "chatbot stopped listening?")) + (DefinedSchemaNode "Listening ended") speech-demand-satisfied (stv 1 1) speech-demand) -(psi-rule (list (DefinedPredicate "Skip Interaction?")) - (DefinedSchemaNode "Keep alive") +(psi-rule (list (DefinedPredicate "Skip Interaction?")) + (DefinedSchemaNode "Keep alive") speech-demand-satisfied (stv 1 1) speech-demand) -;; ------------------------------------------------------------------ -;; Main loop. Uses tail recursion optimization to form the loop. -(DefineLink - (DefinedPredicate "main loop") - (SatisfactionLink - (SequentialAnd -; (SequentialOr -; (DefinedPredicate "Skip Interaction?") -; (DefinedPredicate "Interaction requested") -; (DefinedPredicate "New arrival sequence") -; (DefinedPredicate "Someone left") -; (DefinedPredicate "Interact with people") -; (DefinedPredicate "Nothing is happening") -; (True)) - -; ;; XXX FIXME chatbot is disengaged from everything else. -; ;; The room can be empty, the head is bored or even asleep, -; ;; but the chatbot is still smiling and yabbering. -; ;; If interaction is turned-off need keep alive gestures -; (SequentialOr -; (DefinedPredicate "Speech started?") -; (DefinedPredicate "Speech ongoing?") -; (DefinedPredicate "Speech ended?") -; (DefinedPredicate "Listening started?") -; (DefinedPredicate "Listening?") -; (DefinedPredicate "Listening ended?") -; (SequentialAnd -; (DefinedPredicate "Skip Interaction?") -; (DefinedPredicate "Keep alive") -; ) -; (True) -; ) - - ; If ROS is dead, or the continue flag not set, then stop - ; running the behavior loop. - (DefinedPredicate "Continue running loop?") - (DefinedPredicate "ROS is running?") - - ;; Call self -- tail-recurse. - (DefinedPredicate "main loop") - ))) - ; ---------------------------------------------------------------------- diff --git a/src/self-model.scm b/src/self-model.scm index 0a79f28e..10ed509f 100644 --- a/src/self-model.scm +++ b/src/self-model.scm @@ -25,11 +25,11 @@ ; ; Examples and debugging hints: ; Some (but not all) state queries: -; (cog-evaluate! (DefinedPredicate "chatbot is talking")) -; (cog-evaluate! (DefinedPredicate "chatbot is listening")) +; (cog-evaluate! (DefinedPredicate "chatbot is talking?")) +; (cog-evaluate! (DefinedPredicate "chatbot is listening?")) ; (cog-evaluate! (DefinedPredicate "chatbot is happy")) ; (cog-evaluate! (DefinedPredicateNode "Did someone arrive?")) -; (cog-evaluate! (DefinedPredicateNode "Someone visible")) +; (cog-evaluate! (DefinedPredicateNode "Someone visible?")) ; (cog-execute! (DefinedSchemaNode "Num visible faces")) ; (add-to-load-path "/usr/local/share/opencog/scm") @@ -138,7 +138,7 @@ (StateLink chat-state chat-idle) (DefineLink - (DefinedPredicate "chatbot started talking") + (DefinedPredicate "chatbot started talking?") (Equal (Set chat-start) (Get (State chat-state (Variable "$x"))))) @@ -148,27 +148,27 @@ (Get (State chat-state (Variable "$x"))))) (DefineLink - (DefinedPredicate "chatbot is talking") + (DefinedPredicate "chatbot is talking?") (Equal (Set chat-talk) (Get (State chat-state (Variable "$x"))))) (DefineLink - (DefinedPredicate "chatbot stopped talking") + (DefinedPredicate "chatbot stopped talking?") (Equal (Set chat-stop) (Get (State chat-state (Variable "$x"))))) (DefineLink - (DefinedPredicate "chatbot started listening") + (DefinedPredicate "chatbot started listening?") (Equal (Set chat-listen-start) (Get (State chat-state (Variable "$x"))))) (DefineLink - (DefinedPredicate "chatbot is listening") + (DefinedPredicate "chatbot is listening?") (Equal (Set chat-listen) (Get (State chat-state (Variable "$x"))))) (DefineLink - (DefinedPredicate "chatbot stopped listening") + (DefinedPredicate "chatbot stopped listening?") (Equal (Set chat-listen-stop) (Get (State chat-state (Variable "$x"))))) @@ -379,7 +379,7 @@ ;; Is there someone present? We check for acked faces. ;; The someone-arrived code converts newly-visible faces to acked faces. (DefineLink - (DefinedPredicateNode "Someone visible") + (DefinedPredicateNode "Someone visible?") (SatisfactionLink (TypedVariable (Variable "$face-id") (Type "NumberNode")) (PresentLink @@ -468,7 +468,7 @@ (DefinedPredicate "Is interacting with someone?") (OrLink ; true if talking not listening. - (NotLink (DefinedPredicate "chatbot is listening")) + (NotLink (DefinedPredicate "chatbot is listening?")) ; true if not not-making eye-contact. (NotLink (Equal (SetLink no-interaction) @@ -628,9 +628,14 @@ ;; (DefinedSchema "look at person") to make it look. (DefineLink (DefinedPredicate "interact with new person") - (True (Put (DefinedPredicate "Set interaction target") - ; If more than one new arrival, pick one randomly. - (RandomChoice (DefinedSchema "New arrivals")))) + ; XXX Double-check that the "New arrivals" list is non-empty; + ; some OpenPsi bug sometimes sends us here, and the RandomChoice + ; crashes if the list is empty. + (SequentialAnd + (DefinedPredicateNode "Did someone arrive?") + (True (Put (DefinedPredicate "Set interaction target") + ; If more than one new arrival, pick one randomly. + (RandomChoice (DefinedSchema "New arrivals"))))) ) ;; Set eye-contact face to the requested face.