Please note that active projects have migrated to https://github.com/fawkesrobotics.

Merge remote-tracking branch 'origin/thofmann/clips-executive-nonunique-action-ids'
authorTim Niemueller <niemueller@kbsg.rwth-aachen.de>
Fri, 9 Mar 2018 13:07:02 +0000 (14:07 +0100)
committerTim Niemueller <niemueller@kbsg.rwth-aachen.de>
Fri, 9 Mar 2018 13:35:07 +0000 (14:35 +0100)
1  2 
src/plugins/clips-executive/clips/domain.clp
src/plugins/clips-executive/clips/plan.clp
src/plugins/clips-executive/clips/test-scenario/fixed-sequence.clp
src/plugins/clips-executive/clips/tests/test_domain.cpp

    "Ground a non-atomic precondition. Grounding here merely means that we
     duplicate the precondition and tie it to one specific action-id."
    (not (domain-wm-update))
-   (plan-action (action-name ?op) (id ?action-id) 
 -  (plan-action (action-name ?op) (goal-id ?g) (plan-id ?p) (id ?action-id))
++  (plan-action (action-name ?op) (goal-id ?g) (plan-id ?p) (id ?action-id)
 +    (status FORMULATED|PENDING|WAITING))
    ?precond <- (domain-precondition
                  (name ?precond-name)
                  (part-of ?op)
    (return ?values)
  )
  
+ ; TODO: ?action-name should be ?op
  (defrule domain-effects-check-for-sensed
    "Apply effects of an action after it succeeded."
-   ?pa <- (plan-action (id ?id) (action-name ?op) (status EXECUTION-SUCCEEDED)
-                                                                                       (param-names $?action-param-names) (param-values $?action-param-values))
+   ?pa <- (plan-action (id ?id) (goal-id ?g) (plan-id ?p) (action-name ?op)
+                       (status EXECUTION-SUCCEEDED)
+                                                                                       (param-names $?action-param-names)
+                       (param-values $?action-param-values))
 -      (domain-operator (name ?action-name) (wait-sensed TRUE))
 +      (domain-operator (name ?op) (wait-sensed TRUE))
        =>
        (bind ?next-state SENSED-EFFECTS-HOLD)
-       (do-for-all-facts ((?e domain-effect) (?p domain-predicate))
-               (and ?p:sensed (eq ?e:part-of ?op) (eq ?e:predicate ?p:name))
+       (do-for-all-facts ((?e domain-effect) (?pred domain-predicate))
+               (and ?pred:sensed (eq ?e:part-of ?op) (eq ?e:predicate ?pred:name))
                ; apply if this effect is unconditional or the condition is satisfied
                (if (or (not (any-factp ((?cep domain-precondition)) (eq ?cep:part-of ?e:name)))
                                                (any-factp ((?cep domain-precondition))
  
  (defrule domain-effects-ignore-sensed
    "Apply effects of an action after it succeeded."
-   ?pa <- (plan-action (id ?id) (action-name ?op) (status EXECUTION-SUCCEEDED)
-                                                                                       (param-names $?action-param-names) (param-values $?action-param-values))
+   ?pa <- (plan-action (id ?id) (action-name ?op) (status EXECUTION-SUCCEEDED))
 -      (domain-operator (name ?action-name) (wait-sensed FALSE))
 +      (domain-operator (name ?op) (wait-sensed FALSE))
        =>
        (modify ?pa (status SENSED-EFFECTS-HOLD))
  )
  ; Atomically assert all effects of an action after it has been executed.
  (defrule domain-effects-apply
    "Apply effects of an action after it succeeded."
-   ?pa <- (plan-action (id ?id) (action-name ?op) (status SENSED-EFFECTS-HOLD)
-                                                                                       (param-names $?action-param-names) (param-values $?action-param-values))
+   ?pa <- (plan-action (id ?id) (goal-id ?g) (plan-id ?p) (action-name ?op)
+                       (status SENSED-EFFECTS-HOLD)
+                                                                                       (param-names $?action-param-names)
+                       (param-values $?action-param-values))
 -      (domain-operator (name ?action-name))
 +      (domain-operator (name ?op))
        =>
-       (do-for-all-facts ((?e domain-effect) (?p domain-predicate))
-               (and (not ?p:sensed) (eq ?e:part-of ?op) (eq ?e:predicate ?p:name))
+       (do-for-all-facts ((?e domain-effect) (?pred domain-predicate))
+               (and (not ?pred:sensed) (eq ?e:part-of ?op) (eq ?e:predicate ?pred:name))
  
                ; apply if this effect is unconditional or the condition is satisfied
                (if (or (not (any-factp ((?cep domain-precondition)) (eq ?cep:part-of ?e:name)))
  
                        (if (eq ?e:type POSITIVE)
                         then
-                               (assert (domain-fact (name ?p:name) (param-values ?values)))
+                               (assert (domain-fact (name ?pred:name) (param-values ?values)))
                         else
 -                              (assert (domain-retracted-fact (name ?pred:name)
 -                                       (param-values ?values)))
 +                              (delayed-do-for-all-facts ((?df domain-fact))
-                                       (and (eq ?df:name ?p:name) (eq ?df:param-values ?values))
++                                      (and (eq ?df:name ?pred:name) (eq ?df:param-values ?values))
 +
 +                                      (retract ?df)
 +                              )
                        )
                )
        )
@@@ -4,18 -4,23 +4,24 @@@
        =>
        (assert
                (plan (id TESTGOAL-PLAN) (goal-id TESTGOAL))
-               (plan-action (id 1) (plan-id TESTGOAL-PLAN) (duration 4.0)
+               (plan-action (id 1) (goal-id TESTGOAL) (plan-id TESTGOAL-PLAN)
+                  (duration 4.0)
                             (action-name say-hello)
 -                           (param-names name) (param-values "Peggy"))
 +                           (param-names name) (param-values peggy))
-               (plan-action (id 2) (plan-id TESTGOAL-PLAN) (duration 4.0)
+               (plan-action (id 2) (goal-id TESTGOAL) (plan-id TESTGOAL-PLAN)
 -                 (duration 4.0)
++                           (duration 4.0)
                             (action-name print)
--                                                               (param-names severity text) (param-values warn "This is a print test"))
-               (plan-action (id 3) (plan-id TESTGOAL-PLAN) (duration 4.0)
++                                                               (param-names severity text)
++                           (param-values warn "This is a print test"))
+               (plan-action (id 3) (goal-id TESTGOAL) (plan-id TESTGOAL-PLAN)
 -                 (duration 4.0)
 -                           (action-name say-goodbye))
++                           (duration 4.0)
 +                           (action-name say-goodbye) (param-values peggy))
-               (plan-action (id 4) (plan-id TESTGOAL-PLAN) (duration 4.0)
+               (plan-action (id 4) (goal-id TESTGOAL) (plan-id TESTGOAL-PLAN)
 -                 (duration 4.0)
++                           (duration 4.0)
                             (action-name say-hello-again)
 -                           (param-names name) (param-values "Peggy"))
 +                           (param-names name) (param-values peggy))
-               (plan-action (id 5) (plan-id TESTGOAL-PLAN) (duration 4.0)
+               (plan-action (id 5) (goal-id TESTGOAL) (plan-id TESTGOAL-PLAN)
 -                 (duration 4.0)
++                           (duration 4.0)
                             (action-name say-cleanup))
        )
        (modify ?g (mode EXPANDED))