Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop trailing \0 characters in value returned by iCubModels::getModelsPath function and release 1.23.4 #154

Merged
merged 4 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should modify also

    modelFile = "@ICUB_MODELS_MODELS_PATH@/" + modelName + "/model.urdf";
    return modelFile;
}

into

    modelFile = getModelsPath() + "/" + modelName + "/model.urdf";
    return modelFile;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ea88144 .

{
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