Skip to content
Snippets Groups Projects
Commit b32bd6bf authored by Moritz Gleissner's avatar Moritz Gleissner
Browse files

Merge branch 'fluxio/dev' into 145-fluxio-results-and-errors

parents 5a28d0f9 7bbc7d95
No related branches found
No related tags found
2 merge requests!452Resolve "Fluxio results and errors",!449Fluxio preliminary release
Showing
with 384 additions and 221 deletions
......@@ -99,12 +99,12 @@ module armarx
string hint;
};
exception FluxioException
{
string reason;
};
sequence<dto::FluxioIdentificator> FluxioIdentificatorList;
struct FluxioSkillStatusUpdate
{
......@@ -185,6 +185,7 @@ module armarx
string id;
string name;
string description;
armarx::core::time::dto::Duration timeout;
string lastChanged;
bool executable;
bool native;
......@@ -258,24 +259,23 @@ module armarx
bool
updateSkill(string userId, dto::FluxioSkill skill) throws dto::FluxioException; // updates an existing skill
// TODO: implement dry-run
void
removeSkill(string id); // removes a skill
bool
getSkillMutex(string skillId, string userId) throws dto::FluxioException; // request a mutex for a skill
void
deleteSkillMutex(string skillId, string userId) throws dto::FluxioException; // release a mutex for a skill
optional(5) dto::FluxioIdentificatorList
deleteSkill(string skillId, string userId, bool dryRun); // removes a skill
// TODO: implement dry-run
void
removeSkillParameter(string userId, string skillId, string parameterId); // removes a parameter from a skill
removeSkillParameter(string skillId, string parameterId, string userId); // removes a parameter from a skill
dto::FluxioProfileList
getProfileList() throws dto::FluxioException; // returns all profiles
optional(5) dto::FluxioProfile
optional(6) dto::FluxioProfile
getProfile(string id) throws dto::FluxioException; // returns a single profile
dto::FluxioProfile
......@@ -287,16 +287,16 @@ module armarx
dto::FluxioProviderList
getProviderList() throws dto::FluxioException; // returns all providers
optional(6) dto::FluxioProvider
optional(7) dto::FluxioProvider
getProvider(string id) throws dto::FluxioException; // returns a single provider
optional(7) dto::FluxioSkillList
optional(8) dto::FluxioSkillList
getSkillsOfProvider(string id) throws dto::FluxioException; // returns all skills of a provider
optional(8) dto::FluxioSkill
optional(9) dto::FluxioSkill
addSkillToProvider(string userId, string providerId, dto::FluxioSkill skill) throws dto::FluxioException; // adds a new skill to a provider
optional(9) dto::FluxioSkillStatusUpdateList
optional(10) dto::FluxioSkillStatusUpdateList
getFluxioSkillExecutionStatus(string executionId) throws dto::FluxioException; // returns the status of a fluxio execution
};
}
......
#include "FluxioEdge.h"
#include <memory>
#include <optional>
#include <ArmarXCore/core/logging/Logging.h>
......@@ -35,14 +36,14 @@ namespace armarx
}
std::optional<FluxioEdge>
FluxioEdge::FromIce(const manager::dto::FluxioEdge& i,
std::map<std::string, FluxioNode*>& nodesMap,
std::map<std::string, FluxioParameter>& parametersMap)
FluxioEdge::FromIce(
const manager::dto::FluxioEdge& i,
const std::map<const std::string, const std::unique_ptr<FluxioNode>>& nodesMap,
const std::map<std::string, FluxioParameter>& parametersMap)
{
skills::FluxioNode* fromNodePtr =
const auto& fromNodePtr =
FluxioNode::FromFluxioIdentificatorIce(i.fromNodeId, nodesMap);
skills::FluxioNode* toNodePtr =
FluxioNode::FromFluxioIdentificatorIce(i.toNodeId, nodesMap);
const auto& toNodePtr = FluxioNode::FromFluxioIdentificatorIce(i.toNodeId, nodesMap);
if (fromNodePtr == nullptr || toNodePtr == nullptr)
{
......@@ -50,25 +51,30 @@ namespace armarx
return std::nullopt;
}
skills::FluxioParameter* fromParameterPtr = nullptr;
skills::FluxioParameter* toParameterPtr = nullptr;
std::experimental::observer_ptr<const skills::FluxioParameter> fromParameterPtr =
nullptr;
std::experimental::observer_ptr<const skills::FluxioParameter> toParameterPtr = nullptr;
// Check if fromNode is a SubSkillNode
if (fromNodePtr->nodeType == FluxioNodeType::SUBSKILL)
{
const auto* subSkillNodePtr = dynamic_cast<FluxioSubSkillNode*>(fromNodePtr);
try
const auto& subSkillNodePtr = std::experimental::make_observer(
dynamic_cast<const FluxioSubSkillNode*>(fromNodePtr.get()));
if (subSkillNodePtr == nullptr)
{
auto& subSkillParams = subSkillNodePtr->skillPtr->parameters;
fromParameterPtr = FluxioParameter::FromFluxioIdentificatorIce(
i.fromParameterId, subSkillParams);
ARMARX_WARNING << "Failed to cast node to sub skill node";
return std::nullopt;
}
catch (...)
if (subSkillNodePtr->skillPtr == nullptr)
{
ARMARX_WARNING << "Failed to retrieve parameters of skill in subskill node";
ARMARX_WARNING << "SkillPtr for SubSkillNode is not set";
return std::nullopt;
}
const auto& subSkillParams = subSkillNodePtr->skillPtr->parameters;
fromParameterPtr =
FluxioParameter::FromFluxioIdentificatorIce(i.fromParameterId, subSkillParams);
}
else if (fromNodePtr->nodeType == FluxioNodeType::PARAMETER)
{
......@@ -77,7 +83,8 @@ namespace armarx
}
else if (fromNodePtr->nodeType == FluxioNodeType::CONTROL)
{
auto* controlNodePtr = dynamic_cast<FluxioControlNode*>(fromNodePtr);
const auto& controlNodePtr = std::experimental::make_observer(
dynamic_cast<const FluxioControlNode*>(fromNodePtr.get()));
if (controlNodePtr == nullptr)
{
ARMARX_WARNING << "Failed to cast node to control node";
......@@ -96,23 +103,28 @@ namespace armarx
// Check if toNode is a SubSkillNode
if (toNodePtr->nodeType == FluxioNodeType::SUBSKILL)
{
const auto* subSkillNodePtr = dynamic_cast<FluxioSubSkillNode*>(toNodePtr);
try
const auto& subSkillNodePtr = std::experimental::make_observer(
dynamic_cast<const FluxioSubSkillNode*>(toNodePtr.get()));
if (subSkillNodePtr == nullptr)
{
auto& subSkillParams = subSkillNodePtr->skillPtr->parameters;
toParameterPtr = FluxioParameter::FromFluxioIdentificatorIce(i.toParameterId,
subSkillParams);
ARMARX_WARNING << "Failed to cast node to sub skill node";
return std::nullopt;
}
catch (...)
if (subSkillNodePtr->skillPtr == nullptr)
{
ARMARX_WARNING << "Failed to retrieve parameters of skill in subskill node";
ARMARX_WARNING << "SkillPtr for SubSkillNode is not set";
return std::nullopt;
}
const auto& subSkillParams = subSkillNodePtr->skillPtr->parameters;
toParameterPtr =
FluxioParameter::FromFluxioIdentificatorIce(i.toParameterId, subSkillParams);
}
else if (toNodePtr->nodeType == FluxioNodeType::CONTROL)
{
auto* controlNodePtr = dynamic_cast<FluxioControlNode*>(toNodePtr);
const auto& controlNodePtr = std::experimental::make_observer(
dynamic_cast<const FluxioControlNode*>(toNodePtr.get()));
if (controlNodePtr == nullptr)
{
ARMARX_WARNING << "Failed to cast node to control node";
......@@ -139,14 +151,10 @@ namespace armarx
return std::nullopt;
}
FluxioEdge ret;
ret.fromNodePtr = fromNodePtr;
ret.fromParameterPtr = fromParameterPtr;
ret.toNodePtr = toNodePtr;
ret.toParameterPtr = toParameterPtr;
return ret;
return FluxioEdge{.fromNodePtr = fromNodePtr,
.fromParameterPtr = fromParameterPtr,
.toNodePtr = toNodePtr,
.toParameterPtr = toParameterPtr};
}
} // namespace skills
} // namespace armarx
#pragma once
#include <experimental/memory>
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
#include "FluxioNode.h"
......@@ -11,17 +13,17 @@ namespace armarx
{
struct FluxioEdge
{
FluxioNode* fromNodePtr;
FluxioParameter* fromParameterPtr;
FluxioNode* toNodePtr;
FluxioParameter* toParameterPtr;
std::experimental::observer_ptr<const FluxioNode> fromNodePtr;
std::experimental::observer_ptr<const FluxioParameter> fromParameterPtr;
std::experimental::observer_ptr<const FluxioNode> toNodePtr;
std::experimental::observer_ptr<const FluxioParameter> toParameterPtr;
std::optional<manager::dto::FluxioEdge> toManagerIce() const;
static std::optional<FluxioEdge>
FromIce(const manager::dto::FluxioEdge& i,
std::map<std::string, FluxioNode*>& nodesMap,
std::map<std::string, FluxioParameter>& parametersMap);
const std::map<const std::string, const std::unique_ptr<FluxioNode>>& nodesMap,
const std::map<std::string, FluxioParameter>& parametersMap);
};
} // namespace skills
} // namespace armarx
#include "FluxioNode.h"
#include <experimental/memory>
#include <ArmarXCore/core/logging/Logging.h>
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
......@@ -86,9 +88,10 @@ namespace armarx
return ret;
}
FluxioNode*
FluxioNode::FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioNode*>& nodesMap)
std::experimental::observer_ptr<const FluxioNode>
FluxioNode::FromFluxioIdentificatorIce(
const manager::dto::FluxioIdentificator& i,
const std::map<const std::string, const std::unique_ptr<FluxioNode>>& nodesMap)
{
const auto& nodeIt = nodesMap.find(i.id);
......@@ -98,7 +101,7 @@ namespace armarx
return nullptr;
}
return nodesMap[nodeIt->first];
return std::experimental::make_observer(nodeIt->second.get());
}
FluxioNode
......
#pragma once
#include <experimental/memory>
#include <optional>
#include <string>
......@@ -29,9 +30,9 @@ namespace armarx
virtual std::optional<manager::dto::FluxioNode> toManagerIce() const;
manager::dto::FluxioIdentificator toFluxioIdentificatorIce() const;
static FluxioNode*
FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioNode*>& nodesMap);
static std::experimental::observer_ptr<const FluxioNode> FromFluxioIdentificatorIce(
const manager::dto::FluxioIdentificator& i,
const std::map<const std::string, const std::unique_ptr<FluxioNode>>& nodesMap);
static FluxioNode FromIce(const manager::dto::FluxioNode& i);
};
......
#include "FluxioParameter.h"
#include <memory>
#include <ArmarXCore/core/logging/Logging.h>
#include "RobotAPI/libraries/skills/core/FluxioProfile.h"
......@@ -34,7 +36,7 @@ namespace armarx
continue;
}
ret_values.push_back(*v);
ret_values.push_back(v.value());
}
ret.values = ret_values;
......@@ -71,14 +73,14 @@ namespace armarx
continue;
}
values.push_back(*v);
values.push_back(v.value());
}
}
FluxioParameter*
std::experimental::observer_ptr<const FluxioParameter>
FluxioParameter::FromFluxioIdentificatorIce(
const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioParameter>& parametersMap)
const std::map<std::string, FluxioParameter>& parametersMap)
{
const auto& parameterIt = parametersMap.find(i.id);
......@@ -88,7 +90,7 @@ namespace armarx
return nullptr;
}
return &(parametersMap[parameterIt->first]);
return std::experimental::make_observer(&parameterIt->second);
}
FluxioParameter
......@@ -114,7 +116,7 @@ namespace armarx
continue;
}
ret.values.push_back(*v);
ret.values.push_back(v.value());
}
return ret;
......
#pragma once
#include <experimental/memory>
#include <list>
#include <string>
......@@ -26,9 +27,9 @@ namespace armarx
void updateFromIce(const manager::dto::FluxioParameter& i,
std::map<std::string, FluxioProfile>& profilesMap);
static FluxioParameter*
static std::experimental::observer_ptr<const FluxioParameter>
FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioParameter>& parametersMap);
const std::map<std::string, FluxioParameter>& parametersMap);
static FluxioParameter FromIce(const manager::dto::FluxioParameter& i,
std::map<std::string, FluxioProfile>& profilesMap);
};
......
......@@ -4,10 +4,10 @@
#include <ArmarXCore/core/logging/Logging.h>
#include "RobotAPI/libraries/skills/core/FluxioNode.h"
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
#include "FluxioParameter.h"
#include "RobotAPI/libraries/skills/core/FluxioNode.h"
namespace armarx
{
......@@ -23,7 +23,7 @@ namespace armarx
}
const auto& nt = FluxioNodeTypeToString(nodeType);
if(!nt.has_value())
if (!nt.has_value())
{
return std::nullopt;
}
......@@ -53,7 +53,7 @@ namespace armarx
ARMARX_WARNING << "Parameters id is dummy id in ParameterNode with id " << i.nodeId;
return std::nullopt;
}
skills::FluxioParameter* parameterPtr =
const auto& parameterPtr =
FluxioParameter::FromFluxioIdentificatorIce(i.parameterId, parametersMap);
if (parameterPtr == nullptr)
......
#pragma once
#include <experimental/memory>
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
#include "FluxioNode.h"
......@@ -11,7 +13,7 @@ namespace armarx
{
struct FluxioParameterNode : public FluxioNode
{
FluxioParameter* parameterPtr;
std::experimental::observer_ptr<const FluxioParameter> parameterPtr;
std::optional<manager::dto::FluxioNode> toManagerIce() const override;
......
#include "FluxioProfile.h"
#include <memory>
#include <ArmarXCore/core/logging/Logging.h>
......@@ -42,7 +43,7 @@ namespace armarx
return ret;
}
FluxioProfile*
std::experimental::observer_ptr<const FluxioProfile>
FluxioProfile::FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioProfile>& profilesMap)
{
......@@ -54,7 +55,7 @@ namespace armarx
return nullptr;
}
return &(profilesMap[profilesEntry->second.id]);
return std::experimental::make_observer(&(profilesMap[profilesEntry->second.id]));
}
FluxioProfile
......
#pragma once
#include <experimental/memory>
#include <string>
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
......@@ -13,12 +14,12 @@ namespace armarx
std::string id;
std::string name;
std::string description = "";
FluxioProfile* parentPtr = nullptr;
std::experimental::observer_ptr<const FluxioProfile> parentPtr = nullptr;
manager::dto::FluxioProfile toManagerIce() const;
manager::dto::FluxioIdentificator toFluxioIdentificatorIce() const;
static FluxioProfile*
static std::experimental::observer_ptr<const FluxioProfile>
FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioProfile>& profilesMap);
static FluxioProfile FromIce(const manager::dto::FluxioProfile& i,
......
#include "FluxioProvider.h"
#include <experimental/memory>
#include <memory>
#include <ArmarXCore/core/logging/Logging.h>
namespace armarx
......@@ -28,7 +31,7 @@ namespace armarx
return ret;
}
FluxioProvider*
std::experimental::observer_ptr<const FluxioProvider>
FluxioProvider::FromFluxioIdentificatorIce(
const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioProvider>& providersMap)
......@@ -41,7 +44,7 @@ namespace armarx
return nullptr;
}
return &(providersMap[providerIt->first]);
return std::experimental::make_observer(&(providersMap[providerIt->first]));
}
FluxioProvider
......
#pragma once
#include <experimental/memory>
#include <string>
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
......@@ -16,7 +17,7 @@ namespace armarx
manager::dto::FluxioProvider toManagerIce() const;
manager::dto::FluxioIdentificator toFluxioIdentificatorIce() const;
static FluxioProvider*
static std::experimental::observer_ptr<const FluxioProvider>
FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioProvider>& providersMap);
static FluxioProvider FromIce(const manager::dto::FluxioProvider& i);
......
#include "FluxioSkill.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <utility>
#include <ArmarXCore/core/logging/Logging.h>
#include <ArmarXCore/core/time/DateTime.h>
#include <ArmarXCore/core/time/Duration.h>
#include <ArmarXCore/core/time/ice_conversions.h>
#include "RobotAPI/libraries/skills/core/FluxioParameter.h"
#include "RobotAPI/libraries/skills/core/FluxioProvider.h"
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
#include "FluxioControlNode.h"
#include "FluxioEdge.h"
#include "FluxioNode.h"
#include "FluxioParameterNode.h"
#include "FluxioControlNode.h"
#include "FluxioSubSkillNode.h"
namespace armarx
......@@ -65,7 +72,7 @@ namespace armarx
continue;
}
ret_nodes.push_back(*node);
ret_nodes.push_back(node.value());
}
for (const auto& edge : edges)
......@@ -78,12 +85,14 @@ namespace armarx
continue;
}
ret_edges.push_back(*edgeDTO);
ret_edges.push_back(edgeDTO.value());
}
}
ret.nodes = ret_nodes;
ret.edges = ret_edges;
armarx::core::time::toIce(ret.timeout, timeout);
return ret;
}
......@@ -121,10 +130,12 @@ namespace armarx
name = i.name;
description = i.description;
armarx::core::time::fromIce(i.timeout, timeout);
lastChanged = armarx::DateTime::Now().toDateTimeString();
executable = i.executable;
skillProviderPtr =
const auto skillProviderPtr =
skills::FluxioProvider::FromFluxioIdentificatorIce(i.skillProviderId, providersMap);
this->skillProviderPtr = skillProviderPtr;
// parameters
// create a parameter dto map for convenience
......@@ -173,11 +184,11 @@ namespace armarx
nodes.clear(); // create all nodes anew
for (const manager::dto::FluxioNode& node : i.nodes)
{
FluxioNode* n = CreateNode(node, parameters, skillsMap, profilesMap);
auto n = CreateNode(node, parameters, skillsMap, profilesMap);
if (n != nullptr)
{
nodes[n->nodeId] = n;
nodes.emplace(n->nodeId, std::move(n));
}
}
}
......@@ -192,7 +203,7 @@ namespace armarx
if (e.has_value())
{
edges.push_back(*e);
edges.push_back(e.value());
}
else
{
......@@ -223,16 +234,27 @@ namespace armarx
std::list<std::string> subSkillNodeIds;
for (const auto& [nodeId, nodePtr] : nodes)
{
// TODO: check nodePtr for nullptr
if (nodePtr->nodeType != FluxioNodeType::SUBSKILL)
if (nodePtr == nullptr || nodePtr->nodeType != FluxioNodeType::SUBSKILL)
{
continue;
}
// get subskillnode from pointer // TODO: check for nullptr
auto* subSkillNode = dynamic_cast<FluxioSubSkillNode*>(nodePtr);
// get subskillnode from pointer
const auto& subSkillNodePtr = std::experimental::make_observer(
dynamic_cast<const FluxioSubSkillNode*>(nodePtr.get()));
if (subSkillNodePtr == nullptr)
{
ARMARX_WARNING << "Failed to cast node to sub skill node";
continue;
}
if (subSkillNode->skillPtr->id == skillId)
if (subSkillNodePtr->skillPtr == nullptr)
{
ARMARX_WARNING << "SkillPtr for SubSkillNode is not set";
continue;
}
if (subSkillNodePtr->skillPtr->id == skillId)
{
subSkillNodeIds.push_back(nodeId);
}
......@@ -263,7 +285,55 @@ namespace armarx
}
}
FluxioSkill*
void
FluxioSkill::removeSubSkillNodesAndEdges(const std::string& skillId)
{
std::vector<std::string> nodeIdsToDelete = {};
for (const auto& [nodeId, nodePtr] : nodes)
{
if (nodePtr == nullptr)
{
ARMARX_WARNING << "Unexpected nullptr!";
continue;
}
if (nodePtr->nodeType != FluxioNodeType::SUBSKILL)
{
continue;
}
const auto& subSkillNodePtr = std::experimental::make_observer(
dynamic_cast<const FluxioSubSkillNode*>(nodePtr.get()));
if (subSkillNodePtr == nullptr)
{
ARMARX_WARNING << "Failed to cast node to sub skill node";
continue;
}
if (subSkillNodePtr->skillPtr == nullptr)
{
ARMARX_WARNING << "SkillPtr for SubSkillNode is not set";
continue;
}
if (subSkillNodePtr->skillPtr->id == skillId)
{
edges.remove_if(
[nodeId](const FluxioEdge& e) {
return e.fromNodePtr->nodeId == nodeId || e.toNodePtr->nodeId == nodeId;
});
nodeIdsToDelete.push_back(nodeId);
}
}
for (const auto& id : nodeIdsToDelete)
{
nodes.erase(id);
}
}
std::experimental::observer_ptr<const FluxioSkill>
FluxioSkill::FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioSkill>& skillsMap)
{
......@@ -275,10 +345,10 @@ namespace armarx
return nullptr;
}
return &(skillsMap[skillIt->first]);
return std::experimental::make_observer(&skillsMap[skillIt->first]);
}
std::optional<FluxioSkill>
std::unique_ptr<FluxioSkill>
FluxioSkill::FromIce(const manager::dto::FluxioSkill& i,
std::map<std::string, FluxioProvider>& providersMap,
std::map<std::string, FluxioProfile>& profilesMap,
......@@ -289,7 +359,7 @@ namespace armarx
if (providerPtr == nullptr)
{
ARMARX_WARNING << "Provider for Skill with id " << i.id << " not found";
return std::nullopt;
return nullptr;
}
FluxioSkill ret;
......@@ -297,10 +367,14 @@ namespace armarx
ret.id = i.id;
ret.name = i.name;
ret.description = i.description;
armarx::core::time::fromIce(i.timeout, ret.timeout);
ret.lastChanged = i.lastChanged;
ret.executable = i.executable;
ret.native = i.native;
ret.skillProviderPtr = providerPtr;
ret.parameters = std::map<std::string, FluxioParameter>();
ret.nodes = std::map<const std::string, const std::unique_ptr<FluxioNode>>();
ret.edges = std::list<FluxioEdge>();
for (const manager::dto::FluxioParameter& parameter : i.parameters)
{
......@@ -308,22 +382,20 @@ namespace armarx
ret.parameters[param.id] = param;
}
ret.nodes = {};
ret.edges = {};
if (i.native)
{
return ret; // return early (native skills have no nodes and edges)
return std::make_unique<FluxioSkill>(std::move(ret));
}
if (i.nodesHasValue)
{
for (const manager::dto::FluxioNode& node : i.nodes)
{
FluxioNode* n = CreateNode(node, ret.parameters, skillsMap, profilesMap);
auto n = CreateNode(node, ret.parameters, skillsMap, profilesMap);
if (n != nullptr)
{
ret.nodes[n->nodeId] = n;
ret.nodes.emplace(n->nodeId, std::move(n));
}
}
}
......@@ -336,21 +408,21 @@ namespace armarx
if (e.has_value())
{
ret.edges.push_back(*e);
ret.edges.push_back(e.value());
}
}
}
return ret;
return std::make_unique<FluxioSkill>(std::move(ret));
}
skills::FluxioNode*
std::unique_ptr<FluxioNode>
FluxioSkill::CreateNode(const manager::dto::FluxioNode& i,
std::map<std::string, FluxioParameter>& parametersMap,
std::map<std::string, FluxioSkill>& skillsMap,
std::map<std::string, FluxioProfile>& profilesMap)
{
FluxioNodeType nodeType = FluxioNodeTypeFromString(i.nodeType);
FluxioNodeType nodeType = FluxioNodeTypeFromString(i.nodeType);
if (nodeType == FluxioNodeType::PARAMETER)
{
......@@ -358,7 +430,7 @@ namespace armarx
if (n.has_value())
{
return new FluxioParameterNode(*n);
return std::make_unique<FluxioParameterNode>(n.value());
}
ARMARX_WARNING << "ParameterNode with id " << i.nodeId << " could not be converted";
......@@ -369,7 +441,7 @@ namespace armarx
if (n.has_value())
{
return new FluxioSubSkillNode(*n);
return std::make_unique<FluxioSubSkillNode>(n.value());
}
ARMARX_WARNING << "SubSkillNode with id " << i.nodeId << " could not be converted";
}
......@@ -379,7 +451,7 @@ namespace armarx
if (n.has_value())
{
return new FluxioControlNode(*n);
return std::make_unique<FluxioControlNode>(n.value());
}
ARMARX_WARNING << "controlNode with id " << i.nodeId << " could not be converted";
}
......
#pragma once
#include <list>
#include <memory>
#include <optional>
#include <string>
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
#include <ArmarXCore/core/time/Duration.h>
#include "FluxioEdge.h"
#include "FluxioNode.h"
......@@ -19,15 +21,24 @@ namespace armarx
{
std::string id;
std::string name;
std::string description = "";
std::string description;
/**
* @brief How long (in ms) to wait for the skill to finish execution before timing out. A negative value indicates no timeout (default).
*/
armarx::Duration timeout = armarx::Duration::MilliSeconds(-1);
std::string lastChanged;
bool executable =
false; // TODO: change from explicit to implicit storing of executable state
bool native = true;
FluxioProvider* skillProviderPtr;
std::map<std::string, FluxioParameter> parameters = {};
std::map<std::string, FluxioNode*> nodes = {};
std::list<FluxioEdge> edges = {};
std::experimental::observer_ptr<const FluxioProvider> skillProviderPtr;
std::map<std::string, FluxioParameter> parameters;
std::map<const std::string, const std::unique_ptr<FluxioNode>> nodes;
std::list<FluxioEdge> edges;
FluxioSkill(const FluxioSkill&) = delete;
FluxioSkill& operator=(const FluxioSkill&) = delete;
FluxioSkill(FluxioSkill&&) = default;
FluxioSkill() = default;
std::optional<manager::dto::FluxioSkill> toManagerIce() const;
manager::dto::FluxioIdentificator toFluxioIdentificatorIce() const;
......@@ -36,16 +47,17 @@ namespace armarx
std::map<std::string, FluxioProfile>& profilesMap,
std::map<std::string, FluxioSkill>& skillsMap);
void deleteParameter(const std::string& parameterId, const std::string& skillId);
void removeSubSkillNodesAndEdges(const std::string& skillId);
static FluxioSkill*
static std::experimental::observer_ptr<const FluxioSkill>
FromFluxioIdentificatorIce(const manager::dto::FluxioIdentificator& i,
std::map<std::string, FluxioSkill>& skillsMap);
static std::optional<FluxioSkill>
static std::unique_ptr<FluxioSkill>
FromIce(const manager::dto::FluxioSkill& i,
std::map<std::string, FluxioProvider>& providersMap,
std::map<std::string, FluxioProfile>& profilesMap,
std::map<std::string, FluxioSkill>& skillsMap);
static skills::FluxioNode*
static std::unique_ptr<skills::FluxioNode>
CreateNode(const manager::dto::FluxioNode& i,
std::map<std::string, FluxioParameter>& parametersMap,
std::map<std::string, FluxioSkill>& skillsMap,
......
......@@ -2,10 +2,10 @@
#include <ArmarXCore/core/logging/Logging.h>
#include "RobotAPI/libraries/skills/core/FluxioNode.h"
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
#include "FluxioSkill.h"
#include "RobotAPI/libraries/skills/core/FluxioNode.h"
namespace armarx
{
......@@ -52,8 +52,7 @@ namespace armarx
ARMARX_WARNING << "Skills id is dummy id in SubSkillNode with id " << i.nodeId;
return std::nullopt;
}
skills::FluxioSkill* skillPtr =
FluxioSkill::FromFluxioIdentificatorIce(i.skillId, skillsMap);
const auto& skillPtr = FluxioSkill::FromFluxioIdentificatorIce(i.skillId, skillsMap);
if (skillPtr == nullptr)
{
......
#pragma once
#include <experimental/memory>
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
#include "FluxioNode.h"
......@@ -11,7 +13,7 @@ namespace armarx
{
struct FluxioSubSkillNode : public FluxioNode
{
FluxioSkill* skillPtr;
std::experimental::observer_ptr<const FluxioSkill> skillPtr;
std::optional<manager::dto::FluxioNode> toManagerIce() const override;
......
......@@ -31,7 +31,7 @@ namespace armarx
FluxioValue::FromIce(const manager::dto::FluxioValue& i,
std::map<std::string, FluxioProfile>& profilesMap)
{
FluxioProfile* profilePtr =
auto profilePtr =
FluxioProfile::FromFluxioIdentificatorIce(i.profileId, profilesMap);
if (profilePtr == nullptr)
......
#pragma once
#include <experimental/memory>
#include <string>
#include <optional>
......@@ -13,7 +14,7 @@ namespace armarx
{
struct FluxioValue
{
FluxioProfile* profilePtr;
std::experimental::observer_ptr<const FluxioProfile> profilePtr;
std::string content;
std::optional<manager::dto::FluxioValue> toManagerIce() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment