Changes have been pushed for the repository "fawkesrobotics/fawkes".
Clone: https://github.com/fawkesrobotics/fawkes.git Gitweb: https://github.com/fawkesrobotics/fawkes The branch, common/gologpp has been updated to c85a7eb7404235b0327f893e631d3d93893b4587 (commit) via 4d107ad83c3644e5b8692633222b721b5047f8e3 (commit) from e1fba1cdb285bcb12e41c1ff6e529b6834f57575 (commit) https://github.com/fawkesrobotics/fawkes/tree/common/gologpp 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 4d107ad83c3644e5b8692633222b721b5047f8e3 Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> AuthorDate: Wed Oct 30 14:52:02 2019 +0100 Commit: Till Hofmann <hofm...@kbsg.rwth-aachen.de> CommitDate: Fri Nov 1 13:47:41 2019 +0100 gologpp: add action executor for Blackboard messages This action executor allows sending blackboard messages by executing a Golog++ action. In order to do this, you need to specify a message mapping for each action. The mapping must specify the interface_id, the interface_type, and the message_type that the action should be mapped to. Furthermore, the action parameters should be the same as the field names of the message. https://github.com/fawkesrobotics/fawkes/commit/4d107ad83 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit c85a7eb7404235b0327f893e631d3d93893b4587 Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> AuthorDate: Wed Oct 30 17:42:24 2019 +0100 Commit: Till Hofmann <hofm...@kbsg.rwth-aachen.de> CommitDate: Fri Nov 1 13:47:41 2019 +0100 gologpp: use Golog++ mapping for message sending Instead of specifying the mapping in our config, handle the mapping with Golog++ instead. Now, the message executor can only execute `send_message` actions and expects that the action has the parameters `interface_type`, `interface_id`, and `message_type`. Any additional parameters are passed to the message itself. https://github.com/fawkesrobotics/fawkes/commit/c85a7eb74 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *Summary* ----------------------------------------------------------- src/plugins/gologpp/Makefile | 3 +- src/plugins/gologpp/gologpp_fawkes_backend.cpp | 3 + src/plugins/gologpp/message_action_executor.cpp | 121 +++++++++++++++++++++ src/plugins/gologpp/message_action_executor.h | 57 ++++++++++ src/plugins/gologpp/utils.cpp | 51 +++++++++ .../{nao/naoqi_broker.cpp => gologpp/utils.h} | 24 ++-- 6 files changed, 249 insertions(+), 10 deletions(-) create mode 100644 src/plugins/gologpp/message_action_executor.cpp create mode 100644 src/plugins/gologpp/message_action_executor.h create mode 100644 src/plugins/gologpp/utils.cpp copy src/plugins/{nao/naoqi_broker.cpp => gologpp/utils.h} (68%) - *Diffs* ------------------------------------------------------------- - *commit* 4d107ad83c3644e5b8692633222b721b5047f8e3 - - - - - - - - - - Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> Date: Wed Oct 30 14:52:02 2019 +0100 Subject: gologpp: add action executor for Blackboard messages src/plugins/gologpp/Makefile | 3 +- src/plugins/gologpp/gologpp_fawkes_backend.cpp | 3 + src/plugins/gologpp/message_action_executor.cpp | 143 +++++++++++++++++++++ src/plugins/gologpp/message_action_executor.h | 67 ++++++++++ src/plugins/gologpp/utils.cpp | 51 ++++++++ .../{nao/naoqi_broker.cpp => gologpp/utils.h} | 24 ++-- 6 files changed, 281 insertions(+), 10 deletions(-) _Diff for modified files_: diff --git a/src/plugins/gologpp/Makefile b/src/plugins/gologpp/Makefile index 059143191..ab28553a3 100644 --- a/src/plugins/gologpp/Makefile +++ b/src/plugins/gologpp/Makefile @@ -19,7 +19,8 @@ LIBS_gologpp = fawkescore fawkesutils fawkesblackboard \ fawkesinterface SkillerInterface OBJS_gologpp = plugin.o execution_thread.o gologpp_fawkes_backend.o exog_manager.o \ action_executor.o skiller_action_executor.o \ - aspect/action_executor_dispatcher.o aspect/action_executor_dispatcher_inifin.o + aspect/action_executor_dispatcher.o aspect/action_executor_dispatcher_inifin.o \ + utils.o message_action_executor.o OBJS_all = $(OBJS_gologpp) PLUGINS_all = $(PLUGINDIR)/gologpp.so diff --git a/src/plugins/gologpp/gologpp_fawkes_backend.cpp b/src/plugins/gologpp/gologpp_fawkes_backend.cpp index 216947cea..d1c0b0959 100644 --- a/src/plugins/gologpp/gologpp_fawkes_backend.cpp +++ b/src/plugins/gologpp/gologpp_fawkes_backend.cpp @@ -21,6 +21,7 @@ #include "gologpp_fawkes_backend.h" +#include "message_action_executor.h" #include "skiller_action_executor.h" #include <golog++/model/activity.h> @@ -51,6 +52,8 @@ GologppFawkesBackend::GologppFawkesBackend(Configuration *config, { action_dispatcher_.register_executor( std::make_shared<SkillerActionExecutor>(logger, blackboard, config, cfg_prefix)); + action_dispatcher_.register_executor( + std::make_shared<BBMessageActionExecutor>(logger, blackboard, config, cfg_prefix)); } GologppFawkesBackend::~GologppFawkesBackend() - *commit* c85a7eb7404235b0327f893e631d3d93893b4587 - - - - - - - - - - Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> Date: Wed Oct 30 17:42:24 2019 +0100 Subject: gologpp: use Golog++ mapping for message sending src/plugins/gologpp/message_action_executor.cpp | 74 +++++++++---------------- src/plugins/gologpp/message_action_executor.h | 22 ++------ 2 files changed, 32 insertions(+), 64 deletions(-) _Diff for modified files_: diff --git a/src/plugins/gologpp/message_action_executor.cpp b/src/plugins/gologpp/message_action_executor.cpp index 5b3d19d6d..8da32af04 100644 --- a/src/plugins/gologpp/message_action_executor.cpp +++ b/src/plugins/gologpp/message_action_executor.cpp @@ -50,7 +50,6 @@ BBMessageActionExecutor::BBMessageActionExecutor(Logger * logger, const std::string &cfg_prefix) : ActionExecutor(logger), blackboard_(blackboard), config_(config), cfg_prefix_(cfg_prefix) { - initialize_message_mapping(); open_interfaces(); } @@ -63,73 +62,52 @@ BBMessageActionExecutor::~BBMessageActionExecutor() } void -BBMessageActionExecutor::initialize_message_mapping() -{ - message_mappings_.clear(); - std::string message_mapping_cfg_path = cfg_prefix_ + "/message-mapping/"; - auto cfg_iterator{config_->search(message_mapping_cfg_path)}; - while (cfg_iterator->next()) { - MessageMapping mapping; - mapping.action_name = - std::string(cfg_iterator->path()).substr(message_mapping_cfg_path.length()); - mapping.interface_id = config_->get_string(std::string(cfg_iterator->path()) + "/interface_id"); - mapping.interface_type = - config_->get_string(std::string(cfg_iterator->path()) + "/interface_type"); - mapping.message_type = config_->get_string(std::string(cfg_iterator->path()) + "/message_type"); - message_mappings_.push_back(mapping); - } -} - -void BBMessageActionExecutor::open_interfaces() { - for (auto &mapping : message_mappings_) { - if (mapping.interface) { - blackboard_->close(mapping.interface); - } - Interface *iface = - blackboard_->open_for_reading(mapping.interface_type.c_str(), mapping.interface_id.c_str()); - mapping.interface = iface; - } + return; } void BBMessageActionExecutor::close_interfaces() { - for (auto &mapping : message_mappings_) { - blackboard_->close(mapping.interface); + for (auto interface : open_interfaces_) { + blackboard_->close(interface.second); } } bool BBMessageActionExecutor::can_execute_activity(std::shared_ptr<gologpp::Activity> activity) const { - for (auto &mapping : message_mappings_) { - if (mapping.action_name == activity->mapped_name()) { - return true; - } - } - return false; + return activity->mapped_name() == "send_message"; } void BBMessageActionExecutor::start(std::shared_ptr<gologpp::Activity> activity) { - for (auto &mapping : message_mappings_) { - if (mapping.action_name == activity->mapped_name()) { - assert(mapping.interface); - auto msg = mapping.interface->create_message(mapping.message_type.c_str()); - for (auto field = msg->fields(); field != msg->fields_end(); field++) { - if (activity->target()->mapping().is_mapped(field.get_name())) { - auto value = activity->mapped_arg_value(field.get_name()); - value_to_field(value, &field); - } - } - mapping.interface->msgq_enqueue(msg); - activity->update(gologpp::Transition::Hook::FINISH); - return; + if (!can_execute_activity(activity)) { + throw Exception("Cannot execute activity '%s' with BBMessageActionExecutor", + activity->mapped_name().c_str()); + } + activity->update(gologpp::Transition::Hook::START); + std::string interface_type = activity->mapped_arg_value("interface_type"); + std::string interface_id = activity->mapped_arg_value("interface_id"); + std::string message_type = activity->mapped_arg_value("message_type"); + if (open_interfaces_.find(interface_id) == open_interfaces_.end()) { + open_interfaces_[interface_id] = + blackboard_->open_for_reading(interface_type.c_str(), interface_id.c_str()); + } + Interface *interface = open_interfaces_[interface_id]; + auto msg = interface->create_message(message_type.c_str()); + + for (auto field = msg->fields(); field != msg->fields_end(); field++) { + if (activity->target()->mapping().is_mapped(field.get_name())) { + auto value = activity->mapped_arg_value(field.get_name()); + value_to_field(value, &field); } } + interface->msgq_enqueue(msg); + activity->update(gologpp::Transition::Hook::FINISH); + return; } void diff --git a/src/plugins/gologpp/message_action_executor.h b/src/plugins/gologpp/message_action_executor.h index 937549cdf..f79c93849 100644 --- a/src/plugins/gologpp/message_action_executor.h +++ b/src/plugins/gologpp/message_action_executor.h @@ -24,7 +24,6 @@ #include <map> #include <string> -#include <vector> namespace fawkes { @@ -47,21 +46,12 @@ public: bool can_execute_activity(std::shared_ptr<gologpp::Activity> activity) const override; private: - struct MessageMapping - { - std::string action_name; - std::string interface_id; - std::string interface_type; - std::string message_type; - Interface * interface = nullptr; - }; - void initialize_message_mapping(); - void open_interfaces(); - void close_interfaces(); - BlackBoard * blackboard_; - Configuration * config_; - std::string cfg_prefix_; - std::vector<MessageMapping> message_mappings_; + void open_interfaces(); + void close_interfaces(); + BlackBoard * blackboard_; + Configuration * config_; + std::string cfg_prefix_; + std::map<std::string, Interface *> open_interfaces_; }; } // namespace gpp } // namespace fawkes _______________________________________________ fawkes-commits mailing list fawkes-commits@lists.kbsg.rwth-aachen.de https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits