From 1757e7c69b129579e5bb7fed2d320a6842709a32 Mon Sep 17 00:00:00 2001 From: Fabian Peller <fabian.peller-konrad@kit.edu> Date: Tue, 25 Apr 2023 08:35:31 +0200 Subject: [PATCH] added new aliases for vectors and matrices in aron --- .../aron/codegeneration/typereader/xml/Data.h | 91 ++++++++++++++----- 1 file changed, 68 insertions(+), 23 deletions(-) diff --git a/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Data.h b/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Data.h index 0d0b108f4..bc5574781 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Data.h +++ b/source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Data.h @@ -24,12 +24,13 @@ #pragma once // STD/STL -#include <memory> #include <map> +#include <memory> #include <optional> // ArmarX #include <SimoxUtility/xml.h> + #include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> /** @@ -116,36 +117,80 @@ namespace armarx::aron::typereader::xml }; // Replacements ({tagName, {replacementsTag, additionalAronDTOXMLIncludePackagePath}, deprecationwarning}) - const std::map<std::string, Replacement> REPLACEMENTS = - { - {"int", {"<int32 />", {}, "The <int />-tag is deprecated. Please use <int32 /> instead."}}, - {"long", {"<int64 />", {}, "The <long />-tag is deprecated. Please use <int64 /> instead."}}, - {"float", {"<float32 />", {}, "The <float />-tag is deprecated. Please use <float32 /> instead."}}, - {"double", {"<float64 />", {}, "The <double />-tag is deprecated. Please use <float64 /> instead."}}, - {"position", {"<matrix rows='3' cols='1' type='float32' />", {}, ""}}, - {"pose", {"<matrix rows='4' cols='4' type='float32' />", {}, ""}}, - {"orientation", {"<quaternion type='float32' />", {}, ""}}, + const std::map<std::string, Replacement> REPLACEMENTS = { + {"int", + {"<int32 />", {}, "The <int />-tag is deprecated. Please use <int32 /> instead."}}, + {"long", + {"<int64 />", {}, "The <long />-tag is deprecated. Please use <int64 /> instead."}}, + {"float", + {"<float32 />", + {}, + "The <float />-tag is deprecated. Please use <float32 /> instead."}}, + {"double", + {"<float64 />", + {}, + "The <double />-tag is deprecated. Please use <float64 /> instead."}}, + + // should that be deprecated? + {"position", {"<matrix rows='3' cols='1' type='float32' />", {}, ""}}, + {"pose", {"<matrix rows='4' cols='4' type='float32' />", {}, ""}}, + {"orientation", {"<quaternion type='float32' />", {}, ""}}, + + // values similar to eigen + {"quaternionf", {"<quaternion type='float32' />", {}, ""}}, + {"quaterniond", {"<quaternion type='float64' />", {}, ""}}, + {"vector2f", {"<matrix rows='2' cols='1' type='float32' />", {}, ""}}, + {"vector2d", {"<matrix rows='2' cols='1' type='float64' />", {}, ""}}, + {"vector3f", {"<matrix rows='3' cols='1' type='float32' />", {}, ""}}, + {"vector3d", {"<matrix rows='3' cols='1' type='float64' />", {}, ""}}, + {"vector4f", {"<matrix rows='4' cols='1' type='float32' />", {}, ""}}, + {"vector4d", {"<matrix rows='4' cols='1' type='float64' />", {}, ""}}, + {"matrix2f", {"<matrix rows='2' cols='2' type='float32' />", {}, ""}}, + {"matrix2d", {"<matrix rows='2' cols='2' type='float64' />", {}, ""}}, + {"matrix3f", {"<matrix rows='3' cols='3' type='float32' />", {}, ""}}, + {"matrix3d", {"<matrix rows='3' cols='3' type='float64' />", {}, ""}}, + {"matrix4f", {"<matrix rows='4' cols='4' type='float32' />", {}, ""}}, + {"matrix4d", {"<matrix rows='4' cols='4' type='float64' />", {}, ""}}, // You can also add replacements for arondtos here! // structure: {xml-identifier, {replacement, auto-include}, deprecationwarning} - {"datetime", {"<armarx::arondto::DateTime />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}, ""}}, - {"time", {"<armarx::arondto::DateTime />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}, ""}}, - {"duration", {"<armarx::arondto::Duration />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}, ""}}, - {"framedposition", {"<armarx::arondto::FramedPosition />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, ""}}, - {"framedorientation", {"<armarx::arondto::FramedOrientation />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, ""}}, - {"framedpose", {"<armarx::arondto::FramedPose />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, ""}} - }; - } - + {"datetime", + {"<armarx::arondto::DateTime />", + {"RobotAPI", "libraries/aron/common/aron/time.xml"}, + ""}}, + {"time", + {"<armarx::arondto::DateTime />", + {"RobotAPI", "libraries/aron/common/aron/time.xml"}, + ""}}, + {"duration", + {"<armarx::arondto::Duration />", + {"RobotAPI", "libraries/aron/common/aron/time.xml"}, + ""}}, + {"framedposition", + {"<armarx::arondto::FramedPosition />", + {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, + ""}}, + {"framedorientation", + {"<armarx::arondto::FramedOrientation />", + {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, + ""}}, + {"framedpose", + {"<armarx::arondto::FramedPose />", + {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, + ""}}}; + } // namespace constantes namespace util { - std::optional<RapidXmlReaderNode> GetFirstNodeWithTag(const RapidXmlReaderNode& node, const std::string& name); + std::optional<RapidXmlReaderNode> GetFirstNodeWithTag(const RapidXmlReaderNode& node, + const std::string& name); void EnforceAttribute(const RapidXmlReaderNode& node, const std::string& att); bool HasAttribute(const RapidXmlReaderNode& node, const std::string& att); std::string GetAttribute(const RapidXmlReaderNode& node, const std::string& att); - std::string GetAttributeWithDefault(const RapidXmlReaderNode& node, const std::string& att, const std::string& def); + std::string GetAttributeWithDefault(const RapidXmlReaderNode& node, + const std::string& att, + const std::string& def); bool AttributeIsTrue(const RapidXmlReaderNode& node, const std::string& att); bool HasTagName(const RapidXmlReaderNode& node, const std::string& name); @@ -158,5 +203,5 @@ namespace armarx::aron::typereader::xml void EnforceChildSize(const RapidXmlReaderNode& node, const size_t size); void EnforceChildSizeGreaterEqual(const RapidXmlReaderNode& node, const size_t size); void EnforceChildSizeGreater(const RapidXmlReaderNode& node, const size_t size); - } -} + } // namespace util +} // namespace armarx::aron::typereader::xml -- GitLab