Changes have been pushed for the repository "fawkesrobotics/fawkes".
Clone: https://github.com/fawkesrobotics/fawkes.git Gitweb: https://github.com/fawkesrobotics/fawkes The branch, thofmann/mongocxx-v3 has been updated to c25d53ec6345451d084195dd654b36fd0636e042 (commit) via 22b1394b4db6d95a3192251e8c708b1fd4ce1db9 (commit) from bd1556b180248df32d954b59644b1fc354760282 (commit) https://github.com/fawkesrobotics/fawkes/tree/thofmann/mongocxx-v3 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 22b1394b4db6d95a3192251e8c708b1fd4ce1db9 Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> AuthorDate: Fri Apr 12 16:15:54 2019 +0200 Commit: Till Hofmann <hofm...@kbsg.rwth-aachen.de> CommitDate: Fri Apr 12 16:15:54 2019 +0200 stn-generator: adapt to mongocxx-v3 https://github.com/fawkesrobotics/fawkes/commit/22b1394b4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit c25d53ec6345451d084195dd654b36fd0636e042 Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> AuthorDate: Fri Apr 12 16:19:49 2019 +0200 Commit: Till Hofmann <hofm...@kbsg.rwth-aachen.de> CommitDate: Fri Apr 12 16:19:49 2019 +0200 buildkite: upgrade mongo-cxx-driver to v3 from COPR We cannot update the builder image because it will break building all other branches. Thus, upgrade the driver just before building. This can be removed again when we updated the builder image. https://github.com/fawkesrobotics/fawkes/commit/c25d53ec6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *Summary* ----------------------------------------------------------- .buildkite/pipeline.yml | 1 + src/plugins/stn-generator/stn-generator_thread.cpp | 45 +++++++++++----------- src/plugins/stn-generator/stn-generator_thread.h | 1 - src/plugins/stn-generator/stn.cpp | 41 +++++++++++--------- src/plugins/stn-generator/stn.h | 5 ++- 5 files changed, 49 insertions(+), 44 deletions(-) - *Diffs* ------------------------------------------------------------- - *commit* 22b1394b4db6d95a3192251e8c708b1fd4ce1db9 - - - - - - - - - - Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> Date: Fri Apr 12 16:15:54 2019 +0200 Subject: stn-generator: adapt to mongocxx-v3 src/plugins/stn-generator/stn-generator_thread.cpp | 45 +++++++++++----------- src/plugins/stn-generator/stn-generator_thread.h | 1 - src/plugins/stn-generator/stn.cpp | 41 +++++++++++--------- src/plugins/stn-generator/stn.h | 5 ++- 4 files changed, 48 insertions(+), 44 deletions(-) _Diff for modified files_: diff --git a/src/plugins/stn-generator/stn-generator_thread.cpp b/src/plugins/stn-generator/stn-generator_thread.cpp index 1935749be..5cf5dbad1 100644 --- a/src/plugins/stn-generator/stn-generator_thread.cpp +++ b/src/plugins/stn-generator/stn-generator_thread.cpp @@ -27,9 +27,12 @@ #include <fstream> #include <streambuf> #include <thread> +#include <mongocxx/client.hpp> +#include <bsoncxx/builder/basic/document.hpp> using namespace fawkes; -using namespace mongo; +using namespace mongocxx; +using namespace bsoncxx; /** @class StnGeneratorThread 'stn-generator_thread.h' * Generates an STN representation of a sequential task plan @@ -99,23 +102,23 @@ StnGeneratorThread::loop() pddl_problem.assign((std::istreambuf_iterator<char>(s)), std::istreambuf_iterator<char>()); stn_->read_initial_state(pddl_problem); - QResCursor cursor = robot_memory->query(fromjson("{plan:1}"), cfg_plan_collection_); - while (cursor->more()) { - BSONObj obj = cursor->next(); - std::vector<BSONElement> actions = obj.getField("actions").Array(); + auto cursor = robot_memory->query(from_json("{plan:1}"), cfg_plan_collection_); + for (auto doc : cursor) { + array::view actions = doc["actions"].get_array(); for (auto &a : actions) { - BSONObj o = a.Obj(); std::string args; bool first = true; - for (auto &arg : o.getField("args").Array()) { + array::view args_array = a["args"].get_array(); + for (auto &arg : args_array) { if (!first) { args += " "; } first = false; - args += arg.str(); + args += arg.get_utf8().value.to_string(); } - stn_->add_plan_action(o.getField("name").str(), args); - logger->log_debug(name(), "Added Plan action %s to STN", o.getField("name").str().c_str()); + std::string action_name = a["name"].get_utf8().value.to_string(); + stn_->add_plan_action(action_name, args); + logger->log_debug(name(), "Added Plan action %s to STN", action_name.c_str()); } } stn_->generate(); @@ -128,25 +131,23 @@ StnGeneratorThread::loop() } logger->log_info(name(), "STN Generation finished."); + using namespace bsoncxx::builder; if (cfg_publish_to_robot_memory_) { //TODO reset actions in robot-memory for (auto &action : stn_->get_bson()) { - BSONObjBuilder rm_action; - rm_action << "relation" - << "proposed-stn-action"; - rm_action.appendElements(action); - robot_memory->insert(rm_action.obj(), cfg_output_collection_); + basic::document rm_action; + rm_action.append(basic::kvp("relation", "proposed-stn-action")); + rm_action.append(bsoncxx::builder::concatenate(action.view())); + robot_memory->insert(rm_action.view(), cfg_output_collection_); } // ensure all actions are written to RM before acknowledment std::this_thread::sleep_for(std::chrono::milliseconds(500)); num_published_actions_ += stn_->get_bson().size(); - BSONObjBuilder rm_final; - rm_final << "relation" - << "stn-sync"; - rm_final << "state" - << "synced"; - rm_final << "count" << std::to_string(num_published_actions_); - robot_memory->insert(rm_final.obj(), cfg_output_collection_); + basic::document rm_final; + rm_final.append(basic::kvp("relation", "stn-sync")); + rm_final.append(basic::kvp("state", "synced")); + rm_final.append(basic::kvp("count", std::to_string(num_published_actions_))); + robot_memory->insert(rm_final.view(), cfg_output_collection_); } } diff --git a/src/plugins/stn-generator/stn-generator_thread.h b/src/plugins/stn-generator/stn-generator_thread.h index f9ed8179e..dcc7e2572 100644 --- a/src/plugins/stn-generator/stn-generator_thread.h +++ b/src/plugins/stn-generator/stn-generator_thread.h @@ -30,7 +30,6 @@ #include <blackboard/interface_listener.h> #include <core/threading/thread.h> #include <interfaces/PddlPlannerInterface.h> -#include <mongo/client/dbclient.h> #include <plugins/robot-memory/aspect/robot_memory_aspect.h> namespace fawkes { diff --git a/src/plugins/stn-generator/stn.cpp b/src/plugins/stn-generator/stn.cpp index 051b90914..bc492bbb7 100644 --- a/src/plugins/stn-generator/stn.cpp +++ b/src/plugins/stn-generator/stn.cpp @@ -27,6 +27,8 @@ #include <fstream> #include <iostream> +#include <bsoncxx/builder/basic/document.hpp> + namespace fawkes { namespace stn { @@ -356,28 +358,29 @@ Stn::drawGraph() /** Get a BSON representation of the STN. * @return A vector of BSON objects, each element is an action. */ -std::vector<mongo::BSONObj> +std::vector<bsoncxx::document::value> Stn::get_bson() { - std::vector<mongo::BSONObj> stn; + std::vector<bsoncxx::document::value> stn; for (auto &action : stn_actions_) { - mongo::BSONObjBuilder bson_action; - bson_action << "id" << static_cast<long long>(action.id()); - bson_action << "name" << action.name(); - bson_action << "duration" << static_cast<long long>(action.duration()); - mongo::BSONArrayBuilder cond_actions; - for (auto &cond : action.condActionIds()) { - cond_actions << static_cast<long long>(cond); - } - bson_action << "cond-actions" << cond_actions.arr(); - mongo::BSONArrayBuilder opts_arr; - std::stringstream opts_ss(action.opts()); - std::istream_iterator<std::string> end; - for (std::istream_iterator<std::string> it(opts_ss); it != end; it++) { - opts_arr << *it; - } - bson_action << "opts" << opts_arr.arr(); - stn.push_back(bson_action.obj()); + using namespace bsoncxx::builder; + basic::document bson_action; + bson_action.append(basic::kvp("id", static_cast<int64_t>(action.id()))); + bson_action.append(basic::kvp("name", action.name())); + bson_action.append(basic::kvp("duration", static_cast<int64_t>(action.duration()))); + bson_action.append(basic::kvp("cond-actions", [action](basic::sub_array cond_actions) { + for (auto &cond : action.condActionIds()) { + cond_actions.append(static_cast<int64_t>(cond)); + } + })); + bson_action.append(basic::kvp("opts", [action](basic::sub_array opts) { + std::stringstream opts_ss(action.opts()); + std::istream_iterator<std::string> end; + for (std::istream_iterator<std::string> it(opts_ss); it != end; it++) { + opts.append(*it); + } + })); + stn.push_back(bson_action.extract()); } return stn; } diff --git a/src/plugins/stn-generator/stn.h b/src/plugins/stn-generator/stn.h index 62b5eac3d..cff057546 100644 --- a/src/plugins/stn-generator/stn.h +++ b/src/plugins/stn-generator/stn.h @@ -27,7 +27,8 @@ #include <aspect/logging.h> #include <graphviz/gvc.h> -#include <mongo/client/dbclient.h> +#include <mongocxx/client.hpp> +#include <bsoncxx/document/value.hpp> #include <pddl_parser/pddl_ast.h> #include <algorithm> @@ -51,7 +52,7 @@ public: void set_pddl_domain(const std::string &pddl_domain_string); void generate(); void drawGraph(); - std::vector<mongo::BSONObj> get_bson(); + std::vector<bsoncxx::document::value> get_bson(); private: struct plan_action - *commit* c25d53ec6345451d084195dd654b36fd0636e042 - - - - - - - - - - Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> Date: Fri Apr 12 16:19:49 2019 +0200 Subject: buildkite: upgrade mongo-cxx-driver to v3 from COPR .buildkite/pipeline.yml | 1 + 1 file changed, 1 insertion(+) _Diff for modified files_: diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 899de22e5..43d05807a 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -33,6 +33,7 @@ steps: - label: ":fedora: Fedora" command: + - dnf -y copr enable thofmann/mongocxx-v3 && dnf -y --refresh upgrade mongo-cxx-driver\* - .buildkite/build - .buildkite/test - .buildkite/annotate _______________________________________________ fawkes-commits mailing list fawkes-commits@lists.kbsg.rwth-aachen.de https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits