|
| 1 | +; |
| 2 | +; psi-behvaior.scm |
| 3 | +(use-modules (ice-9 format)) |
| 4 | + |
| 5 | + |
| 6 | +(add-to-load-path "/usr/local/share/opencog/scm") |
| 7 | +(use-modules (opencog)) |
| 8 | +(use-modules (opencog exec)) |
| 9 | +(use-modules (opencog openpsi)) |
| 10 | +; |
| 11 | +;; |
| 12 | +(define (pred-2-schema pnode-str) |
| 13 | + (DefineLink |
| 14 | + (DefinedSchemaNode pnode-str) |
| 15 | + (ExecutionOutputLink (GroundedSchemaNode "scm: cog-evaluate!") |
| 16 | + (ListLink (DefinedPredicateNode pnode-str)) |
| 17 | +))) |
| 18 | +;; |
| 19 | +(pred-2-schema "Interaction requested action") |
| 20 | +(pred-2-schema "New arrival sequence action") |
| 21 | +(pred-2-schema "Someone left action") |
| 22 | +(pred-2-schema "Interact with people action") |
| 23 | +(pred-2-schema "Nothing is happening action") |
| 24 | +(pred-2-schema "Speech started? action") |
| 25 | +(pred-2-schema "Speech ongoing? action") |
| 26 | +(pred-2-schema "Speech ended? action") |
| 27 | +(pred-2-schema "Listening started? action") |
| 28 | +(pred-2-schema "Listening? action") |
| 29 | +(pred-2-schema "Listening ended? action") |
| 30 | +(pred-2-schema "Keep alive") |
| 31 | +;; |
| 32 | +;(DefineLink (DefinedPredicateNode "do-noop") (True)) |
| 33 | +;(pred-2-schema "do-noop") |
| 34 | + |
| 35 | +(define demand-satisfied (True)) |
| 36 | +(define speech-demand-satisfied (True)) |
| 37 | +(define face-demand (psi-demand "face interaction" 1)) |
| 38 | +(define speech-demand (psi-demand "speech interaction" 1)) |
| 39 | +(define run-demand (psi-demand "run demand" 1)) |
| 40 | + |
| 41 | +;(psi-rule (list (DefinedPredicate "Interaction requested"))(DefinedSchemaNode "Interaction requested action") demand-satisfied (stv 1 1) face-demand) |
| 42 | +;(psi-rule (list (DefinedPredicate "New arrival sequence")) (DefinedSchemaNode "New arrival sequence action") demand-satisfied (stv 1 1) face-demand) |
| 43 | +;(psi-rule (list (DefinedPredicate "Someone left")) (DefinedSchemaNode "Someone left action") demand-satisfied (stv 1 1) face-demand) |
| 44 | +;(psi-rule (list (DefinedPredicate "Interact with people")) (DefinedSchemaNode "Interact with people action") demand-satisfied (stv 1 1) face-demand) |
| 45 | +;(psi-rule (list (DefinedPredicate "Nothing is happening")) (DefinedSchemaNode "Nothing is happening action") demand-satisfied (stv 1 1) face-demand) |
| 46 | +;(psi-rule (list (DefinedPredicate "Speech started?")) (DefinedSchemaNode "Speech started? action") speech-demand-satisfied (stv 1 1) speech-demand) |
| 47 | +;(psi-rule (list (DefinedPredicate "Speech ongoing?")) (DefinedSchemaNode "Speech ongoing? action") speech-demand-satisfied (stv 1 1) speech-demand) |
| 48 | +;(psi-rule (list (DefinedPredicate "Speech ended?")) (DefinedSchemaNode "Speech ended? action") speech-demand-satisfied (stv 1 1) speech-demand) |
| 49 | +;(psi-rule (list (DefinedPredicate "Skip Interaction?")) (DefinedSchemaNode "Keep alive") speech-demand-satisfied (stv 1 1) speech-demand) |
| 50 | + |
| 51 | + |
| 52 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 53 | + (DefinedPredicate "Interaction requested")) |
| 54 | + (DefinedSchemaNode "Interaction requested action") |
| 55 | + demand-satisfied (stv 1 1) face-demand) |
| 56 | + |
| 57 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 58 | + (DefinedPredicate "New arrival sequence")) |
| 59 | + (DefinedSchemaNode "New arrival sequence action") |
| 60 | + demand-satisfied (stv 1 1) face-demand) |
| 61 | + |
| 62 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 63 | + (DefinedPredicate "Someone left")) |
| 64 | + (DefinedSchemaNode "Someone left action") |
| 65 | + demand-satisfied (stv 1 1) face-demand) |
| 66 | + |
| 67 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 68 | + (DefinedPredicate "Interact with people")) |
| 69 | + (DefinedSchemaNode "Interact with people action") |
| 70 | + demand-satisfied (stv 1 1) face-demand) |
| 71 | + |
| 72 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 73 | + (DefinedPredicate "Nothing is happening")) |
| 74 | + (DefinedSchemaNode "Nothing is happening action") |
| 75 | + demand-satisfied (stv 1 1) face-demand) |
| 76 | + |
| 77 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 78 | + (DefinedPredicate "Speech started?")) |
| 79 | + (DefinedSchemaNode "Speech started? action") |
| 80 | + speech-demand-satisfied (stv 1 1) speech-demand) |
| 81 | + |
| 82 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 83 | + (DefinedPredicate "Speech ongoing?")) |
| 84 | + (DefinedSchemaNode "Speech ongoing? action") |
| 85 | + speech-demand-satisfied (stv 1 1) speech-demand) |
| 86 | + |
| 87 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 88 | + (DefinedPredicate "Speech ended?")) |
| 89 | + (DefinedSchemaNode "Speech ended? action") |
| 90 | + speech-demand-satisfied (stv 1 1) speech-demand) |
| 91 | + |
| 92 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 93 | + (DefinedPredicate "Listening started?")) |
| 94 | + (DefinedSchemaNode "Listening started? action") |
| 95 | + speech-demand-satisfied (stv 1 1) speech-demand) |
| 96 | + |
| 97 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 98 | + (DefinedPredicate "Listening?")) |
| 99 | + (DefinedSchemaNode "Listening? action") |
| 100 | + speech-demand-satisfied (stv 1 1) speech-demand) |
| 101 | + |
| 102 | +(psi-rule (list (NotLink(DefinedPredicate "Skip Interaction?")) |
| 103 | + (DefinedPredicate "Listening ended?")) |
| 104 | + (DefinedSchemaNode "Listening ended? action") |
| 105 | + speech-demand-satisfied (stv 1 1) speech-demand) |
| 106 | + |
| 107 | +(psi-rule (list (DefinedPredicate "Skip Interaction?")) |
| 108 | + (DefinedSchemaNode "Keep alive") |
| 109 | + speech-demand-satisfied (stv 1 1) speech-demand) |
| 110 | + |
| 111 | +;; ------------------------------------------------------------------ |
| 112 | +;; Main loop. Uses tail recursion optimization to form the loop. |
| 113 | +(DefineLink |
| 114 | + (DefinedPredicate "main loop") |
| 115 | + (SatisfactionLink |
| 116 | + (SequentialAnd |
| 117 | +; (SequentialOr |
| 118 | +; (DefinedPredicate "Skip Interaction?") |
| 119 | +; (DefinedPredicate "Interaction requested") |
| 120 | +; (DefinedPredicate "New arrival sequence") |
| 121 | +; (DefinedPredicate "Someone left") |
| 122 | +; (DefinedPredicate "Interact with people") |
| 123 | +; (DefinedPredicate "Nothing is happening") |
| 124 | +; (True)) |
| 125 | + |
| 126 | +; ;; XXX FIXME chatbot is disengaged from everything else. |
| 127 | +; ;; The room can be empty, the head is bored or even asleep, |
| 128 | +; ;; but the chatbot is still smiling and yabbering. |
| 129 | +; ;; If interaction is turned-off need keep alive gestures |
| 130 | +; (SequentialOr |
| 131 | +; (DefinedPredicate "Speech started?") |
| 132 | +; (DefinedPredicate "Speech ongoing?") |
| 133 | +; (DefinedPredicate "Speech ended?") |
| 134 | +; (DefinedPredicate "Listening started?") |
| 135 | +; (DefinedPredicate "Listening?") |
| 136 | +; (DefinedPredicate "Listening ended?") |
| 137 | +; (SequentialAnd |
| 138 | +; (DefinedPredicate "Skip Interaction?") |
| 139 | +; (DefinedPredicate "Keep alive") |
| 140 | +; ) |
| 141 | +; (True) |
| 142 | +; ) |
| 143 | + |
| 144 | + ; If ROS is dead, or the continue flag not set, then stop |
| 145 | + ; running the behavior loop. |
| 146 | + (DefinedPredicate "Continue running loop?") |
| 147 | + (DefinedPredicate "ROS is running?") |
| 148 | + |
| 149 | + ;; Call self -- tail-recurse. |
| 150 | + (DefinedPredicate "main loop") |
| 151 | + ))) |
| 152 | + |
| 153 | +; ---------------------------------------------------------------------- |
0 commit comments