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 a0324301bccaee9167b79e57a481bc161f73ecd9 (commit) via 1e0f5c7b55de747e478c01f1ff808fb3c03122d3 (commit) from 311edfa9a308610443e6a67c206308f02fb23097 (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 1e0f5c7b55de747e478c01f1ff808fb3c03122d3 Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> AuthorDate: Wed Nov 13 15:59:39 2019 +0100 Commit: Till Hofmann <hofm...@kbsg.rwth-aachen.de> CommitDate: Wed Nov 13 15:59:39 2019 +0100 gologpp: also implement value-to-field conversion for lists When we get a list as input, recursively create and call a visitor for each value in the list. https://github.com/fawkesrobotics/fawkes/commit/1e0f5c7b5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit a0324301bccaee9167b79e57a481bc161f73ecd9 Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> AuthorDate: Wed Nov 13 16:01:42 2019 +0100 Commit: Till Hofmann <hofm...@kbsg.rwth-aachen.de> CommitDate: Wed Nov 13 16:01:42 2019 +0100 gologpp: also accept a double as value for a float interface field Golog++ always treats numbers as doubles, while interfaces also accept floats. Instead of throwing an exception, (implicitly) cast the double to a float. https://github.com/fawkesrobotics/fawkes/commit/a0324301b - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *Summary* ----------------------------------------------------------- src/plugins/gologpp/utils.cpp | 46 +++++++++++++++++++++++++------------------ src/plugins/gologpp/utils.h | 3 ++- 2 files changed, 29 insertions(+), 20 deletions(-) - *Diffs* ------------------------------------------------------------- - *commit* 1e0f5c7b55de747e478c01f1ff808fb3c03122d3 - - - - - - - - - - Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> Date: Wed Nov 13 15:59:39 2019 +0100 Subject: gologpp: also implement value-to-field conversion for lists src/plugins/gologpp/utils.cpp | 45 +++++++++++++++++++++++++------------------ src/plugins/gologpp/utils.h | 3 ++- 2 files changed, 28 insertions(+), 20 deletions(-) _Diff for modified files_: diff --git a/src/plugins/gologpp/utils.cpp b/src/plugins/gologpp/utils.cpp index 1407216f2..60cce9107 100644 --- a/src/plugins/gologpp/utils.cpp +++ b/src/plugins/gologpp/utils.cpp @@ -36,7 +36,8 @@ namespace gpp { /** Constructor. * @param field The field to set. */ -ValueToFieldVisitor::ValueToFieldVisitor(InterfaceFieldIterator *field) : field(field) +ValueToFieldVisitor::ValueToFieldVisitor(InterfaceFieldIterator *field, unsigned int index) +: field(field), index(index) { } @@ -47,11 +48,11 @@ void ValueToFieldVisitor::operator()(unsigned int v) { switch (field->get_type()) { - case IFT_INT32: field->set_int32(v); break; - case IFT_INT64: field->set_int64(v); break; - case IFT_UINT16: field->set_uint16(v); break; - case IFT_UINT32: field->set_uint32(v); break; - case IFT_UINT64: field->set_uint64(v); break; + case IFT_INT32: field->set_int32(v, index); break; + case IFT_INT64: field->set_int64(v, index); break; + case IFT_UINT16: field->set_uint16(v, index); break; + case IFT_UINT32: field->set_uint32(v, index); break; + case IFT_UINT64: field->set_uint64(v, index); break; default: throw Exception("Invalid cast from unsigned int to %s", field->get_typename()); } } @@ -63,8 +64,8 @@ void ValueToFieldVisitor::operator()(int v) { switch (field->get_type()) { - case IFT_INT32: field->set_int32(v); break; - case IFT_INT64: field->set_int64(v); break; + case IFT_INT32: field->set_int32(v, index); break; + case IFT_INT64: field->set_int64(v, index); break; default: throw Exception("Invalid cast from int to %s", field->get_typename()); } } @@ -76,9 +77,9 @@ void ValueToFieldVisitor::operator()(unsigned long v) { switch (field->get_type()) { - case IFT_INT64: field->set_int64(v); break; - case IFT_UINT32: field->set_uint32(v); break; - case IFT_UINT64: field->set_uint64(v); break; + case IFT_INT64: field->set_int64(v, index); break; + case IFT_UINT32: field->set_uint32(v, index); break; + case IFT_UINT64: field->set_uint64(v, index); break; default: throw Exception("Invalid cast from unsigned long to %s", field->get_typename()); } } @@ -90,8 +91,8 @@ void ValueToFieldVisitor::operator()(long v) { switch (field->get_type()) { - case IFT_UINT32: field->set_uint32(v); break; - case IFT_INT64: field->set_int64(v); break; + case IFT_UINT32: field->set_uint32(v, index); break; + case IFT_INT64: field->set_int64(v, index); break; default: throw Exception("Invalid cast from long to %s", field->get_typename()); } } @@ -103,7 +104,7 @@ void ValueToFieldVisitor::operator()(double v) { switch (field->get_type()) { - case IFT_DOUBLE: field->set_double(v); break; + case IFT_DOUBLE: field->set_double(v, index); break; default: throw Exception("Invalid cast from double to %s", field->get_typename()); } } @@ -115,7 +116,12 @@ void ValueToFieldVisitor::operator()(std::string v) { switch (field->get_type()) { - case IFT_STRING: field->set_string(v.c_str()); break; + case IFT_STRING: + if (index != 0) { + throw Exception("Invalid cast, string arrays are not supported"); + } + field->set_string(v.c_str()); + break; // TODO: check that the given string is a valid enum case IFT_ENUM: field->set_enum_string(v.c_str()); break; default: throw Exception("Invalid cast from string to %s", field->get_typename()); @@ -129,7 +135,7 @@ void ValueToFieldVisitor::operator()(bool v) { switch (field->get_type()) { - case IFT_BOOL: field->set_bool(v); + case IFT_BOOL: field->set_bool(v, index); default: throw Exception("Invalid cast from bool to %s", field->get_typename()); } } @@ -156,14 +162,15 @@ ValueToFieldVisitor::operator()(gologpp::CompoundType::Representation v) } } -/** Not implemented yet. +/** Convert the given list by calling a visitor recursively for each item of the list. * @param v The value to set the field to. */ void ValueToFieldVisitor::operator()(gologpp::ListType::Representation v) { - switch (field->get_type()) { - default: throw Exception("Invalid cast from list to %s", field->get_typename()); + for (size_t i = 0; i < v.size(); i++) { + ValueToFieldVisitor visitor(field, i); + boost::apply_visitor(visitor, v[i]->representation()); } } diff --git a/src/plugins/gologpp/utils.h b/src/plugins/gologpp/utils.h index 74e51429f..00833f0c1 100644 --- a/src/plugins/gologpp/utils.h +++ b/src/plugins/gologpp/utils.h @@ -36,7 +36,7 @@ namespace gpp { class ValueToFieldVisitor : public boost::static_visitor<> { public: - ValueToFieldVisitor(InterfaceFieldIterator *field); + ValueToFieldVisitor(InterfaceFieldIterator *field, unsigned int index = 0); void operator()(unsigned int v); void operator()(int v); void operator()(unsigned long v); @@ -50,6 +50,7 @@ public: private: InterfaceFieldIterator *field; + unsigned int index; }; void value_to_field(const gologpp::Value &value, InterfaceFieldIterator *field); - *commit* a0324301bccaee9167b79e57a481bc161f73ecd9 - - - - - - - - - - Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> Date: Wed Nov 13 16:01:42 2019 +0100 Subject: gologpp: also accept a double as value for a float interface field src/plugins/gologpp/utils.cpp | 1 + 1 file changed, 1 insertion(+) _Diff for modified files_: diff --git a/src/plugins/gologpp/utils.cpp b/src/plugins/gologpp/utils.cpp index 60cce9107..f9c465cb3 100644 --- a/src/plugins/gologpp/utils.cpp +++ b/src/plugins/gologpp/utils.cpp @@ -104,6 +104,7 @@ void ValueToFieldVisitor::operator()(double v) { switch (field->get_type()) { + case IFT_FLOAT: field->set_float(v, index); break; case IFT_DOUBLE: field->set_double(v, index); break; default: throw Exception("Invalid cast from double to %s", field->get_typename()); } _______________________________________________ fawkes-commits mailing list fawkes-commits@lists.kbsg.rwth-aachen.de https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits