From 6ac52aff956c5819732699d53278fb50ad533c5d Mon Sep 17 00:00:00 2001 From: Fabian Peller-Konrad <fabian.peller-konrad@kit.edu> Date: Thu, 21 Dec 2023 11:24:14 +0100 Subject: [PATCH] fix code generation for dynamic matrix types --- .../codewriter/cpp/generator/ndarray/Matrix.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp index 0fe08b1dc..404373a0a 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/ndarray/Matrix.cpp @@ -69,7 +69,11 @@ namespace armarx::aron::codegenerator::cpp::generator std::pair<std::vector<std::pair<std::string, std::string>>, bool> Matrix::getCtorInitializers(const std::string& name) const { - if (type.getDefaultValue() == aron::type::matrix::default_value::IDENTITY) + if (type.getCols() == -1 || type.getRows() == -1) + { + return {{}, false}; + } + else if (type.getDefaultValue() == aron::type::matrix::default_value::IDENTITY) { return {{{name, getInstantiatedCppTypename() + "::Identity()"}}, true}; } @@ -94,7 +98,12 @@ namespace armarx::aron::codegenerator::cpp::generator { CppBlockPtr block_if_data = std::make_shared<CppBlock>(); - if (type.getDefaultValue() == aron::type::matrix::default_value::IDENTITY) + if (type.getCols() == -1 || type.getRows() == -1) + { + block_if_data->addLine(cppAccessor + " = " + getInstantiatedCppTypename() + "();"); + } + + else if (type.getDefaultValue() == aron::type::matrix::default_value::IDENTITY) { block_if_data->addLine(cppAccessor + " = " + getInstantiatedCppTypename() + "::Identity();"); } -- GitLab