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  6eafa9c64e30efac5b8cfdf40f2ddc8bb583c548 (commit)
       via  9f9428d0400c6adfb685415af6ac8e0bf6bd26be (commit)
       via  4c3a6a6b87d41755bb9d383afae20b24dac70224 (commit)
       via  5387a75bae1e0ce106f8c9e21a6226411d845621 (commit)
      from  7c6cda7df994d2355c46debc88d29b906cf3f99d (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 5387a75bae1e0ce106f8c9e21a6226411d845621
Author:     Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
AuthorDate: Thu Oct 13 13:42:00 2016 +0200
Commit:     Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
CommitDate: Fri Oct 14 01:00:44 2016 +0200

    pddl-robot-memory: plugin skeleton for generating pddl from the robot memory

http://git.fawkesrobotics.org/fawkes.git/commit/5387a75
http://trac.fawkesrobotics.org/changeset/5387a75

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 4c3a6a6b87d41755bb9d383afae20b24dac70224
Author:     Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
AuthorDate: Thu Oct 13 15:31:14 2016 +0200
Commit:     Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
CommitDate: Fri Oct 14 01:00:48 2016 +0200

    pddl-robot-memory: reading template and writing output file

http://git.fawkesrobotics.org/fawkes.git/commit/4c3a6a6
http://trac.fawkesrobotics.org/changeset/4c3a6a6

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 9f9428d0400c6adfb685415af6ac8e0bf6bd26be
Author:     Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
AuthorDate: Thu Oct 13 19:39:36 2016 +0200
Commit:     Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
CommitDate: Fri Oct 14 01:00:52 2016 +0200

    pddl-robot-memory: use ctemplate as template engine for generating .pddl

http://git.fawkesrobotics.org/fawkes.git/commit/9f9428d
http://trac.fawkesrobotics.org/changeset/9f9428d

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 6eafa9c64e30efac5b8cfdf40f2ddc8bb583c548
Author:     Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
AuthorDate: Fri Oct 14 00:16:52 2016 +0200
Commit:     Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
CommitDate: Fri Oct 14 01:00:57 2016 +0200

    pddl-robot-memory: generic templates to query robot memory and fill
    
    Uses the template engine ctemplate to generate pddl from a template
    file and the robot memory.
    
    The template file can use the following templates to generate some
    output for each document returned by a query:
    
    Example: <<#ONTABLE|{relation:'on-table'}>> (on-table <<object>>)
      <</ONTABLE>>
    Yields: (on-table a) (on-table b)
    When these documents are in the database:
     {relation:'on-table', object:'a'}, {relation:'on-table', object:'b'}
    
    The selection template <<#UNIQUENAME|query>> something
     <</UNIQUENAME>>
     queries the robot memory and inserts 'something' for each returned
     document.
    
    Variable templates <<key>> inside the selection are substituted by
     the values
     of that key in the document returned by the query. You can also
     access subdocuments
     (e.g. <<position.orientation.yaw>> )

http://git.fawkesrobotics.org/fawkes.git/commit/6eafa9c
http://trac.fawkesrobotics.org/changeset/6eafa9c

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


- *Summary* -----------------------------------------------------------
 src/plugins/Makefile                               |    3 +-
 src/plugins/pddl-robot-memory/Makefile             |   59 ++++++
 .../protobuf.mk => pddl-robot-memory/ctemplate.mk} |   25 +--
 .../pddl_robot_memory_plugin.cpp}                  |   20 +-
 .../pddl-robot-memory/pddl_robot_memory_thread.cpp |  197 ++++++++++++++++++++
 .../pddl_robot_memory_thread.h}                    |   27 ++-
 6 files changed, 295 insertions(+), 36 deletions(-)
 create mode 100644 src/plugins/pddl-robot-memory/Makefile
 copy src/plugins/{gazebo/protobuf.mk => pddl-robot-memory/ctemplate.mk} (52%)
 copy src/plugins/{robot-memory/test-plugin/robot_memory_test_plugin.cpp => 
pddl-robot-memory/pddl_robot_memory_plugin.cpp} (66%)
 create mode 100644 src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
 copy src/plugins/{robot-memory/test-plugin/robot_memory_test_thread.h => 
pddl-robot-memory/pddl_robot_memory_thread.h} (72%)


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

- *commit* 5387a75bae1e0ce106f8c9e21a6226411d845621 - - - - - - - - - -
Author:  Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
Date:    Thu Oct 13 13:42:00 2016 +0200
Subject: pddl-robot-memory: plugin skeleton for generating pddl from the robot 
memory

 src/plugins/Makefile                               |    2 +-
 .../{ttmainloop => pddl-robot-memory}/Makefile     |   20 +++++----
 .../pddl_robot_memory_plugin.cpp}                  |   20 ++++----
 .../pddl_robot_memory_thread.cpp}                  |   47 +++++++++++---------
 .../pddl_robot_memory_thread.h}                    |   27 +++++------
 5 files changed, 60 insertions(+), 56 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/Makefile b/src/plugins/Makefile
index 61072d8..8ce3104 100644
--- a/src/plugins/Makefile
+++ b/src/plugins/Makefile
@@ -26,7 +26,7 @@ SUBDIRS       = bbsync bblogger webview ttmainloop rrd rrdweb 
\
          static_transforms navgraph navgraph-clusters navgraph-generator colli 
\
          clips clips-agent clips-protobuf clips-webview clips-navgraph 
clips-ros \
          clips-tf openprs openprs-agent eclipse-clp \
-         mongodb mongodb_log robot-memory clips-robot-memory \
+         mongodb mongodb_log robot-memory clips-robot-memory pddl-robot-memory 
\
          openni refboxcomm ros player xmlrpc gossip \
          robot_state_publisher gazebo dynamixel navgraph-interactive
 

- *commit* 4c3a6a6b87d41755bb9d383afae20b24dac70224 - - - - - - - - - -
Author:  Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
Date:    Thu Oct 13 15:31:14 2016 +0200
Subject: pddl-robot-memory: reading template and writing output file

 src/plugins/Makefile                               |    1 +
 src/plugins/pddl-robot-memory/Makefile             |   28 +++++++++++++-
 .../pddl-robot-memory/pddl_robot_memory_thread.cpp |   40 ++++++++++++++++++++
 .../pddl-robot-memory/pddl_robot_memory_thread.h   |   10 +++-
 4 files changed, 74 insertions(+), 5 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/Makefile b/src/plugins/Makefile
index 8ce3104..b0e0275 100644
--- a/src/plugins/Makefile
+++ b/src/plugins/Makefile
@@ -43,6 +43,7 @@ clips-navgraph navgraph-clusters: navgraph
 clips-webview: clips webview
 clips-ros: clips ros
 clips-robot-memory: robot-memory
+pddl-robot-memory: robot-memory
 gazebo: robotino
 skiller: navgraph
 perception: mongodb
diff --git a/src/plugins/pddl-robot-memory/Makefile 
b/src/plugins/pddl-robot-memory/Makefile
index 062b212..fbfa08b 100644
--- a/src/plugins/pddl-robot-memory/Makefile
+++ b/src/plugins/pddl-robot-memory/Makefile
@@ -16,14 +16,38 @@
 
 BASEDIR = ../../..
 include $(BASEDIR)/etc/buildsys/config.mk
+include $(BASEDIR)/src/plugins/mongodb/mongodb.mk
 
 LIBS_pddl_robot_memory = m fawkescore fawkesutils fawkesaspects fawkesbaseapp \
-                      fawkesblackboard fawkesinterface
+                      fawkesblackboard fawkesinterface fawkesrobotmemory
 
 OBJS_pddl_robot_memory = pddl_robot_memory_plugin.o pddl_robot_memory_thread.o
 
-PLUGINS_all = $(PLUGINDIR)/pddl_robot_memory.$(SOEXT)
 
 OBJS_all = $(OBJS_pddl_robot_memory)
 
+ifeq ($(HAVE_CPP11)$(HAVE_MONGODB),11)
+  CFLAGS  += $(CFLAGS_CPP11)
+
+  PLUGINS_all = $(PLUGINDIR)/pddl-robot-memory.$(SOEXT)          
+else
+  ifneq ($(HAVE_CPP11),1)
+    WARN_TARGETS += warning_cpp11
+  endif
+  ifneq ($(HAVE_TF),1)
+    WARN_TARGETS = warning_mongodb
+  endif
+endif
+
+ifeq ($(OBJSSUBMAKE),1)
+all: $(WARN_TARGETS)
+
+.PHONY: warning_tf warning_clips warning_cpp11
+warning_mongodb:
+       $(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Omitting clips-robot-memory 
plugin$(TNORMAL) (mongodb not available)"
+warning_cpp11:
+       $(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Cannot build 
clips-robot-memory plugin$(TNORMAL) (C++11 not supported)"
+
+endif
+
 include $(BUILDSYSDIR)/base.mk
\ No newline at end of file
diff --git a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp 
b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
index 82d7d96..8edfd10 100644
--- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
+++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
@@ -22,6 +22,8 @@
  */
 
 #include "pddl_robot_memory_thread.h"
+#include <fstream>
+#include <utils/misc/string_conversions.h>
 
 using namespace fawkes;
 
@@ -39,6 +41,44 @@ PddlRobotMemoryThread::PddlRobotMemoryThread()
 void
 PddlRobotMemoryThread::init()
 {
+  //read config values
+  collection = config->get_string("plugins/pddl-robot-memory/collection");
+  input_path = StringConversions::resolve_path("@BASEDIR@/src/agents/" +
+    config->get_string("plugins/pddl-robot-memory/input-problem-description"));
+  output_path = StringConversions::resolve_path("@BASEDIR@/src/agents/" +
+    
config->get_string("plugins/pddl-robot-memory/output-problem-description"));
+
+  //read input template of problem description
+  std::string input;
+  std::ifstream istream(input_path);
+  if(istream.is_open())
+  {
+    input = std::string((std::istreambuf_iterator<char>(istream)), 
std::istreambuf_iterator<char>());
+    istream.close();
+  }
+  else
+  {
+    logger->log_error(name(), "Could not open %s", input_path.c_str());
+  }
+
+  //TODO: expand template
+  std::string output = input;
+
+  //generate output
+  logger->log_info(name(), "Output:\n%s", output.c_str());
+  logger->log_info(name(), "opening: %s", input_path.c_str());
+  std::ofstream ostream(output_path);
+  if(ostream.is_open())
+  {
+    ostream << output.c_str();
+    ostream.close();
+  }
+  else
+  {
+    logger->log_error(name(), "Could not open %s", output_path.c_str());
+  }
+
+  logger->log_info(name(), "Generation of PDDL problem description finished");
 }
 
 void
diff --git a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h 
b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h
index fe21f91..53b0dad 100644
--- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h
+++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h
@@ -29,6 +29,7 @@
 #include <aspect/logging.h>
 #include <aspect/blackboard.h>
 #include <aspect/configurable.h>
+#include <plugins/robot-memory/aspect/robot_memory_aspect.h>
 
 #include <string>
 
@@ -40,7 +41,8 @@ class PddlRobotMemoryThread
   public fawkes::BlockedTimingAspect,
   public fawkes::LoggingAspect,
   public fawkes::ConfigurableAspect,
-  public fawkes::BlackBoardAspect
+  public fawkes::BlackBoardAspect,
+  public fawkes::RobotMemoryAspect
 {
 
  public:
@@ -54,9 +56,11 @@ class PddlRobotMemoryThread
   protected: virtual void run() { Thread::run(); }
 
  private:
-  //Define class member variables here
+  std::string collection;
+  std::string input_path;
+  std::string output_path;
 
 };
 
 
-#endif
\ No newline at end of file
+#endif

- *commit* 9f9428d0400c6adfb685415af6ac8e0bf6bd26be - - - - - - - - - -
Author:  Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
Date:    Thu Oct 13 19:39:36 2016 +0200
Subject: pddl-robot-memory: use ctemplate as template engine for generating 
.pddl

 src/plugins/pddl-robot-memory/Makefile             |   16 ++++++++----
 .../protobuf.mk => pddl-robot-memory/ctemplate.mk} |   25 ++++++++-----------
 .../pddl-robot-memory/pddl_robot_memory_thread.cpp |    7 ++++-
 3 files changed, 28 insertions(+), 20 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/pddl-robot-memory/Makefile 
b/src/plugins/pddl-robot-memory/Makefile
index fbfa08b..fcc15df 100644
--- a/src/plugins/pddl-robot-memory/Makefile
+++ b/src/plugins/pddl-robot-memory/Makefile
@@ -17,6 +17,7 @@
 BASEDIR = ../../..
 include $(BASEDIR)/etc/buildsys/config.mk
 include $(BASEDIR)/src/plugins/mongodb/mongodb.mk
+include $(BASEDIR)/src/plugins/pddl-robot-memory/ctemplate.mk
 
 LIBS_pddl_robot_memory = m fawkescore fawkesutils fawkesaspects fawkesbaseapp \
                       fawkesblackboard fawkesinterface fawkesrobotmemory
@@ -26,8 +27,9 @@ OBJS_pddl_robot_memory = pddl_robot_memory_plugin.o 
pddl_robot_memory_thread.o
 
 OBJS_all = $(OBJS_pddl_robot_memory)
 
-ifeq ($(HAVE_CPP11)$(HAVE_MONGODB),11)
+ifeq ($(HAVE_CPP11)$(HAVE_MONGODB)$(HAVE_CTEMPLATE),111)
   CFLAGS  += $(CFLAGS_CPP11)
+  LDFLAGS += $(LDFLAGS_CTEMPLATE)
 
   PLUGINS_all = $(PLUGINDIR)/pddl-robot-memory.$(SOEXT)          
 else
@@ -37,17 +39,21 @@ else
   ifneq ($(HAVE_TF),1)
     WARN_TARGETS = warning_mongodb
   endif
+  ifneq ($(HAVE_CTEMPLATE),1)
+    WARN_TARGETS = warning_ctemplate
+  endif
 endif
 
 ifeq ($(OBJSSUBMAKE),1)
 all: $(WARN_TARGETS)
 
-.PHONY: warning_tf warning_clips warning_cpp11
+.PHONY: warning_tf warning_ctemplate warning_cpp11
 warning_mongodb:
-       $(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Omitting clips-robot-memory 
plugin$(TNORMAL) (mongodb not available)"
+       $(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Omitting pddl-robot-memory 
plugin$(TNORMAL) (mongodb not available)"
 warning_cpp11:
-       $(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Cannot build 
clips-robot-memory plugin$(TNORMAL) (C++11 not supported)"
-
+       $(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Cannot build 
pddl-robot-memory plugin$(TNORMAL) (C++11 not supported)"
+warning_ctemplate:
+       $(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Cannot build 
pddl-robot-memory plugin$(TNORMAL) (ctemplate-devel not installed)"
 endif
 
 include $(BUILDSYSDIR)/base.mk
\ No newline at end of file
diff --git a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp 
b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
index 8edfd10..b93b35f 100644
--- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
+++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
@@ -24,6 +24,7 @@
 #include "pddl_robot_memory_thread.h"
 #include <fstream>
 #include <utils/misc/string_conversions.h>
+#include <ctemplate/template.h>
 
 using namespace fawkes;
 
@@ -62,7 +63,11 @@ PddlRobotMemoryThread::init()
   }
 
   //TODO: expand template
-  std::string output = input;
+  ctemplate::StringToTemplateCache("tpl-cache", input, 
ctemplate::DO_NOT_STRIP);
+  ctemplate::TemplateDictionary dict("pddl-rm");
+  dict.SetValue("TEST", "EXPANDED TEST");
+  std::string output;
+  ctemplate::ExpandTemplate("tpl-cache", ctemplate::DO_NOT_STRIP, &dict, 
&output);
 
   //generate output
   logger->log_info(name(), "Output:\n%s", output.c_str());

- *commit* 6eafa9c64e30efac5b8cfdf40f2ddc8bb583c548 - - - - - - - - - -
Author:  Frederik Zwilling <zwill...@kbsg.rwth-aachen.de>
Date:    Fri Oct 14 00:16:52 2016 +0200
Subject: pddl-robot-memory: generic templates to query robot memory and fill

 .../pddl-robot-memory/pddl_robot_memory_thread.cpp |  109 +++++++++++++++++++-
 .../pddl-robot-memory/pddl_robot_memory_thread.h   |    4 +
 2 files changed, 108 insertions(+), 5 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp 
b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
index b93b35f..3b11cbe 100644
--- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
+++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp
@@ -24,12 +24,31 @@
 #include "pddl_robot_memory_thread.h"
 #include <fstream>
 #include <utils/misc/string_conversions.h>
-#include <ctemplate/template.h>
 
 using namespace fawkes;
+using namespace mongo;
 
 /** @class PddlRobotMemoryThread 'pddl_robot_memory_thread.h' 
  * Generate PDDL files from the robot memory
+ *
+ * This plugin uses the template engine ctemplate to generate a pddl
+ * from a template file and the robot memory.
+ *
+ * The template file can use the following templates to generate some output
+ * for each document returned by a query:
+ *
+ * Example: <<#ONTABLE|{relation:'on-table'}>> (on-table <<object>>) 
<</ONTABLE>>
+ * Yields: (on-table a) (on-table b)
+ * When these documents are in the database:
+ *  {relation:'on-table', object:'a'}, {relation:'on-table', object:'b'}
+ *
+ * The selection template <<#UNIQUENAME|query>> something <</UNIQUENAME>>
+ *  queries the robot memory and inserts 'something' for each returned 
document.
+ *
+ * Variable templates <<key>> inside the selection are substituted by the 
values
+ *  of that key in the document returned by the query. You can also access 
subdocuments
+ *  (e.g. <<position.orientation.yaw>> )
+ *
  * @author Frederik Zwilling
  */
 
@@ -61,17 +80,56 @@ PddlRobotMemoryThread::init()
   {
     logger->log_error(name(), "Could not open %s", input_path.c_str());
   }
+  //set template delimeters to << >>
+  input = "{{=<< >>=}}" +  input;
 
-  //TODO: expand template
-  ctemplate::StringToTemplateCache("tpl-cache", input, 
ctemplate::DO_NOT_STRIP);
+  //Dictionary how to fill the templates
   ctemplate::TemplateDictionary dict("pddl-rm");
-  dict.SetValue("TEST", "EXPANDED TEST");
+
+  //find queries in template
+  size_t cur_pos = 0;
+  while(input.find("<<#", cur_pos) != std::string::npos)
+  {
+    cur_pos = input.find("<<#", cur_pos) + 3;
+    size_t tpl_end_pos =  input.find(">>", cur_pos);
+    //is a query in the template? (indicated by '|')
+    size_t q_del_pos = input.find("|", cur_pos);
+    if(q_del_pos == std::string::npos || q_del_pos > tpl_end_pos)
+      continue; //no query to execute
+    //parse: template name | query
+    std::string template_name = input.substr(cur_pos, q_del_pos - cur_pos);
+    std::string query_str =  input.substr(q_del_pos + 1, tpl_end_pos - 
(q_del_pos + 1));
+    //remove query stuff from input (its not part of the ctemplate features)
+    input.erase(q_del_pos, tpl_end_pos - q_del_pos);
+
+    //fill dictionary to expand query template:
+    QResCursor cursor = robot_memory->query(fromjson(query_str), collection);
+    while(cursor->more())
+    {
+      BSONObj obj = cursor->next();
+      //dictionary for one entry
+      ctemplate::TemplateDictionary *entry_dict = 
dict.AddSectionDictionary(template_name);
+      fill_dict_from_document(entry_dict, obj);
+    }
+  }
+
+  //prepare template expanding
+  ctemplate::StringToTemplateCache("tpl-cache", input, 
ctemplate::DO_NOT_STRIP);
+  if(!ctemplate::TemplateNamelist::IsAllSyntaxOkay(ctemplate::DO_NOT_STRIP))
+  {
+    logger->log_error(name(), "Syntax error in template %s:", 
input_path.c_str());
+    std::vector<std::string> error_list = 
ctemplate::TemplateNamelist::GetBadSyntaxList(false, ctemplate::DO_NOT_STRIP);
+    for(std::string error : error_list)
+    {
+      logger->log_error(name(), "", error.c_str());
+    }
+  }
+  //Let ctemplate expand the input
   std::string output;
   ctemplate::ExpandTemplate("tpl-cache", ctemplate::DO_NOT_STRIP, &dict, 
&output);
 
   //generate output
   logger->log_info(name(), "Output:\n%s", output.c_str());
-  logger->log_info(name(), "opening: %s", input_path.c_str());
   std::ofstream ostream(output_path);
   if(ostream.is_open())
   {
@@ -96,3 +154,44 @@ PddlRobotMemoryThread::finalize()
 {
 }
 
+/**
+ * Fills a dictionary with key value pairs from a document. Recursive to 
handle subdocuments
+ * @param dict Dictionary to fill
+ * @param obj Document
+ * @param prefix Prefix of previous super-documents keys
+ */
+void 
PddlRobotMemoryThread::fill_dict_from_document(ctemplate::TemplateDictionary 
*dict, mongo::BSONObj obj, std::string prefix)
+{
+  for(BSONObjIterator it = obj.begin(); it.more();)
+  {
+    BSONElement elem = it.next();
+    switch (elem.type()) {
+      case mongo::NumberDouble:
+        dict->SetValue(prefix + elem.fieldName(), 
std::to_string(elem.Double()));
+        break;
+      case mongo::String:
+        dict->SetValue(prefix + elem.fieldName(), elem.String());
+        break;
+      case mongo::Bool:
+        dict->SetValue(prefix + elem.fieldName(), std::to_string(elem.Bool()));
+        break;
+      case mongo::NumberInt:
+        dict->SetIntValue(prefix + elem.fieldName(), elem.Int());
+        break;
+      case mongo::NumberLong:
+        dict->SetValue(prefix + elem.fieldName(), std::to_string(elem.Long()));
+        break;
+      case mongo::Object:
+        fill_dict_from_document(dict, elem.Obj(), prefix + elem.fieldName() + 
".");
+        break;
+      case 7: //ObjectId
+      dict->SetValue(prefix + elem.fieldName(), elem.OID().toString());
+      break;
+      //TODO: array
+
+      default:
+        dict->SetValue(prefix + elem.fieldName(), "INVALID_VALUE_TYPE");
+    }
+  }
+}
+
diff --git a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h 
b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h
index 53b0dad..a04bc8a 100644
--- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h
+++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h
@@ -33,6 +33,8 @@
 
 #include <string>
 
+#include <ctemplate/template.h>
+
 namespace fawkes {
 }
 
@@ -60,6 +62,8 @@ class PddlRobotMemoryThread
   std::string input_path;
   std::string output_path;
 
+  void fill_dict_from_document(ctemplate::TemplateDictionary *dict, 
mongo::BSONObj obj, std::string prefix = "");
+
 };
 
 




-- 
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