Skip to content
Snippets Groups Projects

Fix/read variable size matrices and optionals

Merged Fabian Reister requested to merge fix/read-variable-size-matrices-and-optionals into master
5 files
+ 22
10
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -44,7 +44,7 @@ namespace armarx::aron::codegenerator::cpp::generator
"Eigen::Matrix<" + std::get<0>(ElementType2Cpp.at(n.getElementType())) + ", " + (n.getRows() == -1 ? "Eigen::Dynamic" : std::to_string(n.getRows())) + ", " + (n.getCols() == -1 ? "Eigen::Dynamic" : std::to_string(n.getCols())) + ">",
"Eigen::Matrix<" + std::get<0>(ElementType2Cpp.at(n.getElementType())) + ", " + (n.getRows() == -1 ? "Eigen::Dynamic" : std::to_string(n.getRows())) + ", " + (n.getCols() == -1 ? "Eigen::Dynamic" : std::to_string(n.getCols())) + ">",
simox::meta::get_type_name<data::dto::NDArray>(),
simox::meta::get_type_name<type::dto::Matrix>(), n), matrixType(n)
simox::meta::get_type_name<type::dto::Matrix>(), n)
{
}
@@ -101,14 +101,25 @@ namespace armarx::aron::codegenerator::cpp::generator
block_if_data->addLine("std::string " + type + ";");
block_if_data->addLine("std::vector<int> " + dims + ";");
block_if_data->addLine("std::vector<unsigned char> " + data + ";");
block_if_data->addLine("" + ARON_READER_ACCESSOR + ".readNDArray("+variantAccessor+", "+dims+", "+type+", "+data+"); // of " + cppAccessor);
if(matrixType.getRows() == Eigen::Dynamic or matrixType.getCols() == Eigen::Dynamic)
if((this->type.getRows() == -1 or this->type.getRows() == Eigen::Dynamic) and this->type.getCols() != -1)
{
block_if_data->addLine(cppAccessor + nextEl() + "resize(" + dims + ".at(0));");
}
if(this->type.getRows() != -1 and (this->type.getCols() == -1 or this->type.getCols() == Eigen::Dynamic))
{
block_if_data->addLine(cppAccessor + nextEl() + "resize(" + dims + ".at(1));");
}
if((this->type.getRows() == -1 or this->type.getRows() == Eigen::Dynamic) and (this->type.getCols() == -1 or this->type.getCols() == Eigen::Dynamic))
{
// TODO assert(aron_variant_kpImpedance_shape.size() == 2);
block_if_data->addLine(cppAccessor + nextEl() + "resize(" + dims + ".at(0), " + dims + ".at(1));");
}
block_if_data->addLine("assert(" + cppAccessor + nextEl() + "rows() == " + dims + ".at(0) && " + cppAccessor + nextEl() + "cols() == " + dims + ".at(1) && \"Dimensions of member '"+cppAccessor+"' do not match (simox::alg::to_string(dims, ',')). Got (" + cppAccessor + nextEl() + "rows(), " + cppAccessor + nextEl() + "cols()) instead.\");");
block_if_data->addLine("std::memcpy(reinterpret_cast<unsigned char*>(" + cppAccessor + nextEl() + "data()), "+data+".data(), "+data+".size());");
return resolveMaybeReadBlock(block_if_data, cppAccessor, variantAccessor);
}
Loading