Skip to content

Commit

Permalink
Drop trailing \0 characters in value returned by iCubModels::getModel…
Browse files Browse the repository at this point in the history
…sPath function and release 1.23.4 (#154)

* Drop trailing \0 characters in value returned by iCubModels::getModelsPath function
  • Loading branch information
traversaro authored May 6, 2022
1 parent f9630fe commit f546203
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
9 changes: 8 additions & 1 deletion cpp/src/iCubModels.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@

#include <iCubModels/iCubModels.h>

#include <algorithm>

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;
}

Expand All @@ -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

0 comments on commit f546203

Please sign in to comment.