From f546203781a209e57d1441b5d5facdee9caf90e3 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Fri, 6 May 2022 19:24:49 +0200 Subject: [PATCH] Drop trailing \0 characters in value returned by iCubModels::getModelsPath function and release 1.23.4 (#154) * Drop trailing \0 characters in value returned by iCubModels::getModelsPath function --- CMakeLists.txt | 4 ++-- cpp/src/iCubModels.cpp.in | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49bca5b..ce8536c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ -# Copyright: (C) 2017 Fondazione Istituto Italiano di Tecnologia +# Copyright: (C) 2022 Fondazione Istituto Italiano di Tecnologia # Authors: Silvio Traversaro # CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT cmake_minimum_required(VERSION 3.8) project(icub-models - VERSION 1.23.3) + VERSION 1.23.4) include(GNUInstallDirs) diff --git a/cpp/src/iCubModels.cpp.in b/cpp/src/iCubModels.cpp.in index 1820ec4..4e6d5b4 100644 --- a/cpp/src/iCubModels.cpp.in +++ b/cpp/src/iCubModels.cpp.in @@ -7,11 +7,18 @@ #include +#include + namespace iCubModels { std::string getModelsPath() { std::string retstr = "@ICUB_MODELS_MODELS_PATH@"; + // Sometimes the relocation of the C++ library in conda or similar systems is not working correctly + // and is leaving at the end of the retstr many \0 characters. To be sure not to return a faulty + // string, we remove all the trailing \0 + // See https://github.com/ami-iit/bipedal-locomotion-framework/pull/526 + retstr.erase(std::find(retstr.begin(), retstr.end(), '\0'), retstr.end()); return retstr; } @@ -30,7 +37,7 @@ std::string getModelFile(const std::string& modelName) return modelFile; } - modelFile = "@ICUB_MODELS_MODELS_PATH@/" + modelName + "/model.urdf"; + modelFile = getModelsPath() + "/" + modelName + "/model.urdf"; return modelFile; } } // namespace iCubModels