From ff916e4568c67d81314ee9597e6d983ef23c019f Mon Sep 17 00:00:00 2001 From: Julian Tusch <urhrf@student.kit.edu> Date: Wed, 20 Nov 2024 16:58:57 +0100 Subject: [PATCH] update profile id logic --- .../core/executor/FluxioNativeExecutor.cpp | 13 ++++++++--- .../manager/SkillManagerComponentPlugin.cpp | 23 ++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/source/RobotAPI/libraries/skills/core/executor/FluxioNativeExecutor.cpp b/source/RobotAPI/libraries/skills/core/executor/FluxioNativeExecutor.cpp index b27913b12..e5e627709 100644 --- a/source/RobotAPI/libraries/skills/core/executor/FluxioNativeExecutor.cpp +++ b/source/RobotAPI/libraries/skills/core/executor/FluxioNativeExecutor.cpp @@ -13,6 +13,7 @@ #include "RobotAPI/libraries/skills/core/FluxioParameter.h" #include "RobotAPI/libraries/skills/core/SkillStatusUpdate.h" #include "RobotAPI/libraries/skills/core/executor/FluxioExecutor.h" +#include <RobotAPI/libraries/aron/converter/json/NLohmannJSONConverter.h> #include "../ProviderID.h" #include "../SkillExecutionRequest.h" @@ -54,6 +55,7 @@ namespace armarx::skills this->possibleInputs[this->fluxioSkill.id] = parameters; const auto& type = std::make_shared<armarx::aron::type::Object>(); + // fill in missing with default values for (const auto& [key, param] : this->fluxioSkill.parameters) { @@ -67,7 +69,9 @@ namespace armarx::skills if (fallBack == nullptr) { ARMARX_WARNING << "No fallback value found for parameter " << param.name; - continue; + ARMARX_WARNING << "Can't execute skill due to incomplete params."; + this->setStatus(skills::SkillStatus::Failed); + return; } this->possibleInputs[this->fluxioSkill.id]->addElement(key, fallBack); @@ -84,7 +88,7 @@ namespace armarx::skills { ARMARX_WARNING << "Parameter with ID " << key << " not found in skill " << this->fluxioSkill.id; - ARMARX_WARNING << "Aborting skill execution."; + ARMARX_WARNING << "Can't execute skill due to incomplete params."; this->setStatus(skills::SkillStatus::Failed); return; } @@ -102,7 +106,7 @@ namespace armarx::skills if (!isValide) { ARMARX_WARNING << "Parameters do not fullfill the type of the skill"; - ARMARX_WARNING << "Aborting skill execution."; + ARMARX_WARNING << "Can't execute skill due to incompatible params."; this->setStatus(skills::SkillStatus::Failed); return; } @@ -113,6 +117,9 @@ namespace armarx::skills req.executorName = executorName; this->executorName = executorName; + ARMARX_WARNING << "Executing skill with the following parameters: " + << aron::data::converter::AronNlohmannJSONConverter::ConvertToNlohmannJSON( + req.parameters); auto eid = executeSkillAsync(req); this->executionId = eid; diff --git a/source/RobotAPI/libraries/skills/manager/SkillManagerComponentPlugin.cpp b/source/RobotAPI/libraries/skills/manager/SkillManagerComponentPlugin.cpp index 7fd21169b..0bd71fab2 100644 --- a/source/RobotAPI/libraries/skills/manager/SkillManagerComponentPlugin.cpp +++ b/source/RobotAPI/libraries/skills/manager/SkillManagerComponentPlugin.cpp @@ -736,7 +736,7 @@ namespace armarx::plugins parameters = std::make_shared<aron::data::Dict>(); } - ARMARX_WARNING << "Executing skill with the following parameters: " + ARMARX_WARNING << "Initializing skill execution with the following parameter values (overrides): " << aron::data::converter::AronNlohmannJSONConverter::ConvertToNlohmannJSON( parameters); @@ -1556,8 +1556,24 @@ namespace armarx::plugins __LINE__)}; } - std::string id; - if (fluxioDC.profiles.find(profile.id) != fluxioDC.profiles.end()) + std::string id = profile.id; + + bool validId = false; + try + { + const auto& result = boost::uuids::string_generator()(id); + validId = result.version() != boost::uuids::uuid::version_unknown; + } + catch (...) + { + validId = false; + } + + if (!validId) + { + id = IceUtil::generateUUID(); + } + else if (fluxioDC.profiles.find(profile.id) != fluxioDC.profiles.end()) { ARMARX_INFO << "The id '" << profile.id << "' is already taken. A new uuid will be generated."; @@ -1571,6 +1587,7 @@ namespace armarx::plugins fluxioDC.profiles[id] = profile; // a copy is created when the profile is added to the map fluxioDC.profiles[id].id = id; // this copy can then be modified const auto& ret = fluxioDC.profiles[id]; + l.unlock(); return {ret}; -- GitLab