diff --git a/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp b/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp index e323a2815b3838bb7252f44f58fd7c69c8a470ac..0996242a4b38a6473734bc493ea164a706765d83 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp @@ -1,4 +1,5 @@ #include "Segment.h" +#include <SimoxUtility/algorithm/string/string_tools.h> #include <ArmarXCore/core/application/properties/PluginAll.h> #include <ArmarXCore/core/exceptions/local/ExpressionException.h> @@ -83,14 +84,26 @@ namespace armarx::armem::server::robot_state::description const std::vector<std::string> packages = armarx::CMakePackageFinder::FindAllArmarXSourcePackages(); const std::string package = armarx::ArmarXDataPath::getProject(packages, robotFilename); - const std::string fixedRobotFilename = robotFilename.substr(package.size() + 1, -1); - ARMARX_INFO << "Robot description '" << VAROUT(fixedRobotFilename) << "' found in package " << package; + // make sure that the relative path is without the 'package/' prefix + const std::string robotFileRelPath = [&robotFilename, &package]()-> std::string { + + if(simox::alg::starts_with(robotFilename, package)) + { + // remove "package" + "/" + const std::string fixedRobotFilename = robotFilename.substr(package.size() + 1, -1); + return fixedRobotFilename; + } + + return robotFilename; + }(); + + ARMARX_INFO << "Robot description '" << VAROUT(robotFileRelPath) << "' found in package " << package; const robot::RobotDescription robotDescription { .name = kinematicUnit->getRobotName(), - .xml = {package, fixedRobotFilename} - }; // FIXME + .xml = {package, robotFileRelPath} + }; commitRobotDescription(robotDescription); }