[Fawkes Git] branch/fzwilling/robot-memory: 3 revs updated. (0.5.0-3108-g8a5b802)

Frederik Zwilling zwilling at kbsg.rwth-aachen.de
Tue Sep 13 19:17:46 CEST 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, fzwilling/robot-memory has been updated
        to  8a5b8026678bdc94d20f319705fafcf023c10368 (commit)
       via  b35f714869f8ce8161e7021dce03aa2a133f824e (commit)
       via  c87c3afb891e14315d47b0815a7a6f70af626f7e (commit)
      from  ff3303de647e0d78566794be4ffb90899dd0929d (commit)

http://git.fawkesrobotics.org/fawkes.git/fzwilling/robot-memory

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit c87c3afb891e14315d47b0815a7a6f70af626f7e
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Tue Sep 13 18:01:15 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Tue Sep 13 19:17:33 2016 +0200

    clips-robot-memory: function to create BSON doc from structured fact

http://git.fawkesrobotics.org/fawkes.git/commit/c87c3af
http://trac.fawkesrobotics.org/changeset/c87c3af

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit b35f714869f8ce8161e7021dce03aa2a133f824e
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Tue Sep 13 18:19:27 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Tue Sep 13 19:17:37 2016 +0200

    clips-robot-memory: create BSON document from ordered fact

http://git.fawkesrobotics.org/fawkes.git/commit/b35f714
http://trac.fawkesrobotics.org/changeset/b35f714

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 8a5b8026678bdc94d20f319705fafcf023c10368
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Tue Sep 13 19:15:24 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Tue Sep 13 19:17:42 2016 +0200

    clips-robot-memory: assert facts from bson document

http://git.fawkesrobotics.org/fawkes.git/commit/8a5b802
http://trac.fawkesrobotics.org/changeset/8a5b802

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


- *Summary* -----------------------------------------------------------
 .../clips_robot_memory_thread.cpp                  |    3 +-
 src/plugins/clips-robot-memory/robot-memory.clp    |   75 ++++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletions(-)
 create mode 100644 src/plugins/clips-robot-memory/robot-memory.clp


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

- *commit* c87c3afb891e14315d47b0815a7a6f70af626f7e - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Tue Sep 13 18:01:15 2016 +0200
Subject: clips-robot-memory: function to create BSON doc from structured fact

 .../clips_robot_memory_thread.cpp                  |    3 +-
 src/plugins/clips-robot-memory/robot-memory.clp    |   29 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-robot-memory/clips_robot_memory_thread.cpp b/src/plugins/clips-robot-memory/clips_robot_memory_thread.cpp
index fdd9231..7b5c589 100644
--- a/src/plugins/clips-robot-memory/clips_robot_memory_thread.cpp
+++ b/src/plugins/clips-robot-memory/clips_robot_memory_thread.cpp
@@ -89,7 +89,8 @@ ClipsRobotMemoryThread::clips_context_init(const std::string &env_name,
 
   clips->build("(deffacts have-feature-mongodb (have-feature MongoDB))");
 
-  //TODO: clips->batch_evaluate(SRCDIR"/plugins/clips-robot-memory/robot_memory.clp");
+  //load helper functions written in CLIPS
+  clips->batch_evaluate(SRCDIR"/robot-memory.clp");
 
   clips.unlock();
 }

- *commit* b35f714869f8ce8161e7021dce03aa2a133f824e - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Tue Sep 13 18:19:27 2016 +0200
Subject: clips-robot-memory: create BSON document from ordered fact

 src/plugins/clips-robot-memory/robot-memory.clp |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-robot-memory/robot-memory.clp b/src/plugins/clips-robot-memory/robot-memory.clp
index dc29baf..aa75186 100644
--- a/src/plugins/clips-robot-memory/robot-memory.clp
+++ b/src/plugins/clips-robot-memory/robot-memory.clp
@@ -13,7 +13,7 @@
 (deffunction rm-structured-fact-to-bson (?fact)
   (bind ?doc (bson-create))
   (bind ?templ (fact-relation ?fact))
-  (bson-append ?doc "type" (str-cat ?templ))
+  (bson-append ?doc "relation" (str-cat ?templ))
   ;append kv-pair for each field
   (progn$ (?slot (fact-slot-names ?fact))
     (if (deftemplate-slot-multip ?templ ?slot)
@@ -27,3 +27,15 @@
   )      
   (return ?doc)
 )
+
+;; Creates a BSON document from an ordered fact
+; @param ?fact Fact-Pointer
+; @return BSON document
+(deffunction rm-ordered-fact-to-bson (?fact)
+  (bind ?doc (bson-create))
+  (bind ?templ (fact-relation ?fact))
+  (bson-append ?doc "relation" (str-cat ?templ))
+  ;append values as array
+  (bson-append-array ?doc "values" (fact-slot-value ?fact implied))
+  (return ?doc)
+)

- *commit* 8a5b8026678bdc94d20f319705fafcf023c10368 - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Tue Sep 13 19:15:24 2016 +0200
Subject: clips-robot-memory: assert facts from bson document

 src/plugins/clips-robot-memory/robot-memory.clp |   34 +++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-robot-memory/robot-memory.clp b/src/plugins/clips-robot-memory/robot-memory.clp
index aa75186..709f6bb 100644
--- a/src/plugins/clips-robot-memory/robot-memory.clp
+++ b/src/plugins/clips-robot-memory/robot-memory.clp
@@ -39,3 +39,37 @@
   (bson-append-array ?doc "values" (fact-slot-value ?fact implied))
   (return ?doc)
 )
+
+;; Assert (structured/ordered) fact from a BSON document
+; @param ?doc BSON document
+(deffunction rm-assert-from-bson (?doc)
+  (bind ?relation "")
+  (bind ?values "")
+  (bind ?keys (bson-field-names ?doc))
+  (if (member$ "relation" ?keys)
+    then
+    (bind ?relation (bson-get ?doc "relation"))
+    else
+    (printout error "Can not create fact from " (bson-tostring ?doc) crlf)
+    (return)
+  )
+  (if (member$ ?relation (get-deftemplate-list *))
+    then ;structured fact
+    (progn$ (?slot ?keys)
+      (if (deftemplate-slot-existp ?relation ?slot) then
+        (if (deftemplate-slot-multip ?relation ?slot)
+          then
+          (bind ?values (str-cat ?values "(" ?relation " " (bson-get ?doc ?slot) ")"))
+          else
+          (bind ?values (str-cat ?values "(" ?relation " " (implode$ (bson-get-array ?doc ?slot)) ")"))
+        )
+      )
+    )
+    else ;ordered fact
+    (if (member$ "values" ?keys) then
+      (bind ?values (str-cat ?values "(" ?relation " " (implode$ (bson-get-array ?doc "values")) ")"))
+    )
+  )
+  
+  (assert-string (str-cat "(" ?relation " " ?values ")"))
+)




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list