[Fawkes Git] branch/fzwilling/robot-memory: 2 revs updated. (0.5.0-3090-g8bc2ab5)

Frederik Zwilling zwilling at kbsg.rwth-aachen.de
Tue Aug 23 18:56:54 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  8bc2ab5189aa6849d6ca33d0ea691711db8d5cdf (commit)
       via  182922651a00e647f5d8eb519d60b3fdbc064572 (commit)
      from  ef0a9cb4996993358bf7d041cfb796781c97228f (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 182922651a00e647f5d8eb519d60b3fdbc064572
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Tue Aug 23 18:51:52 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Tue Aug 23 18:56:41 2016 +0200

    mongodb: hint in exception to start the mongod service

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 8bc2ab5189aa6849d6ca33d0ea691711db8d5cdf
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Tue Aug 23 18:55:19 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Tue Aug 23 18:56:46 2016 +0200

    robot-memory: provide aspect for using the RobotMemory

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

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


- *Summary* -----------------------------------------------------------
 src/plugins/mongodb/mongodb_thread.cpp             |    2 +-
 src/plugins/robot-memory/Makefile                  |    9 +-
 src/plugins/{nao => robot-memory}/aspect/Makefile  |   33 +-
 .../robot_memory_aspect.cpp}                       |   51 ++--
 .../robot_memory_aspect.h}                         |   47 ++--
 .../robot-memory/aspect/robot_memory_inifin.cpp    |   79 +++++
 .../robot_memory_inifin.h}                         |   35 ++-
 .../interfaces/RobotMemoryInterface.cpp            |    2 +-
 .../interfaces/RobotMemoryInterface.xml            |    2 +-
 src/plugins/robot-memory/robot_memory.cpp          |  305 +++++++++++++++++
 src/plugins/robot-memory/robot_memory.h            |   82 +++++
 src/plugins/robot-memory/robot_memory_thread.cpp   |  354 ++------------------
 src/plugins/robot-memory/robot_memory_thread.h     |   30 +--
 13 files changed, 595 insertions(+), 436 deletions(-)
 copy src/plugins/{nao => robot-memory}/aspect/Makefile (52%)
 copy src/plugins/robot-memory/{robot_memory_plugin.cpp => aspect/robot_memory_aspect.cpp} (56%)
 copy src/plugins/robot-memory/{robot_memory_plugin.cpp => aspect/robot_memory_aspect.h} (50%)
 create mode 100644 src/plugins/robot-memory/aspect/robot_memory_inifin.cpp
 copy src/plugins/robot-memory/{tests/robot_memory_test.cpp => aspect/robot_memory_inifin.h} (53%)
 create mode 100644 src/plugins/robot-memory/robot_memory.cpp
 create mode 100644 src/plugins/robot-memory/robot_memory.h


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

- *commit* 182922651a00e647f5d8eb519d60b3fdbc064572 - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Tue Aug 23 18:51:52 2016 +0200
Subject: mongodb: hint in exception to start the mongod service

 src/plugins/mongodb/mongodb_thread.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/mongodb/mongodb_thread.cpp b/src/plugins/mongodb/mongodb_thread.cpp
index 081fd18..c2a7e5b 100644
--- a/src/plugins/mongodb/mongodb_thread.cpp
+++ b/src/plugins/mongodb/mongodb_thread.cpp
@@ -326,7 +326,7 @@ MongoDBThread::ClientConf::create_client()
       client = clconn;
       std::string errmsg;
       if (! clconn->connect(__conn_hostport, errmsg)) {
-	throw Exception("Could not connect to MongoDB at %s: %s",
+	throw Exception("Could not connect to MongoDB at %s: %s\nYou probably forgot to start/enable the mongod service",
 			__conn_hostport.toString().c_str(), errmsg.c_str());
       }
       std::list<AuthInfo>::iterator ai;

- *commit* 8bc2ab5189aa6849d6ca33d0ea691711db8d5cdf - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Tue Aug 23 18:55:19 2016 +0200
Subject: robot-memory: provide aspect for using the RobotMemory

 src/plugins/robot-memory/Makefile                  |    9 +-
 src/plugins/{nao => robot-memory}/aspect/Makefile  |   33 +-
 .../robot_memory_aspect.cpp}                       |   51 ++--
 .../robot_memory_aspect.h}                         |   47 ++--
 .../robot-memory/aspect/robot_memory_inifin.cpp    |   79 +++++
 .../robot_memory_inifin.h}                         |   35 ++-
 .../interfaces/RobotMemoryInterface.cpp            |    2 +-
 .../interfaces/RobotMemoryInterface.xml            |    2 +-
 src/plugins/robot-memory/robot_memory.cpp          |  305 +++++++++++++++++
 src/plugins/robot-memory/robot_memory.h            |   82 +++++
 src/plugins/robot-memory/robot_memory_thread.cpp   |  354 ++------------------
 src/plugins/robot-memory/robot_memory_thread.h     |   30 +--
 12 files changed, 594 insertions(+), 435 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/robot-memory/Makefile b/src/plugins/robot-memory/Makefile
index 78fe64a..6deb5cb 100644
--- a/src/plugins/robot-memory/Makefile
+++ b/src/plugins/robot-memory/Makefile
@@ -19,16 +19,13 @@ include $(BASEDIR)/etc/buildsys/config.mk
 include $(BUILDCONFDIR)/tf/tf.mk
 include $(BASEDIR)/src/plugins/mongodb/mongodb.mk
 
-PRESUBDIRS = interfaces
+PRESUBDIRS = interfaces aspect
 
 LIBS_robot_memory = fawkescore fawkesaspects fawkesblackboard fawkesinterface \
 		fawkesutils fawkeslogging fawkesmongodbaspect fvutils \
-		fawkestf RobotMemoryInterface
+		fawkestf RobotMemoryInterface fawkesrobotmemory
 OBJS_robot_memory = $(patsubst %.cpp,%.o,$(patsubst qa/%,,$(subst $(SRCDIR)/,,$(realpath $(wildcard $(SRCDIR)/*.cpp)))))
 
-CFLAGS  += $(CFLAGS_MONGODB)
-LDFLAGS += $(LDFLAGS_MONGODB)
-
 OBJS_all    = $(OBJS_robot_memory)
 
 ifeq ($(HAVE_MONGODB)$(HAVE_TF),11)
@@ -49,7 +46,7 @@ all: $(WARN_TARGETS)
 
 .PHONY: warning_mongodb warning_tf
 warning_mongodb:
-	$(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Omitting MongoDB Logging Plugin$(TNORMAL) (mongodb[-devel] not installed)"
+	$(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Omitting RobotMemory Plugin$(TNORMAL) (mongodb[-devel] not installed)"
 warning_tf:
 	$(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Omitting PCL utility library$(TNORMAL) (tf framework not available)"
 endif
diff --git a/src/plugins/robot-memory/interfaces/RobotMemoryInterface.cpp b/src/plugins/robot-memory/interfaces/RobotMemoryInterface.cpp
index 54650b9..a60da8d 100644
--- a/src/plugins/robot-memory/interfaces/RobotMemoryInterface.cpp
+++ b/src/plugins/robot-memory/interfaces/RobotMemoryInterface.cpp
@@ -56,7 +56,7 @@ RobotMemoryInterface::RobotMemoryInterface() : Interface()
   add_messageinfo("InsertMessage");
   add_messageinfo("UpdateMessage");
   add_messageinfo("RemoveMessage");
-  unsigned char tmp_hash[] = {0x61, 0x88, 0x21, 0xcd, 0x5a, 0x65, 0x18, 0x8d, 0x60, 0xaf, 0xf5, 0x57, 0x30, 0x4c, 0x6b, 0xd8};
+  unsigned char tmp_hash[] = {0x57, 0x8, 0x55, 0x6b, 0x61, 0x8, 0xc9, 0x16, 0xf7, 0x68, 0xcc, 0x7e, 0xae, 0xe2, 0x42, 0xe};
   set_hash(tmp_hash);
 }
 
diff --git a/src/plugins/robot-memory/interfaces/RobotMemoryInterface.xml b/src/plugins/robot-memory/interfaces/RobotMemoryInterface.xml
index 56dcfe7..498cda9 100644
--- a/src/plugins/robot-memory/interfaces/RobotMemoryInterface.xml
+++ b/src/plugins/robot-memory/interfaces/RobotMemoryInterface.xml
@@ -24,7 +24,7 @@
   </message>
   <message name="Update">
     <comment>
-      Message to update documents mathing a query.
+      Message to update documents matching a query.
     </comment>
     <field type="string"  length="1024" name="query">Query as JSON string</field>
     <field type="string"  length="1024" name="update">Update as JSON string</field>
diff --git a/src/plugins/robot-memory/robot_memory_thread.cpp b/src/plugins/robot-memory/robot_memory_thread.cpp
index 7774ab7..8bf74ec 100644
--- a/src/plugins/robot-memory/robot_memory_thread.cpp
+++ b/src/plugins/robot-memory/robot_memory_thread.cpp
@@ -26,10 +26,7 @@
 #include <core/threading/mutex_locker.h>
 #include <memory>
 
-// from MongoDB
-#include <mongo/client/dbclient.h>
 
-using namespace mongo;
 using namespace fawkes;
 
 /** @class RobotMemoryThread "robot_memory_thread.h"
@@ -40,39 +37,33 @@ using namespace fawkes;
 /** Constructor. */
 RobotMemoryThread::RobotMemoryThread()
 	: Thread("RobotMemoryThread", Thread::OPMODE_WAITFORWAKEUP),
-	  BlockedTimingAspect(BlockedTimingAspect::WAKEUP_HOOK_WORLDSTATE)
+	  BlockedTimingAspect(BlockedTimingAspect::WAKEUP_HOOK_SENSOR_PROCESS),
+    AspectProviderAspect(&robot_memory_inifin_)
 {
-  __mutex = new Mutex();
 }
 
 
 /** Destructor. */
 RobotMemoryThread::~RobotMemoryThread()
-{
-  delete __mutex;
-}
+{}
 
 
 void
 RobotMemoryThread::init()
 {
-	logger->log_info(name(), "Started RobotMemory");
-	__collection = "fawkes.msglog";
-  try {
-    __collection = config->get_string("/plugins/mongodb/test-collection");
-  } catch (Exception &e) {}
-
-  __rm_if = blackboard->open_for_writing<RobotMemoryInterface>(config->get_string("/plugins/robot-memory/interface-name").c_str());
-  __rm_if->set_error("");
-  __rm_if->set_result("");
-  
-  __rm_if->write();
+  //init RobotMemory itself
+  robot_memory = new RobotMemory(config, logger, clock, mongodb_client, blackboard);
+  robot_memory->init();
+  //prepare aspect initializer
+  robot_memory_inifin_.set_robot_memory(robot_memory);
 }
 
 
 void
 RobotMemoryThread::finalize()
 {
+  robot_memory_inifin_.set_robot_memory(NULL);
+  delete robot_memory;
 }
 
 
@@ -80,321 +71,24 @@ void
 RobotMemoryThread::loop()
 {
 	// process interface messages
-  while (! __rm_if->msgq_empty() ) {
-    if (__rm_if->msgq_first_is<RobotMemoryInterface::QueryMessage>()) {
-	    RobotMemoryInterface::QueryMessage* msg = (RobotMemoryInterface::QueryMessage*) __rm_if->msgq_first();
-	    exec_query(msg->query());
-    } else if (__rm_if->msgq_first_is<RobotMemoryInterface::InsertMessage>()) {
-	    RobotMemoryInterface::InsertMessage* msg = (RobotMemoryInterface::InsertMessage*) __rm_if->msgq_first();
-	    exec_insert(msg->insert());
-    } else if (__rm_if->msgq_first_is<RobotMemoryInterface::UpdateMessage>()) {
-	    RobotMemoryInterface::UpdateMessage* msg = (RobotMemoryInterface::UpdateMessage*) __rm_if->msgq_first();
-	    exec_update(msg->query(), msg->update());
-    } else if (__rm_if->msgq_first_is<RobotMemoryInterface::RemoveMessage>()) {
-	    RobotMemoryInterface::RemoveMessage* msg = (RobotMemoryInterface::RemoveMessage*) __rm_if->msgq_first();
-	    exec_remove(msg->query());
+  while (! robot_memory->rm_if_->msgq_empty() ) {
+    if (robot_memory->rm_if_->msgq_first_is<RobotMemoryInterface::QueryMessage>()) {
+	    RobotMemoryInterface::QueryMessage* msg = (RobotMemoryInterface::QueryMessage*) robot_memory->rm_if_->msgq_first();
+	    robot_memory->exec_query(msg->query());
+    } else if (robot_memory->rm_if_->msgq_first_is<RobotMemoryInterface::InsertMessage>()) {
+	    RobotMemoryInterface::InsertMessage* msg = (RobotMemoryInterface::InsertMessage*) robot_memory->rm_if_->msgq_first();
+	    robot_memory->exec_insert(msg->insert());
+    } else if (robot_memory->rm_if_->msgq_first_is<RobotMemoryInterface::UpdateMessage>()) {
+	    RobotMemoryInterface::UpdateMessage* msg = (RobotMemoryInterface::UpdateMessage*) robot_memory->rm_if_->msgq_first();
+	    robot_memory->exec_update(msg->query(), msg->update());
+    } else if (robot_memory->rm_if_->msgq_first_is<RobotMemoryInterface::RemoveMessage>()) {
+	    RobotMemoryInterface::RemoveMessage* msg = (RobotMemoryInterface::RemoveMessage*) robot_memory->rm_if_->msgq_first();
+	    robot_memory->exec_remove(msg->query());
     } else {
       logger->log_warn(name(), "Unknown message received");
     }
 
-    __rm_if->msgq_pop();
+    robot_memory->rm_if_->msgq_pop();
   }
 }
 
-void RobotMemoryThread::exec_query(std::string query_string)
-{
-	exec_query(query_string, __collection);
-}
-void RobotMemoryThread::exec_query(std::string query_string, std::string collection)
-{
-	logger->log_info(name(), "Executing Query: %s", query_string.c_str());
-
-	//only one query at a time
-	MutexLocker lock(__mutex);
-
-	//get query from string
-	Query query;
-	try{
-	  query = Query(query_string);
-	} catch (DBException &e) {
-		logger->log_error(name(), "Can't parse query_string '%s'\n Exception: %s",
-		                  query_string.c_str(), e.toString().c_str());
-		__rm_if->set_error((std::string("Can't parse query_string ") +  query_string
-		                    + "\nException: " + e.toString()).c_str());
-		__rm_if->write();
-		return;
-	}
-
-	//introspect query
-	log(query, "executing query:");
-
-	//check if virtual knowledge is queried
-	//rename field in query
-	if(query.getFilter().hasField("class")){
-		set_fields(query, std::string("{type:\"") +
-		           query.getFilter()["class"].String() + "\"}");
-		remove_field(query, "class");
-	}
-	log(query, "Virtual query:");
-	//computation on request
-	if(query.getFilter().hasField("bbinterface")){
-		collection = config->get_string("plugins/robot-memory/blackboard-collection");
-		gen_blackboard_data(query.getFilter()["bbinterface"].String());
-	}
-	log(query, "Virtual query:");
-	
-	//actually execute query
-	std::unique_ptr<DBClientCursor> cursor;
-	try{
-	  cursor = mongodb_client->query(collection, query);
-	} catch (DBException &e) {
-		logger->log_error(name(), "Error for query %s\n Exception: %s",
-		                  query_string.c_str(), e.toString().c_str());
-		__rm_if->set_error((std::string("Query error for ") +  query_string
-		                    + "\nException: " + e.toString()).c_str());
-		__rm_if->write();
-		return;
-	}
-
-	if(cursor->more()){
-		BSONObj res = cursor->next();
-		logger->log_info(name(), "Query One result:\n%s", res.toString().c_str());
-		__rm_if->set_result(res.toString().c_str());
-		__rm_if->write();
-	}
-	else {
-		logger->log_info(name(), "Query result empty");
-	}
-}
-
-void RobotMemoryThread::exec_insert(std::string insert_string)
-{
-	exec_insert(insert_string, __collection);
-}
-void RobotMemoryThread::exec_insert(std::string insert_string, std::string collection)
-{
-	logger->log_info(name(), "Executing Query: %s", insert_string.c_str());
-
-	//only one query at a time
-	MutexLocker lock(__mutex);
-
-	//get query from string
-  BSONObj obj;
-	try{
-		obj = fromjson(insert_string);
-	} catch (DBException &e) {
-		logger->log_error(name(), "Can't parse insert_string '%s'\n Exception: %s",
-		                  insert_string.c_str(), e.toString().c_str());
-		__rm_if->set_error((std::string("Can't parse insert_string ") +  insert_string
-		                    + "\nException: " + e.toString()).c_str());
-		__rm_if->write();
-		return;
-	}
-
-	log(obj, "Inserting:");
-	set_fields(obj, "{type: \"test\"}");
-	log(obj, "Updated Inserting:");
-	
-	//actually execute insert
-	try{
-	  mongodb_client->insert(collection, obj);
-	} catch (DBException &e) {
-		logger->log_error(name(), "Error for insert %s\n Exception: %s",
-		                  insert_string.c_str(), e.toString().c_str());
-		__rm_if->set_error((std::string("Query error for ") +  insert_string
-		                    + "\nException: " + e.toString()).c_str());
-		__rm_if->write();
-		return;
-	}
-
-	__rm_if->set_result("insert successful");
-	__rm_if->write();
-}
-
-void RobotMemoryThread::exec_update(std::string query_string, std::string update_string)
-{
-	exec_update(query_string, update_string, __collection);
-}
-void RobotMemoryThread::exec_update(std::string query_string, std::string update_string,
-                                    std::string collection)
-{
-	logger->log_info(name(), "Executing Update %s for query %s",
-	                 update_string.c_str(), query_string.c_str());
-
-	//only one query at a time
-	MutexLocker lock(__mutex);
-
-	//get query from string
-	Query query;
-	try{
-	  query = Query(query_string);
-	} catch (DBException &e) {
-		logger->log_error(name(), "Can't parse query_string '%s'\n Exception: %s",
-		                  query_string.c_str(), e.toString().c_str());
-		__rm_if->set_error((std::string("Can't parse query_string ") +  query_string
-		                    + "\nException: " + e.toString()).c_str());
-		__rm_if->write();
-		return;
-	}
-	BSONObj update;
-	try{
-		update = fromjson(update_string);
-	} catch (DBException &e) {
-		logger->log_error(name(), "Can't parse update_string '%s'\n Exception: %s",
-		                  update_string.c_str(), e.toString().c_str());
-		__rm_if->set_error((std::string("Can't parse update_string ") +  update_string
-		                    + "\nException: " + e.toString()).c_str());
-		__rm_if->write();
-		return;
-	}
-
-	log(query, "Updating documents for query:");
-	log(update, "Updating with:");
-	
-	//actually execute update
-	try{
-		mongodb_client->update(collection, query, update);
-	} catch (DBException &e) {
-		logger->log_error(name(), "Error for update %s for query %s\n Exception: %s",
-		                  update_string.c_str(), query_string.c_str(), e.toString().c_str());
-		__rm_if->set_error((std::string("Query error for ") +  query_string + " and update "
-		                    + update_string + "\nException: " + e.toString()).c_str());
-		__rm_if->write();
-		return;
-	}
-
-	__rm_if->set_result("update successful");
-	__rm_if->write();
-}
-
-void RobotMemoryThread::exec_remove(std::string query_string)
-{
-	exec_remove(query_string, __collection);
-}
-
-void RobotMemoryThread::exec_remove(std::string query_string, std::string collection)
-{
-	logger->log_info(name(), "Executing Remove: %s", query_string.c_str());
-
-	//only one query at a time
-	MutexLocker lock(__mutex);
-
-	//get query from string
-	Query query;
-	try{
-	  query = Query(query_string);
-	} catch (DBException &e) {
-		logger->log_error(name(), "Can't parse query_string '%s'\n Exception: %s",
-		                  query_string.c_str(), e.toString().c_str());
-		__rm_if->set_error((std::string("Can't parse query_string ") +  query_string
-		                    + "\nException: " + e.toString()).c_str());
-		__rm_if->write();
-		return;
-	}
-
-	//introspect
-	log(query, "Removing documents for query:");
-	
-	//actually execute remove
-	try{
-	  mongodb_client->remove(collection, query);
-	} catch (DBException &e) {
-		logger->log_error(name(), "Error for query %s\n Exception: %s",
-		                  query_string.c_str(), e.toString().c_str());
-		__rm_if->set_error((std::string("Query error for ") +  query_string
-		                    + "\nException: " + e.toString()).c_str());
-		__rm_if->write();
-		return;
-	}
-
-	__rm_if->set_result("remove successful");
-	__rm_if->write();
-}
-
-void
-RobotMemoryThread::log(Query query, std::string what)
-{
-	std::string output = what
-		+ "\nFilter: " + query.getFilter().toString()
-		+ "\nModifiers: " + query.getModifiers().toString()
-		+ "\nSort: " + query.getSort().toString()
-		+ "\nHint: " + query.getHint().toString()
-		+ "\nReadPref: " + query.getReadPref().toString();
-		
-	logger->log_info(name(), "%s", output.c_str());
-}
-
-void
-RobotMemoryThread::log(BSONObj obj, std::string what)
-{
-	std::string output = what
-		+ "\nObject: " + obj.toString();
-		
-	logger->log_info(name(), "%s", output.c_str());
-}
-
-void
-RobotMemoryThread::set_fields(BSONObj &obj, std::string what)
-{
-	BSONObjBuilder b;
-	b.appendElements(obj);
-	b.appendElements(fromjson(what));
-	//override
-	obj = b.obj();
-}
-
-void
-RobotMemoryThread::set_fields(Query &q, std::string what)
-{
-	BSONObjBuilder b;
-	b.appendElements(q.getFilter());
-	b.appendElements(fromjson(what));
-
-	//TODO keep other stuff in query
-	// + "\nFilter: " + query.getFilter().toString()
-	// + "\nModifiers: " + query.getModifiers().toString()
-	// + "\nSort: " + query.getSort().toString()
-	// + "\nHint: " + query.getHint().toString()
-	// + "\nReadPref: " + query.getReadPref().toString();
-     
-	//override
-	q = Query(b.obj());
-}
-
-void
-RobotMemoryThread::remove_field(Query &q, std::string what)
-{
-	BSONObjBuilder b;
-	b.appendElements(q.getFilter().removeField(what));
-	
-	//TODO keep other stuff in query
-	// + "\nFilter: " + query.getFilter().toString()
-	// + "\nModifiers: " + query.getModifiers().toString()
-	// + "\nSort: " + query.getSort().toString()
-	// + "\nHint: " + query.getHint().toString()
-	// + "\nReadPref: " + query.getReadPref().toString();
-	
-	//override
-	q = Query(b.obj());
-}
-
-void
-RobotMemoryThread::gen_blackboard_data(std::string field)
-{
-	logger->log_info(name(), "Generating virtual kb for bb");
-
-	std::string collection = config->get_string("plugins/robot-memory/blackboard-collection");
-	
-	//remove old data first
-	mongodb_client->remove(collection, Query{"{}"});
-	
-	BSONObjBuilder b;
-	b.append("type", "bbinterface");
-	__rm_if->read();
-	b.append("bbinterface", __rm_if->uid());
-	b.append("error", __rm_if->error());
-	b.append("result", __rm_if->result());
-	
-	mongodb_client->insert(collection, b.obj());  
-}
-
diff --git a/src/plugins/robot-memory/robot_memory_thread.h b/src/plugins/robot-memory/robot_memory_thread.h
index 8a5013c..b23ed42 100644
--- a/src/plugins/robot-memory/robot_memory_thread.h
+++ b/src/plugins/robot-memory/robot_memory_thread.h
@@ -31,6 +31,9 @@
 #include <aspect/blackboard.h>
 #include <aspect/blocked_timing.h>
 #include <mongo/client/dbclient.h>
+#include <aspect/aspect_provider.h>
+#include "robot_memory.h"
+#include "aspect/robot_memory_inifin.h"
 
 #include <string>
 
@@ -46,7 +49,8 @@ class RobotMemoryThread
   public fawkes::ClockAspect,
   public fawkes::MongoDBAspect,
 	public fawkes::BlockedTimingAspect,
-  public fawkes::BlackBoardAspect
+  public fawkes::BlackBoardAspect,
+  public fawkes::AspectProviderAspect
 {
  public:
   RobotMemoryThread();
@@ -60,28 +64,8 @@ class RobotMemoryThread
  protected: virtual void run() { Thread::run(); }
 
  private:
-  std::string    __collection;
-  fawkes::Mutex *__mutex;
-  fawkes::RobotMemoryInterface *__rm_if;
-
-  void exec_query(std::string query, std::string collection);
-  void exec_query(std::string query);
-  void exec_insert(std::string insert, std::string collection);
-  void exec_insert(std::string insert);
-  void exec_update(std::string query, std::string update, std::string collection);
-  void exec_update(std::string query, std::string update);
-  void exec_remove(std::string query, std::string collection);
-  void exec_remove(std::string query);
-
-  void log(mongo::Query query, std::string what);
-  void log(mongo::BSONObj obj, std::string what);
-
-  void set_fields(mongo::BSONObj &obj, std::string what);
-  void set_fields(mongo::Query &q, std::string what);
-  void remove_field(mongo::Query &q, std::string what);
-
-  //funtions to generate virtual knowledge
-  void gen_blackboard_data(std::string field);
+   RobotMemory* robot_memory;
+   fawkes::RobotMemoryIniFin robot_memory_inifin_;
 };
 
 #endif




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


More information about the fawkes-commits mailing list