From c1f147b6bae347878131e48cfcd54cdd2f11d317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Mon, 6 Jun 2016 22:43:42 +0800 Subject: [PATCH 01/26] Clarify the chatbot arguments --- src/btree-eva.scm | 12 ++++++------ src/btree-psi.scm | 18 +++++++++--------- src/btree.scm | 14 +++++++------- 3 files changed, 22 insertions(+), 22 deletions(-) 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..56e1c6ec 100644 --- a/src/btree-psi.scm +++ b/src/btree-psi.scm @@ -46,8 +46,8 @@ ;; 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,19 +59,19 @@ (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) ) 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) ) From 588598da006af8752841b5e9182f1127e55f00ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Mon, 6 Jun 2016 22:50:51 +0800 Subject: [PATCH 02/26] Load the actual psi rules --- src/btree-psi.scm | 10 +++++++ src/psi-behavior.scm | 71 ++++++++++++++++++-------------------------- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/src/btree-psi.scm b/src/btree-psi.scm index 56e1c6ec..2829bfe2 100644 --- a/src/btree-psi.scm +++ b/src/btree-psi.scm @@ -43,12 +43,22 @@ ; (display %load-path) (add-to-load-path "../src") (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") ;; Call (run) to run the main loop, (halt) to pause the loop. ;; The main loop runs in its own thread. (define (run) (psi-run)) (define (halt) (psi-halt)) +; XXX FIXME +; If ROS is dead, or the continue flag not set, then stop +; running the behavior loop. +(DefinedPredicate "Continue running loop?") +(DefinedPredicate "ROS is running?") + ; --------------------------------------------------------- ; Load the chat modules. ; diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index 8fd3afbf..ae0cdfe5 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -8,6 +8,35 @@ (use-modules (opencog exec)) (use-modules (opencog openpsi)) ; +;; ------------------------------------------------------------------ +;; Main loop. +; (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) +; ) + ;; (define (pred-2-schema pnode-str) (DefineLink @@ -108,46 +137,4 @@ (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") - ))) - ; ---------------------------------------------------------------------- From 6c878fb3c768540330daff6d3659bb2db1b3d953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Mon, 6 Jun 2016 23:30:32 +0800 Subject: [PATCH 03/26] Cleanup the main loop. --- src/btree-psi.scm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/btree-psi.scm b/src/btree-psi.scm index 2829bfe2..e1c670f8 100644 --- a/src/btree-psi.scm +++ b/src/btree-psi.scm @@ -53,11 +53,23 @@ (define (run) (psi-run)) (define (halt) (psi-halt)) -; XXX FIXME -; If ROS is dead, or the continue flag not set, then stop -; running the behavior loop. -(DefinedPredicate "Continue running loop?") -(DefinedPredicate "ROS is running?") +; 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 + (DefinedPredicateNode 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?") + (DefinedPredicateNode loop-name)))) + ; --------------------------------------------------------- ; Load the chat modules. From 7f9040c41ea789872a37655d1882acb4fc9353b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:07:23 +0800 Subject: [PATCH 04/26] Start refactoring the missing predicates --- src/behavior.scm | 8 ++++---- src/btree-psi.scm | 20 ++++++++++++-------- src/psi-behavior.scm | 9 +++++++-- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index ba2b04a8..7a33616c 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -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") @@ -765,8 +764,9 @@ (SatisfactionLink (SequentialAnd (SequentialOr - (DefinedPredicate "Skip Interaction?") - (DefinedPredicate "Interaction requested") + (DefinedPredicate "Skip Interaction?") + (DefinedPredicate "Someone requests interaction?") + (DefinedPredicate "Interaction requested action") (DefinedPredicate "New arrival sequence") (DefinedPredicate "Someone left") (DefinedPredicate "Interact with people") diff --git a/src/btree-psi.scm b/src/btree-psi.scm index e1c670f8..095665d1 100644 --- a/src/btree-psi.scm +++ b/src/btree-psi.scm @@ -48,28 +48,32 @@ ;; Load the actual psi rules. (load-from-path "psi-behavior.scm") -;; Call (run) to run the main loop, (halt) to pause the loop. -;; The main loop runs in its own thread. -(define (run) (psi-run)) -(define (halt) (psi-halt)) - ; 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 - (DefinedPredicateNode loop-name) + (DefinedPredicate loop-name) (SatisfactionLink (SequentialAnd +(Evaluation (GroundedPredicate "scm: wtf") (ListLink (Node "start"))) (Evaluation (GroundedPredicate "scm: psi-step") (ListLink)) +(Evaluation (GroundedPredicate "scm: wtf") (ListLink (Node "middle"))) (Evaluation (GroundedPredicate "scm: psi-run-continue?") (ListLink)) +(Evaluation (GroundedPredicate "scm: wtf") (ListLink (Node "more"))) ; If ROS is dead, or the continue flag not set, ; then stop running the behavior loop. (DefinedPredicate "ROS is running?") - (DefinedPredicateNode loop-name)))) +(Evaluation (GroundedPredicate "scm: wtf") (ListLink (Node "tail"))) + (DefinedPredicate loop-name)))) +(define (wtf x) (display "heyyyyy\n") (display x)(newline) (stv 1 1)) +;; Call (run) to run the main loop, (halt) to pause the loop. +;; The main loop runs in its own thread. +(define (run) (psi-run)) +(define (halt) (psi-halt)) ; --------------------------------------------------------- ; Load the chat modules. @@ -100,7 +104,7 @@ ; --------------------------------------------------------- ; Run the hacky garbage collection loop. -(run-behavior-tree-gc) +; (run-behavior-tree-gc) ; Silence the output. *unspecified* diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index ae0cdfe5..fe3c6197 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -37,11 +37,16 @@ ; (True) ; ) +(define (foobar x) +(display "duuuuuuuude wtf foobar\n") +(display x) (newline) + (cog-evaluate! x) + (Node "bad value")) ;; (define (pred-2-schema pnode-str) (DefineLink (DefinedSchemaNode pnode-str) - (ExecutionOutputLink (GroundedSchemaNode "scm: cog-evaluate!") + (ExecutionOutputLink (GroundedSchemaNode "scm: foobar") (ListLink (DefinedPredicateNode pnode-str)) ))) ;; @@ -79,7 +84,7 @@ (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Interaction requested")) + (DefinedPredicate "Someone requests interaction?")) (DefinedSchemaNode "Interaction requested action") demand-satisfied (stv 1 1) face-demand) From 4c276637066a27d5dd428237d17cd709032e1baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:09:45 +0800 Subject: [PATCH 05/26] Refactor another interaction --- src/behavior.scm | 2 +- src/psi-behavior.scm | 70 ++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 7a33616c..5a8a596e 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -234,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") @@ -767,6 +766,7 @@ (DefinedPredicate "Skip Interaction?") (DefinedPredicate "Someone requests interaction?") (DefinedPredicate "Interaction requested action") + (DefinedPredicate "Did someone arrive?") (DefinedPredicate "New arrival sequence") (DefinedPredicate "Someone left") (DefinedPredicate "Interact with people") diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index fe3c6197..dfb0b95c 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -43,8 +43,8 @@ (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: foobar") (ListLink (DefinedPredicateNode pnode-str)) @@ -83,63 +83,63 @@ ;(psi-rule (list (DefinedPredicate "Skip Interaction?")) (DefinedSchemaNode "Keep alive") speech-demand-satisfied (stv 1 1) speech-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) (DefinedPredicate "Someone requests interaction?")) - (DefinedSchemaNode "Interaction requested action") + (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 "Someone left")) + (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 "Interact with people")) + (DefinedSchemaNode "Interact with people action") 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 is happening")) + (DefinedSchemaNode "Nothing is happening action") 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 "Speech started?")) + (DefinedSchemaNode "Speech started? action") 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 "Speech ongoing?")) + (DefinedSchemaNode "Speech ongoing? action") speech-demand-satisfied (stv 1 1) speech-demand) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) (DefinedPredicate "Speech ended?")) - (DefinedSchemaNode "Speech ended? action") + (DefinedSchemaNode "Speech ended? action") 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 "Listening started?")) + (DefinedSchemaNode "Listening started? action") 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 "Listening?")) + (DefinedSchemaNode "Listening? action") 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 "Listening ended?")) + (DefinedSchemaNode "Listening ended? action") 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) ; ---------------------------------------------------------------------- From d04147f71de9ee5c729c74f7ae2bf953bcef2529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:12:52 +0800 Subject: [PATCH 06/26] Another predicate conversion --- src/behavior.scm | 10 +++++++--- src/psi-behavior.scm | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 5a8a596e..8c10a139 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -242,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") @@ -764,11 +763,16 @@ (SequentialAnd (SequentialOr (DefinedPredicate "Skip Interaction?") + (DefinedPredicate "Someone requests interaction?") (DefinedPredicate "Interaction requested action") + (DefinedPredicate "Did someone arrive?") (DefinedPredicate "New arrival sequence") - (DefinedPredicate "Someone left") + + (DefinedPredicate "Did someone leave?") + (DefinedPredicate "Someone left action") + (DefinedPredicate "Interact with people") (DefinedPredicate "Nothing is happening") (True)) diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index dfb0b95c..0010f850 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -51,7 +51,7 @@ ))) ;; (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") @@ -94,7 +94,7 @@ demand-satisfied (stv 1 1) face-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Someone left")) + (DefinedPredicate "Did someone leave?")) (DefinedSchemaNode "Someone left action") demand-satisfied (stv 1 1) face-demand) From cbd3198a69d6934d83ea7172bc984a140f6c6194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:17:12 +0800 Subject: [PATCH 07/26] Another conversion --- src/behavior.scm | 6 +++--- src/psi-behavior.scm | 6 +++--- src/self-model.scm | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 8c10a139..76ceb0f8 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -284,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 @@ -773,7 +770,10 @@ (DefinedPredicate "Did someone leave?") (DefinedPredicate "Someone left action") + ; True, if there is anyone visible. + (DefinedPredicate "Someone visible?") (DefinedPredicate "Interact with people") + (DefinedPredicate "Nothing is happening") (True)) diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index 0010f850..bb856c44 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -53,7 +53,7 @@ (pred-2-schema "Interaction requested action") (pred-2-schema "New arrival sequence") (pred-2-schema "Someone left action") -(pred-2-schema "Interact with people action") +(pred-2-schema "Interact with people") (pred-2-schema "Nothing is happening action") (pred-2-schema "Speech started? action") (pred-2-schema "Speech ongoing? action") @@ -99,8 +99,8 @@ demand-satisfied (stv 1 1) face-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Interact with people")) - (DefinedSchemaNode "Interact with people action") + (DefinedPredicate "Someone visible?")) + (DefinedSchemaNode "Interact with people") demand-satisfied (stv 1 1) face-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) diff --git a/src/self-model.scm b/src/self-model.scm index 0a79f28e..ce950f2f 100644 --- a/src/self-model.scm +++ b/src/self-model.scm @@ -29,7 +29,7 @@ ; (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") @@ -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 From 6ece4c6ba75484c28bcb877c5b36202c7cc0dc2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:23:46 +0800 Subject: [PATCH 08/26] the nothing is happening predicate --- src/psi-behavior.scm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index bb856c44..c54e0224 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -54,7 +54,7 @@ (pred-2-schema "New arrival sequence") (pred-2-schema "Someone left action") (pred-2-schema "Interact with people") -(pred-2-schema "Nothing is happening action") +(pred-2-schema "Nothing is happening") (pred-2-schema "Speech started? action") (pred-2-schema "Speech ongoing? action") (pred-2-schema "Speech ended? action") @@ -82,6 +82,15 @@ ;(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) +(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?")) @@ -104,8 +113,8 @@ demand-satisfied (stv 1 1) face-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Nothing is happening")) - (DefinedSchemaNode "Nothing is happening action") + (DefinedPredicate "Nothing happening?")) + (DefinedSchemaNode "Nothing is happening") demand-satisfied (stv 1 1) face-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) From 6a67797e457d2307d8ae894428737ad1b8a79dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:32:26 +0800 Subject: [PATCH 09/26] Convert the speech-started action --- src/behavior.scm | 12 +++++++----- src/psi-behavior.scm | 4 ++-- src/self-model.scm | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 76ceb0f8..2deaa412 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -553,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. @@ -782,7 +780,11 @@ ;; but the chatbot is still smiling and yabbering. ;; If interaction is turned-off need keep alive gestures (SequentialOr - (DefinedPredicate "Speech started?") + ; If the TTS vocalization started (chatbot started talking) ... + (SequentialAnd + (DefinedPredicate "chatbot started talking?") + (DefinedPredicate "Speech started")) + (DefinedPredicate "Speech ongoing?") (DefinedPredicate "Speech ended?") (DefinedPredicate "Listening started?") diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index c54e0224..e77202eb 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -118,8 +118,8 @@ demand-satisfied (stv 1 1) face-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Speech started?")) - (DefinedSchemaNode "Speech started? action") + (DefinedPredicate "chatbot started talking?")) + (DefinedSchemaNode "Speech started") speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) diff --git a/src/self-model.scm b/src/self-model.scm index ce950f2f..d312438b 100644 --- a/src/self-model.scm +++ b/src/self-model.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"))))) From 0c9189da6d9241040ab31efb578be0e0a44650bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:38:19 +0800 Subject: [PATCH 10/26] Convert the is-talking predicate --- src/behavior.scm | 12 +++++++----- src/psi-behavior.scm | 8 ++++---- src/self-model.scm | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 2deaa412..0a09d981 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -596,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 ... @@ -785,7 +783,11 @@ (DefinedPredicate "chatbot started talking?") (DefinedPredicate "Speech started")) - (DefinedPredicate "Speech ongoing?") + ; If the chatbot currently talking ... + (SequentialAnd + (DefinedPredicate "chatbot is talking?") + (DefinedPredicate "Speech ongoing")) + (DefinedPredicate "Speech ended?") (DefinedPredicate "Listening started?") (DefinedPredicate "Listening?") diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index e77202eb..f6c26395 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -55,8 +55,8 @@ (pred-2-schema "Someone left action") (pred-2-schema "Interact with people") (pred-2-schema "Nothing is happening") -(pred-2-schema "Speech started? action") -(pred-2-schema "Speech ongoing? action") +(pred-2-schema "Speech started") +(pred-2-schema "Speech ongoing") (pred-2-schema "Speech ended? action") (pred-2-schema "Listening started? action") (pred-2-schema "Listening? action") @@ -123,8 +123,8 @@ speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Speech ongoing?")) - (DefinedSchemaNode "Speech ongoing? action") + (DefinedPredicate "chatbot is talking?")) + (DefinedSchemaNode "Speech ongoing") speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) diff --git a/src/self-model.scm b/src/self-model.scm index d312438b..0f54a806 100644 --- a/src/self-model.scm +++ b/src/self-model.scm @@ -25,7 +25,7 @@ ; ; Examples and debugging hints: ; Some (but not all) state queries: -; (cog-evaluate! (DefinedPredicate "chatbot is talking")) +; (cog-evaluate! (DefinedPredicate "chatbot is talking?")) ; (cog-evaluate! (DefinedPredicate "chatbot is listening")) ; (cog-evaluate! (DefinedPredicate "chatbot is happy")) ; (cog-evaluate! (DefinedPredicateNode "Did someone arrive?")) @@ -148,7 +148,7 @@ (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"))))) From f1caaf98ef6ecad17745f5e71d1f5a66f24091ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:43:48 +0800 Subject: [PATCH 11/26] Convert the stop-talking action --- src/behavior.scm | 13 +++++++------ src/psi-behavior.scm | 6 +++--- src/self-model.scm | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 0a09d981..e6d3e246 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -654,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)) @@ -788,7 +785,11 @@ (DefinedPredicate "chatbot is talking?") (DefinedPredicate "Speech ongoing")) - (DefinedPredicate "Speech ended?") + ; If the chatbot stopped talking ... + (SequentialAnd + (DefinedPredicate "chatbot stopped talking?") + (DefinedPredicate "Speech ended")) + (DefinedPredicate "Listening started?") (DefinedPredicate "Listening?") (DefinedPredicate "Listening ended?") diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index f6c26395..5e14d62c 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -57,7 +57,7 @@ (pred-2-schema "Nothing is happening") (pred-2-schema "Speech started") (pred-2-schema "Speech ongoing") -(pred-2-schema "Speech ended? action") +(pred-2-schema "Speech ended") (pred-2-schema "Listening started? action") (pred-2-schema "Listening? action") (pred-2-schema "Listening ended? action") @@ -128,8 +128,8 @@ speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Speech ended?")) - (DefinedSchemaNode "Speech ended? action") + (DefinedPredicate "chatbot stopped talking?")) + (DefinedSchemaNode "Speech ended") speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) diff --git a/src/self-model.scm b/src/self-model.scm index 0f54a806..59618f6e 100644 --- a/src/self-model.scm +++ b/src/self-model.scm @@ -153,7 +153,7 @@ (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"))))) From c1d37970654ec942bbcf9025d7b364cd772d527c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:49:10 +0800 Subject: [PATCH 12/26] convert the listening action --- src/behavior.scm | 13 ++++++++----- src/psi-behavior.scm | 6 +++--- src/self-model.scm | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index e6d3e246..93a1ac11 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -572,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. @@ -790,7 +790,10 @@ (DefinedPredicate "chatbot stopped talking?") (DefinedPredicate "Speech ended")) - (DefinedPredicate "Listening started?") + (SequentialAnd + (DefinedPredicate "chatbot started listening?") + (DefinedPredicate "Listening started")) + (DefinedPredicate "Listening?") (DefinedPredicate "Listening ended?") (SequentialAnd diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index 5e14d62c..74d0b6c6 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -58,7 +58,7 @@ (pred-2-schema "Speech started") (pred-2-schema "Speech ongoing") (pred-2-schema "Speech ended") -(pred-2-schema "Listening started? action") +(pred-2-schema "Listening started") (pred-2-schema "Listening? action") (pred-2-schema "Listening ended? action") (pred-2-schema "Keep alive") @@ -133,8 +133,8 @@ speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Listening started?")) - (DefinedSchemaNode "Listening started? action") + (DefinedPredicate "chatbot started listening?")) + (DefinedSchemaNode "Listening started") speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) diff --git a/src/self-model.scm b/src/self-model.scm index 59618f6e..15fa0d36 100644 --- a/src/self-model.scm +++ b/src/self-model.scm @@ -158,7 +158,7 @@ (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"))))) From 42607b83b98a06f6412db25e3b9dae2dec86afe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:53:16 +0800 Subject: [PATCH 13/26] Perform the ongoing-lisgten action --- src/behavior.scm | 12 +++++++----- src/psi-behavior.scm | 6 +++--- src/self-model.scm | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 93a1ac11..09d7e407 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -701,11 +701,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") @@ -794,7 +792,11 @@ (DefinedPredicate "chatbot started listening?") (DefinedPredicate "Listening started")) - (DefinedPredicate "Listening?") + ; If the chatbot stopped talking ... + (SequentialAnd + (DefinedPredicate "chatbot is listening") + (DefinedPredicate "Listening ongoing")) + (DefinedPredicate "Listening ended?") (SequentialAnd (DefinedPredicate "Skip Interaction?") diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index 74d0b6c6..e86008f1 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -59,7 +59,7 @@ (pred-2-schema "Speech ongoing") (pred-2-schema "Speech ended") (pred-2-schema "Listening started") -(pred-2-schema "Listening? action") +(pred-2-schema "Listening ongoing") (pred-2-schema "Listening ended? action") (pred-2-schema "Keep alive") ;; @@ -138,8 +138,8 @@ speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Listening?")) - (DefinedSchemaNode "Listening? action") + (DefinedPredicate "chatbot is listening?")) + (DefinedSchemaNode "Listening ongoing") speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) diff --git a/src/self-model.scm b/src/self-model.scm index 15fa0d36..9642c736 100644 --- a/src/self-model.scm +++ b/src/self-model.scm @@ -163,7 +163,7 @@ (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"))))) From 2b803fb920e37f27ede152e3cc204d2022068a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:56:24 +0800 Subject: [PATCH 14/26] Concert the stop-listening action --- src/behavior.scm | 13 +++++++------ src/psi-behavior.scm | 6 +++--- src/self-model.scm | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 09d7e407..7e7daa17 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -676,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)) @@ -797,7 +794,11 @@ (DefinedPredicate "chatbot is listening") (DefinedPredicate "Listening ongoing")) - (DefinedPredicate "Listening ended?") + ; If the chatbot stopped talking ... + (SequentialAnd + (DefinedPredicate "chatbot stopped listening") + (DefinedPredicate "Listening ended")) + (SequentialAnd (DefinedPredicate "Skip Interaction?") (DefinedPredicate "Keep alive") diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index e86008f1..a41b5b62 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -60,7 +60,7 @@ (pred-2-schema "Speech ended") (pred-2-schema "Listening started") (pred-2-schema "Listening ongoing") -(pred-2-schema "Listening ended? action") +(pred-2-schema "Listening ended") (pred-2-schema "Keep alive") ;; ;(DefineLink (DefinedPredicateNode "do-noop") (True)) @@ -143,8 +143,8 @@ speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) - (DefinedPredicate "Listening ended?")) - (DefinedSchemaNode "Listening ended? action") + (DefinedPredicate "chatbot stopped listening?")) + (DefinedSchemaNode "Listening ended") speech-demand-satisfied (stv 1 1) speech-demand) (psi-rule (list (DefinedPredicate "Skip Interaction?")) diff --git a/src/self-model.scm b/src/self-model.scm index 9642c736..5ab55079 100644 --- a/src/self-model.scm +++ b/src/self-model.scm @@ -168,7 +168,7 @@ (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"))))) From 3fc333e54336bd83976a3c2945b12e79ef7b3d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 12:58:44 +0800 Subject: [PATCH 15/26] whitespace --- src/behavior.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 7e7daa17..930201e7 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -801,8 +801,8 @@ (SequentialAnd (DefinedPredicate "Skip Interaction?") - (DefinedPredicate "Keep alive") - ) + (DefinedPredicate "Keep alive")) + (True) ) From e65987a157446002963efab67d27c6007cb06c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 13:08:15 +0800 Subject: [PATCH 16/26] Remove commented-out code --- src/psi-behavior.scm | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index a41b5b62..0b3df4e7 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -9,33 +9,6 @@ (use-modules (opencog openpsi)) ; ;; ------------------------------------------------------------------ -;; Main loop. -; (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) -; ) (define (foobar x) (display "duuuuuuuude wtf foobar\n") @@ -72,16 +45,6 @@ (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) - (DefineLink (DefinedPredicate "Nothing happening?") (NotLink From a8c01cc6890101e8f48f63b3fa8d35d9b912ce71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 13:12:40 +0800 Subject: [PATCH 17/26] whitespace --- src/psi-behavior.scm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index 0b3df4e7..43062bca 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -11,7 +11,7 @@ ;; ------------------------------------------------------------------ (define (foobar x) -(display "duuuuuuuude wtf foobar\n") +(display "duuuuuuuude foobar pred-schema wrapper\n") (display x) (newline) (cog-evaluate! x) (Node "bad value")) @@ -55,57 +55,57 @@ (DefinedPredicate "Someone visible?")))) -(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) +(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?")) +(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?")) +(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?")) +(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?")) +(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?")) +(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?")) +(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?")) +(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?")) +(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?")) +(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?")) +(psi-rule (list (NotLink (DefinedPredicate "Skip Interaction?")) (DefinedPredicate "chatbot stopped listening?")) (DefinedSchemaNode "Listening ended") speech-demand-satisfied (stv 1 1) speech-demand) From 2dec140af24407a779763174482b2e68ee3fde83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 13:34:41 +0800 Subject: [PATCH 18/26] There are no run demands --- src/psi-behavior.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psi-behavior.scm b/src/psi-behavior.scm index 43062bca..11045416 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -43,7 +43,7 @@ (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)) +; (define run-demand (psi-demand "run demand" 1)) (DefineLink (DefinedPredicate "Nothing happening?") From 4aa73fc9351bf99f23464c9edbe161b9c34ef11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 13:38:49 +0800 Subject: [PATCH 19/26] Bad indentation --- src/atomic-dbg.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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(): From 64cd9990d05d6cc75fe3690396e4060096632917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 13:59:22 +0800 Subject: [PATCH 20/26] Add more missing stanzas --- src/cfg-eva.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cfg-eva.scm b/src/cfg-eva.scm index 386353b3..c86eb631 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 From 29d3932161c4655ae3d535ec0a17f39589940b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 14:11:31 +0800 Subject: [PATCH 21/26] More missing stanzas --- src/cfg-eva.scm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cfg-eva.scm b/src/cfg-eva.scm index c86eb631..c257e754 100644 --- a/src/cfg-eva.scm +++ b/src/cfg-eva.scm @@ -168,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. From 54c4a523bb77cc72251b29410002ebfda48ba6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 15:37:44 +0800 Subject: [PATCH 22/26] Add missing conversions --- src/behavior.scm | 6 +++--- src/btree-psi.scm | 4 ++-- src/self-model.scm | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 930201e7..80a8c91f 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 @@ -791,12 +791,12 @@ ; If the chatbot stopped talking ... (SequentialAnd - (DefinedPredicate "chatbot is listening") + (DefinedPredicate "chatbot is listening?") (DefinedPredicate "Listening ongoing")) ; If the chatbot stopped talking ... (SequentialAnd - (DefinedPredicate "chatbot stopped listening") + (DefinedPredicate "chatbot stopped listening?") (DefinedPredicate "Listening ended")) (SequentialAnd diff --git a/src/btree-psi.scm b/src/btree-psi.scm index 095665d1..adca545e 100644 --- a/src/btree-psi.scm +++ b/src/btree-psi.scm @@ -42,8 +42,8 @@ ; 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-sophia.scm") ;;; <<<=== See, its Sophia 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") diff --git a/src/self-model.scm b/src/self-model.scm index 5ab55079..ce4d0fef 100644 --- a/src/self-model.scm +++ b/src/self-model.scm @@ -26,7 +26,7 @@ ; 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 listening?")) ; (cog-evaluate! (DefinedPredicate "chatbot is happy")) ; (cog-evaluate! (DefinedPredicateNode "Did someone arrive?")) ; (cog-evaluate! (DefinedPredicateNode "Someone visible?")) @@ -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) From 8e362f586dd8e36c9d011b6b44e31e7b91f2c569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 16:26:34 +0800 Subject: [PATCH 23/26] Avoid a crash --- src/self-model.scm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/self-model.scm b/src/self-model.scm index ce4d0fef..10ed509f 100644 --- a/src/self-model.scm +++ b/src/self-model.scm @@ -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. From 269fd60611277a9b26ace28aae689820ffd7e214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 16:42:19 +0800 Subject: [PATCH 24/26] Bug fix --- src/behavior.scm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/behavior.scm b/src/behavior.scm index 80a8c91f..1f3cecda 100644 --- a/src/behavior.scm +++ b/src/behavior.scm @@ -197,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") @@ -749,18 +749,22 @@ (SequentialOr (DefinedPredicate "Skip Interaction?") - (DefinedPredicate "Someone requests interaction?") - (DefinedPredicate "Interaction requested action") + (SequentialAnd + (DefinedPredicate "Someone requests interaction?") + (DefinedPredicate "Interaction requested action")) - (DefinedPredicate "Did someone arrive?") - (DefinedPredicate "New arrival sequence") + (SequentialAnd + (DefinedPredicate "Did someone arrive?") + (DefinedPredicate "New arrival sequence")) - (DefinedPredicate "Did someone leave?") - (DefinedPredicate "Someone left action") + (SequentialAnd + (DefinedPredicate "Did someone leave?") + (DefinedPredicate "Someone left action")) ; True, if there is anyone visible. - (DefinedPredicate "Someone visible?") - (DefinedPredicate "Interact with people") + (SequentialAnd + (DefinedPredicate "Someone visible?") + (DefinedPredicate "Interact with people")) (DefinedPredicate "Nothing is happening") (True)) From 10a5738799f14649284d02ea8cbd7b285d03eda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 16:47:53 +0800 Subject: [PATCH 25/26] Remove some debug prints --- src/btree-psi.scm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/btree-psi.scm b/src/btree-psi.scm index adca545e..4bc0e490 100644 --- a/src/btree-psi.scm +++ b/src/btree-psi.scm @@ -56,20 +56,15 @@ (DefinedPredicate loop-name) (SatisfactionLink (SequentialAnd -(Evaluation (GroundedPredicate "scm: wtf") (ListLink (Node "start"))) (Evaluation (GroundedPredicate "scm: psi-step") (ListLink)) -(Evaluation (GroundedPredicate "scm: wtf") (ListLink (Node "middle"))) (Evaluation (GroundedPredicate "scm: psi-run-continue?") (ListLink)) -(Evaluation (GroundedPredicate "scm: wtf") (ListLink (Node "more"))) ; If ROS is dead, or the continue flag not set, ; then stop running the behavior loop. (DefinedPredicate "ROS is running?") -(Evaluation (GroundedPredicate "scm: wtf") (ListLink (Node "tail"))) (DefinedPredicate loop-name)))) -(define (wtf x) (display "heyyyyy\n") (display x)(newline) (stv 1 1)) ;; Call (run) to run the main loop, (halt) to pause the loop. ;; The main loop runs in its own thread. (define (run) (psi-run)) From af05bc22a7e1b81f67ec8d255bb533b216af074d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 Jun 2016 18:31:55 +0800 Subject: [PATCH 26/26] Stub out debug print --- src/README.md | 8 ++++++++ src/psi-behavior.scm | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) 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/psi-behavior.scm b/src/psi-behavior.scm index 11045416..74613eb5 100644 --- a/src/psi-behavior.scm +++ b/src/psi-behavior.scm @@ -11,8 +11,8 @@ ;; ------------------------------------------------------------------ (define (foobar x) -(display "duuuuuuuude foobar pred-schema wrapper\n") -(display x) (newline) +; (display "duuuuuuuude foobar pred-schema wrapper\n") +; (display x) (newline) (cog-evaluate! x) (Node "bad value")) ;;