Skip to content
Snippets Groups Projects
Commit 94b541a4 authored by Firat Yusuf Duran's avatar Firat Yusuf Duran :moyai:
Browse files

add loadProfiles to skillmemory

parent ccdb4eb7
No related branches found
No related tags found
2 merge requests!458Fluxio/dev get types,!449Fluxio preliminary release
Pipeline #21134 failed
...@@ -256,4 +256,9 @@ namespace armarx ...@@ -256,4 +256,9 @@ namespace armarx
{ {
profileCoreSegment.addProfile(profile); profileCoreSegment.addProfile(profile);
} }
std::optional<std::vector<skills::manager::arondto::FluxioProfile>> SkillsMemory::loadProfiles()
{
return profileCoreSegment.getProfiles();
}
} // namespace armarx } // namespace armarx
...@@ -118,6 +118,7 @@ namespace armarx ...@@ -118,6 +118,7 @@ namespace armarx
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadCompositeSkillsOfProvider(const std::string& providerId) override; std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadCompositeSkillsOfProvider(const std::string& providerId) override;
void addProfile(const skills::manager::arondto::FluxioProfile& profile) override; void addProfile(const skills::manager::arondto::FluxioProfile& profile) override;
std::optional<std::vector<skills::manager::arondto::FluxioProfile>> loadProfiles() override;
protected: protected:
/// @see armarx::ManagedIceObject::onInitComponent() /// @see armarx::ManagedIceObject::onInitComponent()
......
#include "ProfileLibrarySegment.h" #include "ProfileLibrarySegment.h"
#include <vector>
#include <SimoxUtility/algorithm/string.h> #include <SimoxUtility/algorithm/string.h>
#include <ArmarXCore/core/time/ice_conversions.h> #include <ArmarXCore/core/time/ice_conversions.h>
#include "RobotAPI/libraries/armem/client/query/Builder.h"
#include "RobotAPI/libraries/armem/core/Commit.h" #include "RobotAPI/libraries/armem/core/Commit.h"
#include "RobotAPI/libraries/armem/core/MemoryID.h" #include "RobotAPI/libraries/armem/core/MemoryID.h"
#include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h> #include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h>
...@@ -52,4 +54,31 @@ namespace armarx::skills::segment ...@@ -52,4 +54,31 @@ namespace armarx::skills::segment
// Commit data to memory and notify // Commit data to memory and notify
iceMemory.commit(commit); iceMemory.commit(commit);
} }
std::optional<std::vector<skills::manager::arondto::FluxioProfile>> ProfileLibraryCoreSegment::getProfiles() const {
std::vector<skills::manager::arondto::FluxioProfile> ret;
armarx::armem::client::query::Builder qb;
qb.allLatestInCoreSegment(id());
armem::client::QueryResult qresult = iceMemory.query(qb.buildQueryInput());
if (!qresult.success)
{
ARMARX_WARNING << "Query failed: " << qresult.errorMessage;
return std::nullopt;
}
const armem::wm::Memory& data = qresult.memory;
data.forEachInstance(
[&ret](const armem::wm::EntityInstance& instance)
{
auto profile = instance.dataAs<skills::manager::arondto::FluxioProfile>();
if (profile.deleted)
{
return;
}
ret.push_back(profile);
});
return ret;
}
} // namespace armarx::skills::segment } // namespace armarx::skills::segment
#pragma once #pragma once
// Base Class // Base Class
#include <optional>
#include <vector>
#include <RobotAPI/libraries/armem/server/segment/SpecializedSegment.h> #include <RobotAPI/libraries/armem/server/segment/SpecializedSegment.h>
// ArmarX // ArmarX
...@@ -29,5 +31,6 @@ namespace armarx::skills::segment ...@@ -29,5 +31,6 @@ namespace armarx::skills::segment
void init(); void init();
void addProfile(const skills::manager::arondto::FluxioProfile& profile); void addProfile(const skills::manager::arondto::FluxioProfile& profile);
std::optional<std::vector<skills::manager::arondto::FluxioProfile>> getProfiles() const;
}; };
} // namespace armarx::skills::segment } // namespace armarx::skills::segment
...@@ -771,4 +771,11 @@ namespace armarx ...@@ -771,4 +771,11 @@ namespace armarx
{ {
// Implemented in derived class // Implemented in derived class
} }
std::optional<std::vector<skills::manager::arondto::FluxioProfile>>
SkillManagerComponentPluginUser::loadProfiles()
{
// Implemented in derived class
return {};
}
} // namespace armarx } // namespace armarx
...@@ -156,6 +156,7 @@ namespace armarx ...@@ -156,6 +156,7 @@ namespace armarx
virtual std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadCompositeSkillsOfProvider(const std::string& providerId); virtual std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadCompositeSkillsOfProvider(const std::string& providerId);
virtual void addProfile(const skills::manager::arondto::FluxioProfile& profile); virtual void addProfile(const skills::manager::arondto::FluxioProfile& profile);
virtual std::optional<std::vector<skills::manager::arondto::FluxioProfile>> loadProfiles();
private: private:
armarx::plugins::SkillManagerComponentPlugin* plugin = nullptr; armarx::plugins::SkillManagerComponentPlugin* plugin = nullptr;
......
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