Changes have been pushed for the repository "fawkes.git".
(Fawkes Robotics Software Framework)

Clone:  g...@git.fawkesrobotics.org:fawkes.git
Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, thofmann/clips-executive-nonunique-action-ids has been created
        at  6721a9095d76e5f50fc365ce2fa5c9bde90b608d (commit)

http://git.fawkesrobotics.org/fawkes.git/thofmann/clips-executive-nonunique-action-ids

- *Log* ---------------------------------------------------------------
commit 222a1ae737b3e77fe4ad6c4262302843986f3f41
Author:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
AuthorDate: Wed Mar 7 18:51:42 2018 +0100
Commit:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
CommitDate: Wed Mar 7 19:31:26 2018 +0100

    clips-executive: action IDs are only unique for a fixed goal and plan
    
    Action IDs are no longer unique globally, but  for a given goal and
    plan. Similarly, plan IDs are no longer unique globally, but only for a
    given goal.
    
    Adapt precondition grounding and checking and effect application such
    that it always checks the goal ID and plan ID. All plan-actions now
    always need to refer to a goal and a plan.
    
    Also modify the test scenario and all tests to the change and add a test
    that checks that we only apply effects for the right action, even if
    there is a second action with the same action ID.

http://git.fawkesrobotics.org/fawkes.git/commit/222a1ae
http://trac.fawkesrobotics.org/changeset/222a1ae

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 6721a9095d76e5f50fc365ce2fa5c9bde90b608d
Author:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
AuthorDate: Wed Mar 7 19:19:16 2018 +0100
Commit:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
CommitDate: Wed Mar 7 19:31:42 2018 +0100

    clips-executive: add goal-ids to plan-actions of PDDL plans
    
    When parsing the result of the planner, also fill the goal-id slot of
    the plan-action so a plan-action is always associated with a goal.
    
    Since we no longer need to have globally unique action IDs, remove the
    offset computation for the action IDs for PDDL actions.

http://git.fawkesrobotics.org/fawkes.git/commit/6721a90
http://trac.fawkesrobotics.org/changeset/6721a90

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/plugins/clips-executive/clips/pddl.clp |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* 222a1ae737b3e77fe4ad6c4262302843986f3f41 - - - - - - - - - -
Author:  Till Hofmann <hofm...@kbsg.rwth-aachen.de>
Date:    Wed Mar 7 18:51:42 2018 +0100
Subject: clips-executive: action IDs are only unique for a fixed goal and plan

 src/plugins/clips-executive/clips/domain.clp       |  108 ++++++++++++++------
 src/plugins/clips-executive/clips/plan.clp         |    2 +
 .../clips/test-scenario/fixed-sequence.clp         |   15 ++-
 .../clips-executive/clips/tests/blocksworld.clp    |    8 +-
 .../clips/tests/conditional_say.clp                |    4 +-
 .../clips-executive/clips/tests/test_domain.cpp    |   47 ++++++++-
 6 files changed, 139 insertions(+), 45 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-executive/clips/domain.clp 
b/src/plugins/clips-executive/clips/domain.clp
index 090e929..ae3a807 100644
--- a/src/plugins/clips-executive/clips/domain.clp
+++ b/src/plugins/clips-executive/clips/domain.clp
@@ -80,6 +80,10 @@
 (deftemplate domain-pending-sensed-fact
   "An action effect of a sensed predicate that is still pending."
   (slot name (type SYMBOL) (default ?NONE))
+  (slot goal-id (type SYMBOL))
+  (slot plan-id (type SYMBOL))
+  ; TODO: Rename to action for consistency. Do this when we no longer need to
+  ; stay compatible with lab course code.
   (slot action-id (type INTEGER))
   (slot type (type SYMBOL) (allowed-values POSITIVE NEGATIVE)
     (default POSITIVE))
@@ -116,6 +120,10 @@
    precondition belongs to. Note that grounded should always be yes if the
    action is not nil."
   (slot part-of (type SYMBOL))
+  (slot goal-id (type SYMBOL))
+  (slot plan-id (type SYMBOL))
+  ; TODO: Rename to action for consistency. Do this when we no longer need to
+  ; stay compatible with lab course code.
   (slot grounded-with (type INTEGER) (default 0))
   (slot name (type SYMBOL) (default-dynamic (gensym*)))
   (slot type (type SYMBOL) (allowed-values conjunction negation))
@@ -133,6 +141,10 @@
    See the tests for an example.
 "
   (slot part-of (type SYMBOL))
+  (slot goal-id (type SYMBOL))
+  (slot plan-id (type SYMBOL))
+  ; TODO: Rename to action for consistency. Do this when we no longer need to
+  ; stay compatible with lab course code.
   (slot grounded-with (type INTEGER) (default 0))
   (slot name (type SYMBOL) (default-dynamic (gensym*)))
   (slot predicate (type SYMBOL))
@@ -203,31 +215,35 @@
   "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))
   ?precond <- (domain-precondition
                 (name ?precond-name)
                 (part-of ?op)
                 (grounded FALSE))
-  (not (domain-precondition
-        (name ?precond-name) (grounded-with ?action-id) (grounded TRUE)))
+  (not (domain-precondition (name ?precond-name) (goal-id ?g) (plan-id ?p)
+        (grounded-with ?action-id) (grounded TRUE)))
 =>
-  (duplicate ?precond (grounded-with ?action-id) (grounded TRUE))
+  (duplicate ?precond
+    (goal-id ?g) (plan-id ?p) (grounded-with ?action-id)
+    (grounded TRUE))
 )
 
 (defrule domain-ground-effect-precondition
   "Ground a non-atomic precondition. Grounding here merely means that we
    duplicate the precondition and tie it to one specific effect-id."
   (not (domain-wm-update))
-  (plan-action (action-name ?op) (id ?action-id) (status EXECUTION-SUCCEEDED))
+  (plan-action (action-name ?op) (id ?action-id) (goal-id ?g) (plan-id ?p)
+    (status EXECUTION-SUCCEEDED))
   (domain-effect (name ?effect-name) (part-of ?op))
   ?precond <- (domain-precondition
                 (name ?precond-name)
                 (part-of ?effect-name)
                 (grounded FALSE))
-  (not (domain-precondition
-        (name ?precond-name) (grounded-with ?action-id) (grounded TRUE)))
+  (not (domain-precondition (name ?precond-name) (goal-id ?g) (plan-id ?p)
+         (grounded-with ?action-id) (grounded TRUE)))
 =>
-  (duplicate ?precond (grounded-with ?action-id) (grounded TRUE))
+  (duplicate ?precond (goal-id ?g) (plan-id ?p) (grounded-with ?action-id)
+    (grounded TRUE))
 )
 
 (defrule domain-ground-nested-precondition
@@ -238,13 +254,17 @@
                 (name ?precond-name)
                 (part-of ?parent)
                 (grounded FALSE))
-  (domain-precondition (name ?parent) (grounded-with ?action-id&~0))
+  (domain-precondition (name ?parent) (goal-id ?g&~nil) (plan-id ?p&~nil)
+    (grounded-with ?action-id&~0))
   (not (domain-precondition
         (name ?precond-name)
+        (goal-id ?g)
+        (plan-id ?p)
         (grounded-with ?action-id)
         (grounded TRUE)))
 =>
-  (duplicate ?precond (grounded-with ?action-id) (grounded TRUE))
+  (duplicate ?precond (goal-id ?g) (plan-id ?p) (grounded-with ?action-id)
+    (grounded TRUE))
 )
 
 (defrule domain-ground-atomic-precondition
@@ -255,7 +275,7 @@
     (param-names $?action-param-names)
     (id ?action-id)
     (param-values $?action-values))
-  (domain-precondition (name ?parent)
+  (domain-precondition (name ?parent) (goal-id ?g&~nil) (plan-id ?p&~nil)
     (grounded-with ?action-id&~0) (grounded TRUE))
   ?precond <- (domain-atomic-precondition
                 (part-of ?parent)
@@ -265,6 +285,8 @@
                 (grounded FALSE)
               )
   (not (domain-atomic-precondition
+        (goal-id ?g)
+        (plan-id ?p)
         (grounded-with ?action-id)
         (name ?precond-name)
         (grounded TRUE)))
@@ -288,7 +310,8 @@
     )
   )
   (duplicate ?precond
-    (param-values ?values) (grounded-with ?action-id) (grounded TRUE))
+    (param-values ?values) (goal-id ?g) (plan-id ?p)
+    (grounded-with ?action-id) (grounded TRUE))
 )
 
 (deffunction intersect
@@ -305,6 +328,7 @@
 
 (defrule domain-check-if-atomic-precondition-is-satisfied
   ?precond <- (domain-atomic-precondition
+                (goal-id ?g) (plan-id ?p)
                 (is-satisfied FALSE)
                 (predicate ?pred)
                 (param-values $?params)
@@ -321,14 +345,18 @@
   ?precond <- (domain-precondition
                 (type negation)
                 (grounded TRUE)
+                (goal-id ?g)
+                (plan-id ?p)
                 (grounded-with ?action-id)
                 (name ?pn)
                 (is-satisfied FALSE))
   (or (domain-atomic-precondition
+        (goal-id ?g) (plan-id ?p)
         (grounded-with ?action-id) (part-of ?pn)
         (grounded TRUE) (is-satisfied FALSE)
       )
       (domain-precondition
+        (goal-id ?g) (plan-id ?p)
         (grounded-with ?action-id) (part-of ?pn)
         (grounded TRUE) (is-satisfied FALSE)
       )
@@ -343,14 +371,18 @@
   ?precond <- (domain-precondition
                 (type negation)
                 (name ?pn)
+                (goal-id ?g)
+                (plan-id ?p)
                 (grounded-with ?action-id)
                 (is-satisfied TRUE)
                 (grounded TRUE))
   (or (domain-atomic-precondition
+        (goal-id ?g) (plan-id ?p)
         (grounded-with ?action-id) (part-of ?pn)
         (grounded TRUE) (is-satisfied TRUE)
       )
       (domain-precondition
+        (goal-id ?g) (plan-id ?p)
         (grounded-with ?action-id) (part-of ?pn)
         (grounded TRUE) (is-satisfied TRUE)
       )
@@ -364,13 +396,17 @@
   ?precond <- (domain-precondition
                 (name ?pn)
                 (type conjunction)
+                (goal-id ?g)
+                (plan-id ?p)
                 (grounded-with ?action-id)
                 (grounded TRUE)
                 (is-satisfied FALSE))
   (not (domain-atomic-precondition
+        (goal-id ?g) (plan-id ?p)
         (part-of ?pn) (grounded TRUE)
         (grounded-with ?action-id) (is-satisfied FALSE)))
   (not (domain-precondition
+        (goal-id ?g) (plan-id ?p)
         (part-of ?pn) (grounded TRUE)
         (grounded-with ?action-id) (is-satisfied FALSE)))
 =>
@@ -383,14 +419,18 @@
   ?precond <- (domain-precondition
                 (name ?pn)
                 (type conjunction)
+                (goal-id ?g)
+                (plan-id ?p)
                 (grounded-with ?action-id)
                 (grounded TRUE)
                 (is-satisfied TRUE))
   (or (domain-atomic-precondition
+        (goal-id ?g) (plan-id ?p)
         (part-of ?pn) (grounded TRUE)
         (grounded-with ?action-id) (is-satisfied FALSE)
       )
       (domain-precondition
+        (goal-id ?g) (plan-id ?p)
         (part-of ?pn) (grounded TRUE)
         (grounded-with ?action-id) (is-satisfied FALSE)
       )
@@ -420,27 +460,30 @@
   (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))
        =>
        (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))
                                                                                
         (and (eq ?cep:part-of ?e:name) ?cep:is-satisfied
-                                                                               
                                ?cep:grounded (eq ?cep:grounded-with ?id))))
+                            (eq ?cep:goal-id ?g) (eq ?cep:plan-id ?p)
+                            ?cep:grounded (eq ?cep:grounded-with ?id))))
                 then
                        (bind ?values
                                                (domain-ground-effect 
?e:param-names ?e:param-constants
                                                                                
                                                        ?action-param-names 
?action-param-values))
 
-                       (assert (domain-pending-sensed-fact (name ?p:name) 
(action-id ?id)
+                       (assert (domain-pending-sensed-fact (name ?pred:name) 
(action-id ?id)
                                                                                
                                                                                
        (param-values ?values) (type ?e:type)))
                        (bind ?next-state SENSED-EFFECTS-WAIT)
                )
@@ -450,8 +493,7 @@
 
 (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))
        =>
        (modify ?pa (status SENSED-EFFECTS-HOLD))
@@ -460,18 +502,21 @@
 ; 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))
        =>
-       (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)))
                                                (any-factp ((?cep 
domain-precondition))
                                                                                
         (and (eq ?cep:part-of ?e:name) ?cep:is-satisfied
-                                                                               
                                ?cep:grounded (eq ?cep:grounded-with ?id))))
+                            (eq ?cep:goal-id ?g) (eq ?cep:plan-id ?p)
+                            ?cep:grounded (eq ?cep:grounded-with ?id))))
                 then
                        (bind ?values
                                                (domain-ground-effect 
?e:param-names ?e:param-constants
@@ -479,9 +524,10 @@
 
                        (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 ?p:name) 
(param-values ?values)))
+                               (assert (domain-retracted-fact (name ?pred:name)
+                                       (param-values ?values)))
                        )
                )
        )
@@ -553,8 +599,10 @@
 
 (defrule domain-check-if-action-is-executable
   "If the precondition of an action is satisfied, the action is executable."
-  ?action <- (plan-action (id ?action-id) (executable FALSE))
-  (domain-precondition (grounded-with ?action-id) (is-satisfied TRUE))
+  ?action <- (plan-action (id ?action-id) (goal-id ?g) (plan-id ?p)
+                          (executable FALSE))
+  (domain-precondition (plan-id ?p) (goal-id ?g) (grounded-with ?action-id)
+                       (is-satisfied TRUE))
 =>
   (modify ?action (executable TRUE))
 )
diff --git a/src/plugins/clips-executive/clips/plan.clp 
b/src/plugins/clips-executive/clips/plan.clp
index f52729c..bced465 100644
--- a/src/plugins/clips-executive/clips/plan.clp
+++ b/src/plugins/clips-executive/clips/plan.clp
@@ -22,8 +22,10 @@
        (slot cost (type FLOAT))
 )
 
+; TODO: Rename slots
 (deftemplate plan-action
        (slot id (type INTEGER))
+  (slot goal-id (type SYMBOL))
        (slot plan-id (type SYMBOL))
        (slot action-name (type SYMBOL))
        (multislot param-names)
diff --git a/src/plugins/clips-executive/clips/test-scenario/fixed-sequence.clp 
b/src/plugins/clips-executive/clips/test-scenario/fixed-sequence.clp
index 3e65024..d42548e 100644
--- a/src/plugins/clips-executive/clips/test-scenario/fixed-sequence.clp
+++ b/src/plugins/clips-executive/clips/test-scenario/fixed-sequence.clp
@@ -4,18 +4,23 @@
        =>
        (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"))
-               (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)
                             (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)
+               (plan-action (id 3) (goal-id TESTGOAL) (plan-id TESTGOAL-PLAN)
+                 (duration 4.0)
                             (action-name say-goodbye))
-               (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)
                             (action-name say-hello-again)
                             (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)
                             (action-name say-cleanup))
        )
        (modify ?g (mode EXPANDED))
diff --git a/src/plugins/clips-executive/clips/tests/blocksworld.clp 
b/src/plugins/clips-executive/clips/tests/blocksworld.clp
index 7c2bc73..7b1915b 100644
--- a/src/plugins/clips-executive/clips/tests/blocksworld.clp
+++ b/src/plugins/clips-executive/clips/tests/blocksworld.clp
@@ -55,18 +55,18 @@
   ; world model
   (domain-fact (name handempty))
   (domain-fact (name clear) (param-values b1))
-  (plan-action (id 1) (plan-id p0) (action-name pick-up) (param-names x)
+  (plan-action (id 1) (goal-id g0) (plan-id p0) (action-name pick-up) 
(param-names x)
     (param-values b1))
 
   (domain-fact (name on) (param-values b1 b2))
-  (plan-action (id 2) (plan-id p0) (action-name unstack)
+  (plan-action (id 2) (goal-id g0) (plan-id p0) (action-name unstack)
     (param-names x y) (param-values b1 b2))
 )
 
 (defrule apply-action
   "Pseudo-execute action by changing its state to EXECUTION-SUCCEEDED ."
-  ?aa <- (apply-action ?action-id)
-  ?pa <- (plan-action (id ?action-id))
+  ?aa <- (apply-action ?goal-id ?plan-id ?action-id)
+  ?pa <- (plan-action (id ?action-id) (goal-id ?goal-id) (plan-id ?plan-id))
 =>
   (modify ?pa (status EXECUTION-SUCCEEDED))
   (retract ?aa)
diff --git a/src/plugins/clips-executive/clips/tests/conditional_say.clp 
b/src/plugins/clips-executive/clips/tests/conditional_say.clp
index 5e993d6..3e86a2b 100644
--- a/src/plugins/clips-executive/clips/tests/conditional_say.clp
+++ b/src/plugins/clips-executive/clips/tests/conditional_say.clp
@@ -37,8 +37,8 @@
 
 (defrule apply-action
   "Pseudo-execute action by changing its state to FINAL."
-  ?aa <- (apply-action ?action-id)
-  ?pa <- (plan-action (id ?action-id))
+  ?aa <- (apply-action ?goal-id ?plan-id ?action-id)
+  ?pa <- (plan-action (id ?action-id) (goal-id ?goal-id) (plan-id ?plan-id))
 =>
   (modify ?pa (status EXECUTION-SUCCEEDED))
   (retract ?aa)
diff --git a/src/plugins/clips-executive/clips/tests/test_domain.cpp 
b/src/plugins/clips-executive/clips/tests/test_domain.cpp
index 5056cc3..dae8370 100644
--- a/src/plugins/clips-executive/clips/tests/test_domain.cpp
+++ b/src/plugins/clips-executive/clips/tests/test_domain.cpp
@@ -183,7 +183,7 @@ TEST_F(BlocksworldDomainTest, ApplyEffects)
   EXPECT_TRUE(has_fact("((?p domain-fact))", "(eq ?p:name handempty)"));
   EXPECT_TRUE(has_fact("((?p domain-fact))",
         "(and (eq ?p:name clear) (eq ?p:param-values (create$ b1)))"));
-  env.assert_fact("(apply-action 1)");
+  env.assert_fact("(apply-action g0 p0 1)");
   env.run();
   EXPECT_TRUE(has_fact("((?p domain-fact))",
         "(and (eq ?p:name holding) (eq ?p:param-values (create$ b1)))"));
@@ -204,7 +204,7 @@ TEST_F(BlocksworldDomainTest, 
ApplyContradictingEffectsWithDifferentParams)
         "(and (eq ?p:name clear) (eq ?p:param-values (create$ b1)))"));
   EXPECT_FALSE(has_fact("((?p domain-fact))",
         "(and (eq ?p:name clear) (eq ?p:param-values (create$ b2)))"));
-  env.assert_fact("(apply-action 2)");
+  env.assert_fact("(apply-action g0 p0 2)");
   env.run();
   EXPECT_FALSE(has_fact("((?p domain-fact))",
         "(and (eq ?p:name clear) (eq ?p:param-values (create$ b1)))"));
@@ -243,6 +243,7 @@ TEST_F(DomainTest, WaitForSensedEffects)
   env.assert_fact("(domain-object (name obj1))");
   env.assert_fact("(domain-fact (name holding) (param-values obj1))");
   env.assert_fact("(plan-action"
+                  " (goal-id g0) (plan-id p0)"
                   " (id 1)"
                   " (status EXECUTION-SUCCEEDED)"
                   " (action-name drop)"
@@ -295,6 +296,7 @@ TEST_F(DomainTest, OnlyWaitForEffectsIfWaitSensedIsTRUE)
   env.assert_fact("(domain-fact (name holding) (param-values obj1))");
   env.assert_fact("(plan-action"
                   " (id 1)"
+                  " (goal-id g0) (plan-id p0)"
                   " (status EXECUTION-SUCCEEDED)"
                   " (action-name drop)"
                   " (param-names o)"
@@ -312,6 +314,7 @@ TEST_F(DomainTest, PreconditionWithConstant)
   env.reset();
   env.assert_fact("(plan-action"
                   " (id 1)"
+                  " (goal-id g0) (plan-id p0)"
                   " (action-name op1)"
                   " (param-names y)"
                   " (param-values b))");
@@ -347,6 +350,7 @@ TEST_F(DomainTest, PreconditionWithConstantInSecondSlot)
   env.reset();
   env.assert_fact("(plan-action"
                   " (id 1)"
+                  " (goal-id g0) (plan-id p0)"
                   " (action-name op1)"
                   " (param-names x)"
                   " (param-values b))");
@@ -382,6 +386,7 @@ TEST_F(DomainTest, PreconditionWithUnknownParameter)
   env.reset();
   env.assert_fact("(plan-action"
                   " (id 1)"
+                  " (goal-id g0) (plan-id p0)"
                   " (action-name op1)"
                   " (param-names x)"
                   " (param-values b))");
@@ -407,6 +412,37 @@ TEST_F(DomainTest, ActionHasADomainOperator)
         "(eq ?e:error-type operator-of-action-does-not-exist)"));
 }
 
+/** Action IDs are only unique within the same plan and goal.
+ *  Create multiple actions with the same ID but different plans, and test
+ *  if they are treated correctly.
+ */
+TEST_F(BlocksworldDomainTest, NonUniqueActionIDs)
+{
+  env.reset();
+  env.assert_fact("(plan-action (id 1) (goal-id g0) (plan-id p1)"
+                  " (action-name unstack)"
+                  " (param-names x y) (param-values b1 b2))");
+  env.run();
+  // The action pick-up with ID 1 in plan p0 of goal g0. This should be
+  // executable, and the executable state should not be copied to the other
+  // actions.
+  EXPECT_TRUE(has_fact("((?a plan-action))",
+        "(and (eq ?a:id 1) (eq ?a:goal-id g0) (eq ?a:plan-id p0)"
+        " (eq ?a:executable TRUE))"
+        ));
+  EXPECT_TRUE(has_fact("((?a plan-action))",
+        "(and (eq ?a:id 1) (eq ?a:goal-id g0) (eq ?a:plan-id p1)"
+        " (eq ?a:executable FALSE))"
+        ));
+  env.assert_fact("(plan-action (id 1) (goal-id g1) (plan-id p0)"
+                  " (action-name unstack)"
+                  " (param-names x y) (param-values b1 b2))");
+  EXPECT_TRUE(has_fact("((?a plan-action))",
+        "(and (eq ?a:id 1) (eq ?a:goal-id g1) (eq ?a:plan-id p0)"
+        " (eq ?a:executable FALSE))"
+        ));
+}
+
 /** Test with the conditional-say domain. */
 class ConditionalSayDomainTest : public DomainTest
 {
@@ -424,11 +460,12 @@ TEST_F(ConditionalSayDomainTest, 
DoNotApplyCondEffectIfCondDoesNotHold)
   env.reset();
   env.assert_fact("(plan-action"
                   " (id 1)"
+                  " (goal-id g0) (plan-id p0)"
                   " (action-name say)"
                   " (param-names s t)"
                   " (param-values front_speaker hello)"
                   ")");
-  env.assert_fact("(apply-action 1)");
+  env.assert_fact("(apply-action g0 p0 1)");
   env.run();
   EXPECT_FALSE(has_fact("((?fact domain-fact))",
         "(and (eq ?fact:name said) (eq ?fact:param-values (create$ hello)))"));
@@ -440,14 +477,16 @@ TEST_F(ConditionalSayDomainTest, 
ApplyCondEffectIfCondHolds)
   env.reset();
   env.assert_fact("(plan-action"
                   " (id 1)"
+                  " (goal-id g0) (plan-id p0)"
                   " (action-name say)"
                   " (param-names s t)"
                   " (param-values front_speaker hello)"
                   ")");
-  env.assert_fact("(apply-action 1)");
+  env.assert_fact("(apply-action g0 p0 1)");
   env.assert_fact(
       "(domain-fact (name speaker-ready) (param-values front_speaker))");
   env.run();
+  EXPECT_TRUE(has_fact("((?a plan-action))", "(eq ?a:status FINAL)"));
   EXPECT_TRUE(has_fact("((?fact domain-fact))",
         "(and (eq ?fact:name said) (eq ?fact:param-values (create$ hello)))"));
 }

- *commit* 6721a9095d76e5f50fc365ce2fa5c9bde90b608d - - - - - - - - - -
Author:  Till Hofmann <hofm...@kbsg.rwth-aachen.de>
Date:    Wed Mar 7 19:19:16 2018 +0100
Subject: clips-executive: add goal-ids to plan-actions of PDDL plans

 src/plugins/clips-executive/clips/pddl.clp |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-executive/clips/pddl.clp 
b/src/plugins/clips-executive/clips/pddl.clp
index a543fe4..af7742d 100644
--- a/src/plugins/clips-executive/clips/pddl.clp
+++ b/src/plugins/clips-executive/clips/pddl.clp
@@ -82,13 +82,6 @@
   (modify ?p (status PLANNED))
 )
 
-(deffunction pddl-get-max-action-id ()
-  "Get the max ID of all current action"
-  (bind ?i 0)
-  (do-for-all-facts ((?a plan-action)) (> ?a:id ?i) (bind ?i ?a:id))
-  (return ?i)
-)
-
 (defrule pddl-expand-goal
   "Fetch the resulting plan from robot memory and expand the goal."
   ?g <- (goal (id ?goal-id) (mode SELECTED))
@@ -101,7 +94,6 @@
         )
   =>
   (printout t "Fetched a new plan!" crlf)
-  (bind ?id-offset (pddl-get-max-action-id))
   (progn$ (?action (bson-get-array (bson-get ?obj "o") "actions"))
     (bind ?action-name (sym-cat (bson-get ?action "name")))
     ; FF sometimes returns the pseudo-action REACH-GOAL. Filter it out.
@@ -120,7 +112,8 @@
       (assert
         (plan (id ?plan-id) (goal-id ?goal-id))
         (plan-action
-          (id (+ ?action-index ?id-offset))
+          (id ?action-index)
+          (goal-id ?goal-id)
           (plan-id ?plan-id)
           (action-name ?action-name)
           (param-values ?param-values)




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org
_______________________________________________
fawkes-commits mailing list
fawkes-commits@lists.kbsg.rwth-aachen.de
https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits

Reply via email to