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

Frederik Zwilling zwilling at kbsg.rwth-aachen.de
Tue Nov 1 18:14:13 CET 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  57d984fa1b912f98e5c9fd89d626a7f9e99ad93c (commit)
       via  4c48028893519f687c05948383ab0f4ed9092f8d (commit)
      from  60b435c6524e8d4411feca88d83007991ec2784e (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 4c48028893519f687c05948383ab0f4ed9092f8d
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Tue Nov 1 13:21:29 2016 +0100
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Tue Nov 1 18:14:03 2016 +0100

    robot-memory: moved computables in subfolder

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 57d984fa1b912f98e5c9fd89d626a7f9e99ad93c
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Tue Nov 1 18:12:02 2016 +0100
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Tue Nov 1 18:14:07 2016 +0100

    robot-memory: added computable for blackboard interfaces

http://git.fawkesrobotics.org/fawkes.git/commit/57d984f
http://trac.fawkesrobotics.org/changeset/57d984f

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


- *Summary* -----------------------------------------------------------
 src/plugins/robot-memory/Makefile                  |    1 +
 .../computables/blackboard_computable.cpp          |  120 ++++++++++++++++++++
 .../computables/blackboard_computable.h            |   50 ++++++++
 .../robot-memory/{ => computables}/computable.cpp  |    0
 .../robot-memory/{ => computables}/computable.h    |    0
 .../{ => computables}/computables_manager.cpp      |    0
 .../{ => computables}/computables_manager.h        |    0
 src/plugins/robot-memory/robot_memory.cpp          |   11 +-
 src/plugins/robot-memory/robot_memory.h            |    2 +-
 src/plugins/robot-memory/robot_memory_thread.cpp   |    4 +
 src/plugins/robot-memory/robot_memory_thread.h     |    2 +
 src/plugins/robot-memory/test-plugin/Makefile      |    3 +-
 .../robot-memory/test-plugin/robot_memory_test.cpp |   25 ++++-
 .../robot-memory/test-plugin/robot_memory_test.h   |    6 +-
 .../test-plugin/robot_memory_test_thread.cpp       |    2 +-
 15 files changed, 215 insertions(+), 11 deletions(-)
 create mode 100644 src/plugins/robot-memory/computables/blackboard_computable.cpp
 create mode 100644 src/plugins/robot-memory/computables/blackboard_computable.h
 rename src/plugins/robot-memory/{ => computables}/computable.cpp (100%)
 rename src/plugins/robot-memory/{ => computables}/computable.h (100%)
 rename src/plugins/robot-memory/{ => computables}/computables_manager.cpp (100%)
 rename src/plugins/robot-memory/{ => computables}/computables_manager.h (100%)


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

- *commit* 4c48028893519f687c05948383ab0f4ed9092f8d - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Tue Nov 1 13:21:29 2016 +0100
Subject: robot-memory: moved computables in subfolder

 src/plugins/robot-memory/Makefile                  |    1 +
 .../robot-memory/{ => computables}/computable.cpp  |    0
 .../robot-memory/{ => computables}/computable.h    |    0
 .../{ => computables}/computables_manager.cpp      |    0
 .../{ => computables}/computables_manager.h        |    0
 src/plugins/robot-memory/robot_memory.h            |    2 +-
 6 files changed, 2 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/robot-memory/Makefile b/src/plugins/robot-memory/Makefile
index d25debd..ffb656f 100644
--- a/src/plugins/robot-memory/Makefile
+++ b/src/plugins/robot-memory/Makefile
@@ -30,6 +30,7 @@ LIBS_robot_memory = fawkescore fawkesaspects fawkesblackboard fawkesinterface \
 		fawkesutils fawkeslogging fawkesmongodbaspect fvutils \
 		fawkestf RobotMemoryInterface fawkesrobotmemory
 OBJS_robot_memory = $(patsubst %.cpp,%.o,$(patsubst qa/%,,$(subst $(SRCDIR)/,,$(realpath $(wildcard $(SRCDIR)/*.cpp)))))
+OBJS_robot_memory += $(patsubst %.cpp,%.o,$(patsubst qa/%,,$(subst $(SRCDIR)/,,$(realpath $(wildcard $(SRCDIR)/computables/*.cpp)))))
 
 OBJS_all    = $(OBJS_robot_memory)
 
diff --git a/src/plugins/robot-memory/robot_memory.h b/src/plugins/robot-memory/robot_memory.h
index 163a788..5f032f4 100644
--- a/src/plugins/robot-memory/robot_memory.h
+++ b/src/plugins/robot-memory/robot_memory.h
@@ -30,7 +30,7 @@
 #include <mongo/client/dbclient.h>
 #include "interfaces/RobotMemoryInterface.h"
 #include "event_trigger_manager.h"
-#include "computables_manager.h"
+#include "computables/computables_manager.h"
 
 namespace fawkes {
   class Mutex;

- *commit* 57d984fa1b912f98e5c9fd89d626a7f9e99ad93c - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Tue Nov 1 18:12:02 2016 +0100
Subject: robot-memory: added computable for blackboard interfaces

 .../computables/blackboard_computable.cpp          |  120 ++++++++++++++++++++
 .../computables/blackboard_computable.h            |   50 ++++++++
 src/plugins/robot-memory/robot_memory.cpp          |   11 +-
 src/plugins/robot-memory/robot_memory_thread.cpp   |    4 +
 src/plugins/robot-memory/robot_memory_thread.h     |    2 +
 src/plugins/robot-memory/test-plugin/Makefile      |    3 +-
 .../robot-memory/test-plugin/robot_memory_test.cpp |   25 ++++-
 .../robot-memory/test-plugin/robot_memory_test.h   |    6 +-
 .../test-plugin/robot_memory_test_thread.cpp       |    2 +-
 9 files changed, 213 insertions(+), 10 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/robot-memory/robot_memory.cpp b/src/plugins/robot-memory/robot_memory.cpp
index bdeff5b..d02a39b 100644
--- a/src/plugins/robot-memory/robot_memory.cpp
+++ b/src/plugins/robot-memory/robot_memory.cpp
@@ -118,7 +118,7 @@ QResCursor RobotMemory::query(Query query, std::string collection)
   check_collection_name(collection);
   log_deb(std::string("Executing Query "+ query.toString() +" on collection "+collection));
 
-  //only one query at a time
+  //lock (mongo_client not thread safe)
   MutexLocker lock(mutex_);
 
   //check if computation on demand is necessary and execute Computables
@@ -152,7 +152,7 @@ int RobotMemory::insert(BSONObj obj, std::string collection)
 
   log_deb(std::string("Executing Query "+ obj.toString() + " on collection " + collection));
 
-  //only one query at a time
+  //lock (mongo_client not thread safe)
   MutexLocker lock(mutex_);
 
   //actually execute insert
@@ -192,7 +192,7 @@ int RobotMemory::update(Query query, BSONObj update, std::string collection, boo
   check_collection_name(collection);
   log_deb(std::string("Executing Update "+update.toString()+" for query "+query.toString()+" on collection "+ collection));
 
-  //only one query at a time
+  //lock (mongo_client not thread safe)
   MutexLocker lock(mutex_);
 
   //actually execute update
@@ -230,7 +230,7 @@ int RobotMemory::remove(Query query, std::string collection)
   check_collection_name(collection);
   log_deb(std::string("Executing Remove "+query.toString()+" on collection "+collection));
 
-  //only one query at a time
+  //lock (mongo_client not thread safe)
   MutexLocker lock(mutex_);
 
   //actually execute remove
@@ -261,6 +261,9 @@ int RobotMemory::drop_collection(std::string collection)
  */
 int RobotMemory::clear_memory()
 {
+  //lock (mongo_client not thread safe)
+  MutexLocker lock(mutex_);
+
   log_deb("Clearing whole robot memory");
   mongodb_client_->dropDatabase(database_name_);
   return 1;
diff --git a/src/plugins/robot-memory/robot_memory_thread.cpp b/src/plugins/robot-memory/robot_memory_thread.cpp
index 5509a14..ba82068 100644
--- a/src/plugins/robot-memory/robot_memory_thread.cpp
+++ b/src/plugins/robot-memory/robot_memory_thread.cpp
@@ -58,12 +58,16 @@ RobotMemoryThread::init()
   robot_memory->init();
   //prepare aspect initializer
   robot_memory_inifin_.set_robot_memory(robot_memory);
+
+  //register blackboard computable
+  blackboard_computable = new BlackboardComputable(robot_memory, blackboard, logger);
 }
 
 
 void
 RobotMemoryThread::finalize()
 {
+  delete blackboard_computable;
   robot_memory_inifin_.set_robot_memory(NULL);
   delete robot_memory;
 }
diff --git a/src/plugins/robot-memory/robot_memory_thread.h b/src/plugins/robot-memory/robot_memory_thread.h
index 610252f..23ce0ef 100644
--- a/src/plugins/robot-memory/robot_memory_thread.h
+++ b/src/plugins/robot-memory/robot_memory_thread.h
@@ -34,6 +34,7 @@
 #include <aspect/aspect_provider.h>
 #include "robot_memory.h"
 #include "aspect/robot_memory_inifin.h"
+#include "computables/blackboard_computable.h"
 
 #include <string>
 
@@ -66,6 +67,7 @@ class RobotMemoryThread
  private:
    RobotMemory* robot_memory;
    fawkes::RobotMemoryIniFin robot_memory_inifin_;
+   BlackboardComputable* blackboard_computable;
 };
 
 #endif
diff --git a/src/plugins/robot-memory/test-plugin/Makefile b/src/plugins/robot-memory/test-plugin/Makefile
index 546954c..3406a6b 100644
--- a/src/plugins/robot-memory/test-plugin/Makefile
+++ b/src/plugins/robot-memory/test-plugin/Makefile
@@ -19,7 +19,8 @@ include $(BASEDIR)/etc/buildsys/config.mk
 include $(BASEDIR)/etc/buildsys/gtest.mk
 
 LIBS_robot_memory_test = m fawkescore fawkesutils fawkesaspects fawkesbaseapp \
-                      fawkesblackboard fawkesinterface fawkesrobotmemory
+                      fawkesblackboard fawkesinterface fawkesrobotmemory \
+                      Position3DInterface
 
 OBJS_robot_memory_test = robot_memory_test_plugin.o robot_memory_test_thread.o robot_memory_test.o
 
diff --git a/src/plugins/robot-memory/test-plugin/robot_memory_test.cpp b/src/plugins/robot-memory/test-plugin/robot_memory_test.cpp
index cfd0e3b..d004258 100644
--- a/src/plugins/robot-memory/test-plugin/robot_memory_test.cpp
+++ b/src/plugins/robot-memory/test-plugin/robot_memory_test.cpp
@@ -20,21 +20,24 @@
  */
 
 #include "robot_memory_test.h"
+#include <interfaces/Position3DInterface.h>
 #include <list>
 #include <algorithm>
 
-//init static variable
-RobotMemory* RobotMemoryTestEnvironment::robot_memory = NULL;
-
 using namespace fawkes;
 using namespace mongo;
 
+//init static variable
+RobotMemory* RobotMemoryTestEnvironment::robot_memory = NULL;
+BlackBoard* RobotMemoryTestEnvironment::blackboard = NULL;
+
 /**
  * Setup for each test
  */
 void RobotMemoryTest::SetUp()
 {
   robot_memory = RobotMemoryTestEnvironment::robot_memory;
+  blackboard = RobotMemoryTestEnvironment::blackboard;
 }
 
 TEST_F(RobotMemoryTest, TestsWorking)
@@ -280,3 +283,19 @@ TEST_F(RobotMemoryTest, ComputableMultiple)
   ASSERT_FALSE(qres->more());
   robot_memory->remove_computable(comp);
 }
+
+
+TEST_F(RobotMemoryTest, BlackboardComputable)
+{
+  Position3DInterface* if3d = blackboard->open_for_writing<Position3DInterface>("test");
+  if3d->set_frame("test_frame");
+  if3d->set_translation(0, 1.1);
+  if3d->set_translation(1, 2.2);
+  if3d->set_translation(2, 3.3);
+  if3d->write();
+  QResCursor qres = robot_memory->query(fromjson("{interface:'Position3DInterface',id:'test'}"), "robmem.blackboard");
+  ASSERT_TRUE(qres->more());
+  ASSERT_TRUE(contains_pairs(qres->next(), fromjson(
+      "{interface:'Position3DInterface',id:'test',frame:'test_frame',translation:[1.1, 2.2, 3.3]}")));
+  blackboard->close(if3d);
+}
diff --git a/src/plugins/robot-memory/test-plugin/robot_memory_test.h b/src/plugins/robot-memory/test-plugin/robot_memory_test.h
index ad596ed..cb12317 100644
--- a/src/plugins/robot-memory/test-plugin/robot_memory_test.h
+++ b/src/plugins/robot-memory/test-plugin/robot_memory_test.h
@@ -23,6 +23,7 @@
 #define __PLUGINS_ROBOT_MEMORY_TEST_H_
 
 #include <gtest/gtest.h>
+#include <blackboard/blackboard.h>
 #include "plugins/robot-memory/robot_memory.h"
 #include <stdio.h>
 
@@ -33,15 +34,17 @@
 class RobotMemoryTestEnvironment : public ::testing::Environment
 {
  public:
-  RobotMemoryTestEnvironment(RobotMemory* robot_memory)
+  RobotMemoryTestEnvironment(RobotMemory* robot_memory, fawkes::BlackBoard* blackboard)
   {
     this->robot_memory = robot_memory;
+    this->blackboard = blackboard;
   }
   virtual ~RobotMemoryTestEnvironment() {}
   void SetUp() {}
   virtual void TearDown(){}
  public:
   static RobotMemory* robot_memory;
+  static fawkes::BlackBoard* blackboard;
 };
 
 /** Class for Tests of the RobotMemory
@@ -51,6 +54,7 @@ class RobotMemoryTest : public ::testing::Test
  protected:
   virtual void SetUp();
   RobotMemory* robot_memory;
+  fawkes::BlackBoard* blackboard;
 
  protected:
   ::testing::AssertionResult contains_pairs(mongo::BSONObj obj, mongo::BSONObj exp);
diff --git a/src/plugins/robot-memory/test-plugin/robot_memory_test_thread.cpp b/src/plugins/robot-memory/test-plugin/robot_memory_test_thread.cpp
index 640917b..89d8f54 100644
--- a/src/plugins/robot-memory/test-plugin/robot_memory_test_thread.cpp
+++ b/src/plugins/robot-memory/test-plugin/robot_memory_test_thread.cpp
@@ -44,7 +44,7 @@ RobotMemoryTestThread::init()
 {
   //prepare tests
   logger->log_warn(name(), "Preparing tests");
-  test_env_ = new RobotMemoryTestEnvironment(robot_memory);
+  test_env_ = new RobotMemoryTestEnvironment(robot_memory, blackboard);
   ::testing::AddGlobalTestEnvironment((testing::Environment*) test_env_);
 
 }




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


More information about the fawkes-commits mailing list