[Fawkes Git] branch/fzwilling/robot-memory: 4 revs updated. (0.5.0-3094-ge1ca80b)

Frederik Zwilling zwilling at kbsg.rwth-aachen.de
Wed Aug 24 17:43:24 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  e1ca80b64149553b3e4b45393b7af50d3b3ff3e9 (commit)
       via  19166057c87f28c0f8b1fc55572f20cb371ab13c (commit)
       via  2d4b77e55d659fe25cc04c546f6e18d5e9efcf62 (commit)
       via  dd8aa99ca6506fd0cc134470fa02a80977d5f2ac (commit)
      from  8bc2ab5189aa6849d6ca33d0ea691711db8d5cdf (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 dd8aa99ca6506fd0cc134470fa02a80977d5f2ac
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Wed Aug 24 11:36:35 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Wed Aug 24 15:01:07 2016 +0200

    robot-memory: clearer api functions

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 2d4b77e55d659fe25cc04c546f6e18d5e9efcf62
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Wed Aug 24 14:03:51 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Wed Aug 24 15:01:13 2016 +0200

    gtest: tool for unit testing in a running fawkes environment
    
    This tool allows gtest unit tests depending on a running fawkes
    environmnet with aspects, plugins, blackboard, etc.
    You can execute tests with "make test" in src/tools/gtest. It then
    starts fawkes similar to the mainapp's main function with a set of
    plugins containing a test-plugin. This test plugin implements unit tests
    and calls the RUN_ALL_TESTS makro. Afterwards the plugins ends fawkes.

http://git.fawkesrobotics.org/fawkes.git/commit/2d4b77e
http://trac.fawkesrobotics.org/changeset/2d4b77e

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 19166057c87f28c0f8b1fc55572f20cb371ab13c
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Wed Aug 24 14:59:22 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Wed Aug 24 15:01:17 2016 +0200

    robot-memory: created gtest plugin to run tests in fawkes

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit e1ca80b64149553b3e4b45393b7af50d3b3ff3e9
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Wed Aug 24 17:40:48 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Wed Aug 24 17:43:19 2016 +0200

    robot-memory-test: provide environment with access to the RobotMemory

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

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


- *Summary* -----------------------------------------------------------
 src/plugins/robot-memory/robot_memory.cpp          |   56 ++++++++--------
 src/plugins/robot-memory/robot_memory.h            |   14 ++---
 src/plugins/robot-memory/robot_memory_thread.cpp   |    8 +-
 .../robot-memory/{tests => test-plugin}/Makefile   |   19 +++---
 .../{tests => test-plugin}/robot_memory_test.cpp   |   31 +++++++--
 .../robot-memory/test-plugin/robot_memory_test.h   |   56 ++++++++++++++++
 .../robot_memory_test_plugin.cpp}                  |   38 +++++------
 .../test-plugin/robot_memory_test_thread.cpp       |   67 +++++++++++++++++++
 .../test-plugin/robot_memory_test_thread.h}        |   47 +++++++-------
 .../robot-memory/tests => tools/gtest}/Makefile    |   21 ++++---
 src/tools/gtest/gtest_fawkes.cpp                   |   70 ++++++++++++++++++++
 11 files changed, 315 insertions(+), 112 deletions(-)
 copy src/plugins/robot-memory/{tests => test-plugin}/Makefile (69%)
 rename src/plugins/robot-memory/{tests => test-plugin}/robot_memory_test.cpp (63%)
 create mode 100644 src/plugins/robot-memory/test-plugin/robot_memory_test.h
 copy src/plugins/robot-memory/{robot_memory_plugin.cpp => test-plugin/robot_memory_test_plugin.cpp} (62%)
 create mode 100644 src/plugins/robot-memory/test-plugin/robot_memory_test_thread.cpp
 copy src/plugins/{ros/odometry_thread.h => robot-memory/test-plugin/robot_memory_test_thread.h} (66%)
 rename src/{plugins/robot-memory/tests => tools/gtest}/Makefile (65%)
 create mode 100644 src/tools/gtest/gtest_fawkes.cpp


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

- *commit* dd8aa99ca6506fd0cc134470fa02a80977d5f2ac - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Wed Aug 24 11:36:35 2016 +0200
Subject: robot-memory: clearer api functions

 src/plugins/robot-memory/robot_memory.cpp        |   56 +++++++++++-----------
 src/plugins/robot-memory/robot_memory.h          |   14 ++----
 src/plugins/robot-memory/robot_memory_thread.cpp |    8 ++--
 3 files changed, 37 insertions(+), 41 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/robot-memory/robot_memory.cpp b/src/plugins/robot-memory/robot_memory.cpp
index cd0d647..d460f5a 100644
--- a/src/plugins/robot-memory/robot_memory.cpp
+++ b/src/plugins/robot-memory/robot_memory.cpp
@@ -52,9 +52,9 @@ void RobotMemory::init()
 {
   //load config values
   logger_->log_info(name_, "Started RobotMemory");
-  collection_ = "fawkes.msglog";
+  default_collection_ = "fawkes.msglog";
   try {
-    collection_ = config_->get_string("/plugins/mongodb/test-collection");
+    default_collection_ = config_->get_string("/plugins/mongodb/test-collection");
   } catch (Exception &e) {}
 
   //init blackboard interface
@@ -64,13 +64,13 @@ void RobotMemory::init()
   rm_if_->write();
 }
 
-void RobotMemory::exec_query(std::string query_string)
+void RobotMemory::query(std::string query_string, std::string collection)
 {
-  exec_query(query_string, collection_);
-}
-void RobotMemory::exec_query(std::string query_string, std::string collection)
-{
-  logger_->log_info(name_, "Executing Query: %s", query_string.c_str());
+  if(collection == "")
+  {
+    collection = default_collection_;
+  }
+  logger_->log_info(name_, "Executing Query %s on collection %s", query_string.c_str(), collection);
 
   //only one query at a time
   MutexLocker lock(mutex_);
@@ -122,13 +122,13 @@ void RobotMemory::exec_query(std::string query_string, std::string collection)
   }
 }
 
-void RobotMemory::exec_insert(std::string insert_string)
+void RobotMemory::insert(std::string insert_string, std::string collection)
 {
-  exec_insert(insert_string, collection_);
-}
-void RobotMemory::exec_insert(std::string insert_string, std::string collection)
-{
-  logger_->log_info(name_, "Executing Query: %s", insert_string.c_str());
+  if(collection == "")
+  {
+    collection = default_collection_;
+  }
+  logger_->log_info(name_, "Executing Query %s on collection %s", insert_string.c_str(), collection);
 
   //only one query at a time
   MutexLocker lock(mutex_);
@@ -157,15 +157,15 @@ void RobotMemory::exec_insert(std::string insert_string, std::string collection)
   }
 }
 
-void RobotMemory::exec_update(std::string query_string, std::string update_string)
-{
-  exec_update(query_string, update_string, collection_);
-}
-void RobotMemory::exec_update(std::string query_string, std::string update_string,
+void RobotMemory::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());
+  if(collection == "")
+  {
+    collection = default_collection_;
+  }
+  logger_->log_info(name_, "Executing Update %s for query %s on collection %s",
+                   update_string.c_str(), query_string.c_str(), collection);
 
   //only one query at a time
   MutexLocker lock(mutex_);
@@ -201,14 +201,14 @@ void RobotMemory::exec_update(std::string query_string, std::string update_strin
   }
 }
 
-void RobotMemory::exec_remove(std::string query_string)
-{
-  exec_remove(query_string, collection_);
-}
-
-void RobotMemory::exec_remove(std::string query_string, std::string collection)
+void RobotMemory::remove(std::string query_string, std::string collection)
 {
-  logger_->log_info(name_, "Executing Remove: %s", query_string.c_str());
+  if(collection == "")
+  {
+    collection = default_collection_;
+  }
+  logger_->log_info(name_, "Executing Remove %s on collection %s",
+                    query_string.c_str(), collection);
 
   //only one query at a time
   MutexLocker lock(mutex_);
diff --git a/src/plugins/robot-memory/robot_memory.h b/src/plugins/robot-memory/robot_memory.h
index 7eb00ee..8584de1 100644
--- a/src/plugins/robot-memory/robot_memory.h
+++ b/src/plugins/robot-memory/robot_memory.h
@@ -48,14 +48,10 @@ class RobotMemory
     virtual ~RobotMemory();
 
     //robot memory functions
-    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 query(std::string query, std::string collection = "");
+    void insert(std::string insert, std::string collection = "");
+    void update(std::string query, std::string update, std::string collection = "");
+    void remove(std::string query, std::string collection = "");
 
   private:
     mongo::DBClientBase* mongodb_client_;
@@ -65,7 +61,7 @@ class RobotMemory
     fawkes::BlackBoard* blackboard_;
 
     const char* name_ = "RobotMemory";
-    std::string collection_;
+    std::string default_collection_;
     fawkes::Mutex *mutex_;
     fawkes::RobotMemoryInterface* rm_if_;
 
diff --git a/src/plugins/robot-memory/robot_memory_thread.cpp b/src/plugins/robot-memory/robot_memory_thread.cpp
index 8bf74ec..5ba2c0c 100644
--- a/src/plugins/robot-memory/robot_memory_thread.cpp
+++ b/src/plugins/robot-memory/robot_memory_thread.cpp
@@ -74,16 +74,16 @@ RobotMemoryThread::loop()
   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());
+	    robot_memory->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());
+	    robot_memory->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());
+	    robot_memory->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());
+	    robot_memory->remove(msg->query());
     } else {
       logger->log_warn(name(), "Unknown message received");
     }

- *commit* 2d4b77e55d659fe25cc04c546f6e18d5e9efcf62 - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Wed Aug 24 14:03:51 2016 +0200
Subject: gtest: tool for unit testing in a running fawkes environment

 .../robot-memory/tests => tools/gtest}/Makefile    |   21 ++++---
 src/tools/gtest/gtest_fawkes.cpp                   |   70 ++++++++++++++++++++
 2 files changed, 82 insertions(+), 9 deletions(-)


- *commit* 19166057c87f28c0f8b1fc55572f20cb371ab13c - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Wed Aug 24 14:59:22 2016 +0200
Subject: robot-memory: created gtest plugin to run tests in fawkes

 .../aspect => robot-memory/test-plugin}/Makefile   |   21 +++---
 .../robot_memory_test_plugin.cpp}                  |   38 +++++------
 .../test-plugin/robot_memory_test_thread.cpp       |   67 ++++++++++++++++++++
 .../test-plugin/robot_memory_test_thread.h}        |   33 ++++++----
 src/plugins/robot-memory/tests/Makefile            |   45 -------------
 .../robot-memory/tests/robot_memory_test.cpp       |   34 ----------
 6 files changed, 116 insertions(+), 122 deletions(-)


- *commit* e1ca80b64149553b3e4b45393b7af50d3b3ff3e9 - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Wed Aug 24 17:40:48 2016 +0200
Subject: robot-memory-test: provide environment with access to the RobotMemory

 src/plugins/robot-memory/test-plugin/Makefile      |   24 +++++++--
 .../test-plugin/robot_memory_test.cpp}             |   40 +++++++++-----
 .../robot-memory/test-plugin/robot_memory_test.h   |   56 ++++++++++++++++++++
 .../test-plugin/robot_memory_test_thread.cpp       |   10 ++--
 .../test-plugin/robot_memory_test_thread.h         |   10 ++--
 5 files changed, 112 insertions(+), 28 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/robot-memory/test-plugin/Makefile b/src/plugins/robot-memory/test-plugin/Makefile
index 377737c..546954c 100644
--- a/src/plugins/robot-memory/test-plugin/Makefile
+++ b/src/plugins/robot-memory/test-plugin/Makefile
@@ -19,12 +19,28 @@ include $(BASEDIR)/etc/buildsys/config.mk
 include $(BASEDIR)/etc/buildsys/gtest.mk
 
 LIBS_robot_memory_test = m fawkescore fawkesutils fawkesaspects fawkesbaseapp \
-                      fawkesblackboard fawkesinterface
+                      fawkesblackboard fawkesinterface fawkesrobotmemory
 
-OBJS_robot_memory_test = robot_memory_test_plugin.o robot_memory_test_thread.o
-
-PLUGINS_all = $(PLUGINDIR)/robot_memory_test.$(SOEXT)
+OBJS_robot_memory_test = robot_memory_test_plugin.o robot_memory_test_thread.o robot_memory_test.o
 
 OBJS_all = $(OBJS_robot_memory_test)
 
+ifeq ($(HAVE_GTEST)$(HAVE_CPP11),11)
+  CFLAGS += $(CFLAGS_GTEST)
+  CFLAGS += $(CFLAGS_CPP11)
+  LDFLAGS += $(LDFLAGS_GTEST)
+  PLUGINS_all = $(PLUGINDIR)/robot_memory_test.$(SOEXT)
+else
+  WARN_TARGETS += warning_gtest
+endif
+
+ifeq ($(OBJSSUBMAKE),1)
+test: $(WARN_TARGETS)
+
+.PHONY: warning_gtest
+warning_gtest:
+	$(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Omitting unit tests for Robot Memory$(TNORMAL) (gtest or cpp11 not available)"
+
+endif
+
 include $(BUILDSYSDIR)/base.mk
\ No newline at end of file
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 5a31270..2a3d7c3 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
@@ -39,14 +39,14 @@ RobotMemoryTestThread::RobotMemoryTestThread()
 {
 }
 
-TEST(GTestTest, TestsWorking)
-{
-  ASSERT_EQ(1, 3-2);
-}
-
 void
 RobotMemoryTestThread::init()
 {
+  //prepare tests
+  logger->log_warn(name(), "Preparing tests");
+  test_env_ = new RobotMemoryTestEnvironment(robot_memory);
+  ::testing::AddGlobalTestEnvironment((testing::Environment*) test_env_);
+
   logger->log_warn(name(), "Starting tests");
   test_result_ = RUN_ALL_TESTS();
 }
diff --git a/src/plugins/robot-memory/test-plugin/robot_memory_test_thread.h b/src/plugins/robot-memory/test-plugin/robot_memory_test_thread.h
index d574bff..769d47f 100644
--- a/src/plugins/robot-memory/test-plugin/robot_memory_test_thread.h
+++ b/src/plugins/robot-memory/test-plugin/robot_memory_test_thread.h
@@ -29,19 +29,19 @@
 #include <aspect/logging.h>
 #include <aspect/blackboard.h>
 #include <aspect/configurable.h>
-
 #include <string>
 
+#include "plugins/robot-memory/aspect/robot_memory_aspect.h"
+#include "robot_memory_test.h"
 
-namespace fawkes {
-}
 
 class RobotMemoryTestThread 
 : public fawkes::Thread,
   public fawkes::BlockedTimingAspect,
   public fawkes::LoggingAspect,
   public fawkes::ConfigurableAspect,
-  public fawkes::BlackBoardAspect
+  public fawkes::BlackBoardAspect,
+  public fawkes::RobotMemoryAspect
 {
 
  public:
@@ -57,6 +57,8 @@ class RobotMemoryTestThread
  private:
   int test_result_;
 
+  //environment to make objects available for testing
+  RobotMemoryTestEnvironment* test_env_;
 };
 
 




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


More information about the fawkes-commits mailing list