From 96f3432a16c89cd9bc866a5777d268175568720a Mon Sep 17 00:00:00 2001 From: "fabian.peller-konrad@kit.edu" <fabian.peller-konrad@kit.edu> Date: Mon, 31 Aug 2020 17:02:14 +0200 Subject: [PATCH] updated aronGenerator executable and tested automatic aron cmake generator macro --- .../config/ArMemGlobalStorageApp.cfg | 6 +- .../AronArmemGenerator/CMakeLists.txt | 3 - .../applications/AronGenerator/CMakeLists.txt | 3 + .../cxxopts.hpp | 0 .../main.cpp | 21 ++- source/RobotAPI/applications/CMakeLists.txt | 2 +- .../ArMemLocalStorage/ArMemLocalStorage.cpp | 24 +-- .../ArMemLocalStorage/ArMemLocalStorage.h | 2 + .../libraries/aron/test/CMakeLists.txt | 9 +- .../aron/test/aron/HumanPose.aron.generated.h | 161 ++++++++++++++++++ .../RobotAPI/libraries/aron/test/aronTest.cpp | 2 + .../libraries/aron/test/generated/NaturalIK.h | 77 +++++---- 12 files changed, 250 insertions(+), 60 deletions(-) delete mode 100644 source/RobotAPI/applications/AronArmemGenerator/CMakeLists.txt create mode 100644 source/RobotAPI/applications/AronGenerator/CMakeLists.txt rename source/RobotAPI/applications/{AronArmemGenerator => AronGenerator}/cxxopts.hpp (100%) rename source/RobotAPI/applications/{AronArmemGenerator => AronGenerator}/main.cpp (88%) create mode 100644 source/RobotAPI/libraries/aron/test/aron/HumanPose.aron.generated.h diff --git a/scenarios/ArMemTest/config/ArMemGlobalStorageApp.cfg b/scenarios/ArMemTest/config/ArMemGlobalStorageApp.cfg index 732d15000..963d56b61 100644 --- a/scenarios/ArMemTest/config/ArMemGlobalStorageApp.cfg +++ b/scenarios/ArMemTest/config/ArMemGlobalStorageApp.cfg @@ -27,12 +27,12 @@ # ArmarX.ArMemGlobalStorage.EnableProfiling = false -# ArmarX.ArMemGlobalStorage.LocalMemoryHostnames: The hostnames of the local memories +# ArmarX.ArMemGlobalStorage.LocalMemoryHostnames: The hostnames of the local memories, comma separated # Attributes: -# - Default: Default value not mapped. +# - Default: "" # - Case sensitivity: yes # - Required: no -# ArmarX.ArMemGlobalStorage.LocalMemoryHostnames = Default value not mapped. +ArmarX.ArMemGlobalStorage.LocalMemoryHostnames = "i61nb072" # ArmarX.ArMemGlobalStorage.MinimumLoggingLevel: Local logging level only for this component diff --git a/source/RobotAPI/applications/AronArmemGenerator/CMakeLists.txt b/source/RobotAPI/applications/AronArmemGenerator/CMakeLists.txt deleted file mode 100644 index 1bc84c4a9..000000000 --- a/source/RobotAPI/applications/AronArmemGenerator/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -armarx_component_set_name("AronArmemGeneratorApp") -set(COMPONENT_LIBS aron armem) -armarx_add_component_executable(main.cpp) diff --git a/source/RobotAPI/applications/AronGenerator/CMakeLists.txt b/source/RobotAPI/applications/AronGenerator/CMakeLists.txt new file mode 100644 index 000000000..2840d4c3b --- /dev/null +++ b/source/RobotAPI/applications/AronGenerator/CMakeLists.txt @@ -0,0 +1,3 @@ +armarx_component_set_name("AronGeneratorApp") +set(COMPONENT_LIBS aron) +armarx_add_component_executable(main.cpp) diff --git a/source/RobotAPI/applications/AronArmemGenerator/cxxopts.hpp b/source/RobotAPI/applications/AronGenerator/cxxopts.hpp similarity index 100% rename from source/RobotAPI/applications/AronArmemGenerator/cxxopts.hpp rename to source/RobotAPI/applications/AronGenerator/cxxopts.hpp diff --git a/source/RobotAPI/applications/AronArmemGenerator/main.cpp b/source/RobotAPI/applications/AronGenerator/main.cpp similarity index 88% rename from source/RobotAPI/applications/AronArmemGenerator/main.cpp rename to source/RobotAPI/applications/AronGenerator/main.cpp index 48ae7dd4d..e235a0663 100644 --- a/source/RobotAPI/applications/AronArmemGenerator/main.cpp +++ b/source/RobotAPI/applications/AronGenerator/main.cpp @@ -29,7 +29,7 @@ #include <boost/algorithm/string.hpp> // CXXOPTS -#include <RobotAPI/applications/AronArmemGenerator/cxxopts.hpp> +#include <RobotAPI/applications/AronGenerator/cxxopts.hpp> // ArmarX Executable //#include <ArmarXCore/core/application/Application.h> @@ -76,7 +76,18 @@ int main(int argc, char* argv[]) if (verbose) { - std::cout << "Parse the XML file..."; + std::cout << "Welcome to the AronGenerator!" << std::endl; + std::cout << "Received the following parameters:" << std::endl; + std::cout << "\tFile: " << filename << std::endl; + std::cout << "\tOutput: " << output << std::endl; + std::cout << std::endl; + } + + std::cout << "Generating a new cpp file out of <" + filename + ">" << std::endl; + + if (verbose) + { + std::cout << "Parsing the XML file..."; } std::filesystem::path input_file(filename); @@ -85,7 +96,8 @@ int main(int argc, char* argv[]) std::cerr << "The file you passed has the wrong type." << std::endl; } - std::string new_name_with_extension = input_file.filename().replace_extension(".h").string(); + std::string new_name_with_extension = input_file.filename().replace_extension("").string(); + new_name_with_extension += ".aron.generated.h"; reader.parseFile(input_file); if (verbose) @@ -98,7 +110,7 @@ int main(int argc, char* argv[]) if (verbose) { - std::cout << "Run the type class generator..."; + std::cout << "Running the type class generator..."; } writer.generateTypeClasses(reader.getGenerateTypes()); @@ -176,6 +188,7 @@ int main(int argc, char* argv[]) } ofs.close(); + std::cout << "Finished generating <" + output_current_file + ">" << std::endl; } catch (const cxxopts::OptionException& e) { diff --git a/source/RobotAPI/applications/CMakeLists.txt b/source/RobotAPI/applications/CMakeLists.txt index 68dfd7829..1e3460c75 100644 --- a/source/RobotAPI/applications/CMakeLists.txt +++ b/source/RobotAPI/applications/CMakeLists.txt @@ -1,4 +1,4 @@ -add_subdirectory(AronArmemGenerator) +add_subdirectory(AronGenerator) add_subdirectory(WeissHapticUnit) add_subdirectory(RobotControlUI) add_subdirectory(RobotStateComponent) diff --git a/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.cpp b/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.cpp index fb1c918d4..4ca8e4d63 100644 --- a/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.cpp +++ b/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.cpp @@ -33,23 +33,23 @@ namespace armarx { armarx::PropertyDefinitionsPtr ArMemLocalStorage::createPropertyDefinitions() { - PropertyDefinitionsPtr defs{new ComponentPropertyDefinitions{getConfigIdentifier()}}; + PropertyDefinitionsPtr defs(new ComponentPropertyDefinitions(getConfigIdentifier(), false)); + defs->optional(hostname_to_use, "MockedHostname", "Use a hostname mock. Leave empty to use the real one."); defs->optional(maximum_segments, "MaximumNumberOfSegments", "Maximum number of segments (<0 means infinite)"); defs->optional(maximum_entries_per_segment, "MaximumEntriesPerSegment", "Maximum number of accepted datatypes per segment (<0 means infinite)"); defs->optional(maximum_entries_per_datatype, "MaximumEntriesPerDatatype", "Maximum number of accepted commits per datatype (<0 means infinite)"); - return defs; } std::string ArMemLocalStorage::getDefaultName() const { - std::string hostname = getMyHostname(); - return GenerateLocalMemoryObjectNameFromHostname(hostname); + return GenerateLocalMemoryObjectNameFromHostname(hostname_to_use); } ArMemLocalStorage::ArMemLocalStorage() : armarx::Component(), armarx::armem::ArMemBase(), + hostname_to_use(getMyHostname()), maximum_segments(-1), maximum_entries_per_segment(-1), maximum_entries_per_datatype(-1) @@ -144,8 +144,8 @@ namespace armarx void ArMemLocalStorage::checkStorageIntegrity() const { if (indexed_storage.size() != timestamped_storage.size() || - indexed_storage.size() != hashed_storage.size() || - timestamped_storage.size() != hashed_storage.size()) + indexed_storage.size() != hashed_storage.size() || + timestamped_storage.size() != hashed_storage.size()) { throw LocalException("The memory is in an invalid state. The storages have different sizes! Please Check!"); } @@ -164,27 +164,27 @@ namespace armarx } - ArMemCommitPtr ArMemLocalStorage::getLatestCommitFromSegment(const std::string& segment, const Ice::Current &) + ArMemCommitPtr ArMemLocalStorage::getLatestCommitFromSegment(const std::string& segment, const Ice::Current&) { - int index = indexed_storage[segment].size() -1; - if(index >= 0) + int index = indexed_storage[segment].size() - 1; + if (index >= 0) { return indexed_storage[segment][index]; } return nullptr; } - ArMemCommitPtr ArMemLocalStorage::getNextCommitFromSegmentForTimestamp(const std::string &, Ice::Long, const Ice::Current &) + ArMemCommitPtr ArMemLocalStorage::getNextCommitFromSegmentForTimestamp(const std::string&, Ice::Long, const Ice::Current&) { return nullptr; } - TimestampedArMemCommitList ArMemLocalStorage::getAllCommitsBetweenTimestampsFromSegment(const std::string &, Ice::Long, Ice::Long, const Ice::Current &) + TimestampedArMemCommitList ArMemLocalStorage::getAllCommitsBetweenTimestampsFromSegment(const std::string&, Ice::Long, Ice::Long, const Ice::Current&) { return {}; } - TimestampedArMemCommitList ArMemLocalStorage::getAllCommitsFromSegment(const std::string &, const Ice::Current &) + TimestampedArMemCommitList ArMemLocalStorage::getAllCommitsFromSegment(const std::string&, const Ice::Current&) { return {}; } diff --git a/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.h b/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.h index e0e277b28..bc228dedb 100644 --- a/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.h +++ b/source/RobotAPI/components/ArMemLocalStorage/ArMemLocalStorage.h @@ -81,6 +81,8 @@ namespace armarx std::map<std::string, TimestampedDataTypeStorage> timestamped_storage; std::map<std::string, HashedDataTypeStorage> hashed_storage; + std::string hostname_to_use; + long maximum_segments; long maximum_entries_per_segment; long maximum_entries_per_datatype; diff --git a/source/RobotAPI/libraries/aron/test/CMakeLists.txt b/source/RobotAPI/libraries/aron/test/CMakeLists.txt index b3bc0820d..831b2d9c9 100644 --- a/source/RobotAPI/libraries/aron/test/CMakeLists.txt +++ b/source/RobotAPI/libraries/aron/test/CMakeLists.txt @@ -1,5 +1,12 @@ +SET(TEST_NAME aronTest) # Libs required for the tests SET(LIBS ${LIBS} ArmarXCore aron) + +SET(ARON_XML_FILES + xmls/HumanPose.xml +) + +generateAronCppInterface() -armarx_add_test(aronTest aronTest.cpp "${LIBS}") +armarx_add_test(${TEST_NAME} aronTest.cpp "${LIBS}") diff --git a/source/RobotAPI/libraries/aron/test/aron/HumanPose.aron.generated.h b/source/RobotAPI/libraries/aron/test/aron/HumanPose.aron.generated.h new file mode 100644 index 000000000..b104597fd --- /dev/null +++ b/source/RobotAPI/libraries/aron/test/aron/HumanPose.aron.generated.h @@ -0,0 +1,161 @@ +/* + * This file is part of ArmarX. + * + * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), + * Karlsruhe Institute of Technology (KIT), all rights reserved. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + ************************************************************************* + * WARNING: This file is autogenerated. + * Original file: /home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/xmls/HumanPose.xml + * Timestamp of generation: Mon Aug 31 17:00:22 2020 + * Please do not edit since your changes may be overwritten on the next generation + * If you have any questions please contact: Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + ************************************************************************* + */ + + +#ifndef ARONTESTSEGMENT__NATURALIKRESULT__ARON_TYPE_DEFINITION_INCLUDE_GUARD +#define ARONTESTSEGMENT__NATURALIKRESULT__ARON_TYPE_DEFINITION_INCLUDE_GUARD + +#include <string> +#include <vector> +#include <map> +#include <Eigen/Core> +#include <RobotAPI/interface/aron.h> +#include <RobotAPI/libraries/aron/codegenerator/AronCppClass.h> +#include <RobotAPI/libraries/aron/io/classWriters/AronDataNavigatorWriter/AronDataNavigatorWriter.h> +#include <RobotAPI/libraries/aron/io/classReaders/AronDataNavigatorReader/AronDataNavigatorReader.h> + +namespace armarx +{ + class NaturalIKResult + : virtual public armarx::aron::codegeneration::AronCppClass + { + public: + std::vector<float> jointValues; + bool reached; + + public: + NaturalIKResult() + { + initialize(); + reset(); + } + + public: + /** + * @brief operator==() - This method checks whether all values equal another instance. + * @param i - The other instance + * @return - true, if all members are the same, false otherwise + */ + bool operator==(const armarx::NaturalIKResult& i) const + { + if ( not (jointValues == i.jointValues)) + return false; + if ( not (reached == i.reached)) + return false; + return true; + } + /** + * @brief reset() - This method resets all member variables to default. + * @return - nothing + */ + virtual void reset() override + { + jointValues.clear(); + reached = {}; + } + /** + * @brief initialize() - This method initializeses special base-class members. + * @return - nothing + */ + virtual void initialize() override + { + // setup aronType + std::map<std::string, armarx::aron::AronAbstractType::PointerType> aronTypeRoot_objectiteratorcontainer; + armarx::aron::AronFloatType::PointerType aronTypeRoot_jointValues_listtype = armarx::aron::AronFloatType::PointerType(new armarx::aron::AronFloatType()); + armarx::aron::AronListType::PointerType aronTypeRoot_jointValues = armarx::aron::AronListType::PointerType(new armarx::aron::AronListType(aronTypeRoot_jointValues_listtype)); + aronTypeRoot_objectiteratorcontainer["jointValues"] = aronTypeRoot_jointValues; + armarx::aron::AronBoolType::PointerType aronTypeRoot_reached = armarx::aron::AronBoolType::PointerType(new armarx::aron::AronBoolType()); + aronTypeRoot_objectiteratorcontainer["reached"] = aronTypeRoot_reached; + armarx::aron::AronObjectType::PointerType aronTypeRoot = armarx::aron::AronObjectType::PointerType(new armarx::aron::AronObjectType("armarx::NaturalIKResult", aronTypeRoot_objectiteratorcontainer)); + aronType = aronTypeRoot; + } + /** + * @brief write() - This method returns a new type from the member data types using a writer implementation. + * @param w - The writer implementation + * @return - the result of the writer implementation + */ + virtual void write(armarx::aron::io::AronWriter& w) const override + { + w.writeStartDict(); + w.writeKey("jointValues"); + w.writeStartList(); + for(unsigned int jointValues_listiterator = 0; jointValues_listiterator < jointValues.size(); ++jointValues_listiterator) + { + w.writeFloat(jointValues[jointValues_listiterator]); + } + w.writeEndList(); + w.writeKey("reached"); + w.writeBool(reached); + w.writeEndDict(); + } + /** + * @brief read() - This method sets the struct members to new values given in a reader implementation. + * @param r - The reader implementation + * @return - nothing + */ + virtual void read(armarx::aron::io::AronReader& r) override + { + reset(); + + r.readStartDict(); + r.readMember("jointValues"); + r.readStartList(); + while(!r.readEndList()) + { + float jointValues_listiterator; + jointValues_listiterator = r.readFloat(); + jointValues.push_back(jointValues_listiterator); + } + r.readMember("reached"); + reached = r.readBool(); + r.readEndDict(); + } + /** + * @brief specializedWrite() - This method returns a new type from the member data types using a writer implementation. + * @return - the result of the writer implementation + */ + armarx::aron::AronDataPtr toAron() const + { + armarx::aron::io::AronDataNavigatorWriter writer; + this->write(writer); + return writer.getResult(); + } + /** + * @brief specializedRead() - This method sets the struct members to new values given in a reader implementation. + * @return - nothing + */ + void fromAron(const armarx::aron::AronDataPtr& input) + { + armarx::aron::io::AronDataNavigatorReader reader(input); + this->read(reader); + } + }; // class NaturalIKResult +} // namespace armarx + +#endif // ARONTESTSEGMENT__NATURALIKRESULT__ARON_TYPE_DEFINITION_INCLUDE_GUARD diff --git a/source/RobotAPI/libraries/aron/test/aronTest.cpp b/source/RobotAPI/libraries/aron/test/aronTest.cpp index db0276168..8c7a28398 100644 --- a/source/RobotAPI/libraries/aron/test/aronTest.cpp +++ b/source/RobotAPI/libraries/aron/test/aronTest.cpp @@ -46,6 +46,8 @@ #include "generated/PrimitiveTest.h" #include "generated/ObjectTest.h" +#include "aron/humanPose.generated.aron.h" + #include <Eigen/Core> diff --git a/source/RobotAPI/libraries/aron/test/generated/NaturalIK.h b/source/RobotAPI/libraries/aron/test/generated/NaturalIK.h index 9298574ba..b92ab591f 100644 --- a/source/RobotAPI/libraries/aron/test/generated/NaturalIK.h +++ b/source/RobotAPI/libraries/aron/test/generated/NaturalIK.h @@ -1,30 +1,31 @@ -/* - * This file is part of ArmarX. - * - * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), - * Karlsruhe Institute of Technology (KIT), all rights reserved. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ArmarX is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - ************************************************************************* - * WARNING: This file is autogenerated. - * Original file: /home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/xmls/NaturalIK.xml - * Please do not edit since your changes may be overwritten on the next generation - * If you have any questions please contact: Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) - ************************************************************************* - */ +/* + * This file is part of ArmarX. + * + * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), + * Karlsruhe Institute of Technology (KIT), all rights reserved. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + ************************************************************************* + * WARNING: This file is autogenerated. + * Original file: /home/fabian/Software/ArmarX/RobotAPI/source/RobotAPI/libraries/aron/test/xmls/NaturalIK.xml + * Timestamp of generation: Mon Aug 31 14:07:08 2020 + * Please do not edit since your changes may be overwritten on the next generation + * If you have any questions please contact: Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu) + ************************************************************************* + */ #ifndef ARONTESTSEGMENT__NATURALIKRESULT__ARON_TYPE_DEFINITION_INCLUDE_GUARD @@ -47,14 +48,14 @@ namespace armarx public: std::vector<float> jointValues; bool reached; - + public: NaturalIKResult() { initialize(); reset(); } - + public: /** * @brief operator==() - This method checks whether all values equal another instance. @@ -63,10 +64,14 @@ namespace armarx */ bool operator==(const armarx::NaturalIKResult& i) const { - if ( not (jointValues == i.jointValues)) - return false; - if ( not (reached == i.reached)) - return false; + if (not(jointValues == i.jointValues)) + { + return false; + } + if (not(reached == i.reached)) + { + return false; + } return true; } /** @@ -104,7 +109,7 @@ namespace armarx w.writeStartDict(); w.writeKey("jointValues"); w.writeStartList(); - for(unsigned int jointValues_listiterator = 0; jointValues_listiterator < jointValues.size(); ++jointValues_listiterator) + for (unsigned int jointValues_listiterator = 0; jointValues_listiterator < jointValues.size(); ++jointValues_listiterator) { w.writeFloat(jointValues[jointValues_listiterator]); } @@ -121,11 +126,11 @@ namespace armarx virtual void read(armarx::aron::io::AronReader& r) override { reset(); - + r.readStartDict(); r.readMember("jointValues"); r.readStartList(); - while(!r.readEndList()) + while (!r.readEndList()) { float jointValues_listiterator; jointValues_listiterator = r.readFloat(); -- GitLab