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 d08ddcdd5271f7ea692462522711841cf6ca256f (commit) via 55bcabed2dec2c073f34f7eb445e05a2c00d1742 (commit) via c7528c3032adb961f2714b0df4298a5bc3258189 (commit) via 8d18688c45ea10aa3338cafa6d4227c11b5b9d0d (commit) from 6eafa9c64e30efac5b8cfdf40f2ddc8bb583c548 (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 8d18688c45ea10aa3338cafa6d4227c11b5b9d0d Author: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> AuthorDate: Fri Oct 14 13:12:41 2016 +0200 Commit: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> CommitDate: Fri Oct 14 16:45:18 2016 +0200 pddl-robot-memory: changed delimiter to access subdocuments to '_' The previous '.' as well as other intuitive delimiters are not usable in ctemplate names. http://git.fawkesrobotics.org/fawkes.git/commit/8d18688 http://trac.fawkesrobotics.org/changeset/8d18688 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit c7528c3032adb961f2714b0df4298a5bc3258189 Author: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> AuthorDate: Fri Oct 14 13:40:23 2016 +0200 Commit: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> CommitDate: Fri Oct 14 16:45:22 2016 +0200 pddl-robot-memory: allow accessing arrays in templates http://git.fawkesrobotics.org/fawkes.git/commit/c7528c3 http://trac.fawkesrobotics.org/changeset/c7528c3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit 55bcabed2dec2c073f34f7eb445e05a2c00d1742 Author: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> AuthorDate: Fri Oct 14 16:26:49 2016 +0200 Commit: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> CommitDate: Fri Oct 14 16:45:26 2016 +0200 pddl-robot-memory: generate pddl on interface message http://git.fawkesrobotics.org/fawkes.git/commit/55bcabe http://trac.fawkesrobotics.org/changeset/55bcabe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit d08ddcdd5271f7ea692462522711841cf6ca256f Author: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> AuthorDate: Fri Oct 14 16:33:58 2016 +0200 Commit: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> CommitDate: Fri Oct 14 16:45:30 2016 +0200 pddl-robot-memory: config to generate pddl on init http://git.fawkesrobotics.org/fawkes.git/commit/d08ddcd http://trac.fawkesrobotics.org/changeset/d08ddcd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *Summary* ----------------------------------------------------------- src/plugins/pddl-robot-memory/Makefile | 5 +- .../interfaces/Makefile | 0 .../interfaces/PddlGenInterface.xml | 21 ++++++ .../pddl-robot-memory/pddl_robot_memory_thread.cpp | 68 ++++++++++++++++--- .../pddl-robot-memory/pddl_robot_memory_thread.h | 12 +++- 5 files changed, 91 insertions(+), 15 deletions(-) copy src/plugins/{robot-memory => pddl-robot-memory}/interfaces/Makefile (100%) create mode 100644 src/plugins/pddl-robot-memory/interfaces/PddlGenInterface.xml - *Diffs* ------------------------------------------------------------- - *commit* 8d18688c45ea10aa3338cafa6d4227c11b5b9d0d - - - - - - - - - - Author: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> Date: Fri Oct 14 13:12:41 2016 +0200 Subject: pddl-robot-memory: changed delimiter to access subdocuments to '_' .../pddl-robot-memory/pddl_robot_memory_thread.cpp | 2 +- 1 files changed, 1 insertions(+), 1 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 3b11cbe..fdd2560 100644 --- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp +++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp @@ -182,7 +182,7 @@ void PddlRobotMemoryThread::fill_dict_from_document(ctemplate::TemplateDictionar dict->SetValue(prefix + elem.fieldName(), std::to_string(elem.Long())); break; case mongo::Object: - fill_dict_from_document(dict, elem.Obj(), prefix + elem.fieldName() + "."); + fill_dict_from_document(dict, elem.Obj(), prefix + elem.fieldName() + "_"); break; case 7: //ObjectId dict->SetValue(prefix + elem.fieldName(), elem.OID().toString()); - *commit* c7528c3032adb961f2714b0df4298a5bc3258189 - - - - - - - - - - Author: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> Date: Fri Oct 14 13:40:23 2016 +0200 Subject: pddl-robot-memory: allow accessing arrays in templates .../pddl-robot-memory/pddl_robot_memory_thread.cpp | 23 ++++++++++++++----- 1 files changed, 17 insertions(+), 6 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 fdd2560..93499f1 100644 --- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp +++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp @@ -47,7 +47,8 @@ using namespace mongo; * * 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>> ) + * and arrays as follows: + * (e.g. <<position_translation_0>> for a document {position:{translation:[0,1,2], orientation:[0,1,2]}}) * * @author Frederik Zwilling */ @@ -160,7 +161,7 @@ PddlRobotMemoryThread::finalize() * @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) +void PddlRobotMemoryThread::fill_dict_from_document(ctemplate::TemplateDictionary *dict, BSONObj obj, std::string prefix) { for(BSONObjIterator it = obj.begin(); it.more();) { @@ -185,10 +186,20 @@ void PddlRobotMemoryThread::fill_dict_from_document(ctemplate::TemplateDictionar 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 - + dict->SetValue(prefix + elem.fieldName(), elem.OID().toString()); + break; + case mongo::Array: + { + // access array elements as if they were a subdocument with key-value pairs + // using the indices as keys + BSONObjBuilder b; + for(size_t i = 0; i < elem.Array().size(); i++) + { + b.append(elem.Array()[i]); + } + fill_dict_from_document(dict, b.obj(), prefix + elem.fieldName() + "_"); + break; + } default: dict->SetValue(prefix + elem.fieldName(), "INVALID_VALUE_TYPE"); } - *commit* 55bcabed2dec2c073f34f7eb445e05a2c00d1742 - - - - - - - - - - Author: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> Date: Fri Oct 14 16:26:49 2016 +0200 Subject: pddl-robot-memory: generate pddl on interface message src/plugins/pddl-robot-memory/Makefile | 5 ++- .../interfaces/Makefile | 0 .../interfaces/PddlGenInterface.xml | 21 +++++++++++ .../pddl-robot-memory/pddl_robot_memory_thread.cpp | 38 +++++++++++++++++-- .../pddl-robot-memory/pddl_robot_memory_thread.h | 12 +++++-- 5 files changed, 68 insertions(+), 8 deletions(-) _Diff for modified files_: diff --git a/src/plugins/pddl-robot-memory/Makefile b/src/plugins/pddl-robot-memory/Makefile index fcc15df..1cc05f9 100644 --- a/src/plugins/pddl-robot-memory/Makefile +++ b/src/plugins/pddl-robot-memory/Makefile @@ -19,8 +19,11 @@ include $(BASEDIR)/etc/buildsys/config.mk include $(BASEDIR)/src/plugins/mongodb/mongodb.mk include $(BASEDIR)/src/plugins/pddl-robot-memory/ctemplate.mk +PRESUBDIRS = interfaces + LIBS_pddl_robot_memory = m fawkescore fawkesutils fawkesaspects fawkesbaseapp \ - fawkesblackboard fawkesinterface fawkesrobotmemory + fawkesblackboard fawkesinterface fawkesrobotmemory \ + PddlGenInterface OBJS_pddl_robot_memory = pddl_robot_memory_plugin.o pddl_robot_memory_thread.o 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 93499f1..300c448 100644 --- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp +++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp @@ -55,7 +55,7 @@ using namespace mongo; PddlRobotMemoryThread::PddlRobotMemoryThread() : Thread("PddlRobotMemoryThread", Thread::OPMODE_WAITFORWAKEUP), - BlockedTimingAspect(BlockedTimingAspect::WAKEUP_HOOK_SKILL) + BlackBoardInterfaceListener("NavGraphGeneratorThread") { } @@ -69,6 +69,23 @@ PddlRobotMemoryThread::init() output_path = StringConversions::resolve_path("@BASEDIR@/src/agents/" + config->get_string("plugins/pddl-robot-memory/output-problem-description")); + //setup interface + gen_if = blackboard->open_for_writing<PddlGenInterface>(config->get_string("plugins/pddl-robot-memory/interface-name").c_str()); + gen_if->set_msg_id(0); + gen_if->set_final(false); + gen_if->write(); + + //setup interface listener + bbil_add_message_interface(gen_if); + blackboard->register_listener(this, BlackBoard::BBIL_FLAG_MESSAGES); +} + +/** + * Thread is only waked up if there is a new interface message to generate a pddl + */ +void +PddlRobotMemoryThread::loop() +{ //read input template of problem description std::string input; std::ifstream istream(input_path); @@ -143,16 +160,29 @@ PddlRobotMemoryThread::init() } logger->log_info(name(), "Generation of PDDL problem description finished"); + gen_if->set_final(true); + gen_if->write(); } void -PddlRobotMemoryThread::loop() +PddlRobotMemoryThread::finalize() { + blackboard->close(gen_if); } -void -PddlRobotMemoryThread::finalize() +bool +PddlRobotMemoryThread::bb_interface_message_received(Interface *interface, fawkes::Message *message) throw() { + if (message->is_of_type<PddlGenInterface::GenerateMessage>()) { + gen_if->set_msg_id(message->id()); + gen_if->set_final(false); + gen_if->write(); + wakeup(); //activates loop where the generation is done + } else { + logger->log_error(name(), "Received unknown message of type %s, ignoring", + message->type()); + } + return false; } /** 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 a04bc8a..6c17ee1 100644 --- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h +++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.h @@ -25,26 +25,27 @@ #define __PLUGINS_PDDL_ROBOT_MEMORYTHREAD_H_ #include <core/threading/thread.h> -#include <aspect/blocked_timing.h> #include <aspect/logging.h> #include <aspect/blackboard.h> #include <aspect/configurable.h> #include <plugins/robot-memory/aspect/robot_memory_aspect.h> +#include <blackboard/interface_listener.h> #include <string> #include <ctemplate/template.h> +#include "interfaces/PddlGenInterface.h" namespace fawkes { } class PddlRobotMemoryThread : public fawkes::Thread, - public fawkes::BlockedTimingAspect, public fawkes::LoggingAspect, public fawkes::ConfigurableAspect, public fawkes::BlackBoardAspect, - public fawkes::RobotMemoryAspect + public fawkes::RobotMemoryAspect, + public fawkes::BlackBoardInterfaceListener { public: @@ -58,12 +59,17 @@ class PddlRobotMemoryThread protected: virtual void run() { Thread::run(); } private: + fawkes::PddlGenInterface *gen_if; + std::string collection; std::string input_path; std::string output_path; void fill_dict_from_document(ctemplate::TemplateDictionary *dict, mongo::BSONObj obj, std::string prefix = ""); + void generate(); + virtual bool bb_interface_message_received(fawkes::Interface *interface, + fawkes::Message *message) throw(); }; - *commit* d08ddcdd5271f7ea692462522711841cf6ca256f - - - - - - - - - - Author: Frederik Zwilling <zwill...@kbsg.rwth-aachen.de> Date: Fri Oct 14 16:33:58 2016 +0200 Subject: pddl-robot-memory: config to generate pddl on init .../pddl-robot-memory/pddl_robot_memory_thread.cpp | 5 +++++ 1 files changed, 5 insertions(+), 0 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 300c448..d95248d 100644 --- a/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp +++ b/src/plugins/pddl-robot-memory/pddl_robot_memory_thread.cpp @@ -78,6 +78,11 @@ PddlRobotMemoryThread::init() //setup interface listener bbil_add_message_interface(gen_if); blackboard->register_listener(this, BlackBoard::BBIL_FLAG_MESSAGES); + + if(config->get_bool("plugins/pddl-robot-memory/generate-on-init")) + { + wakeup(); //activates loop where the generation is done + } } /** -- 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