SkillExecutionRequestSegment.cpp
Go to the documentation of this file.
2 
3 #include <SimoxUtility/algorithm/string.h>
4 
6 #include <RobotAPI/libraries/armem_skills/aron/Skill.aron.generated.h>
9 
11 {
12 
15  Base(iceMemory, CoreSegmentName, skills::arondto::SkillExecutionRequest::ToAronType())
16  {
17  }
18 
19  void
21  const std::string& prefix)
22  {
23  this->setDefaultMaxHistorySize(50);
24  Base::defineProperties(defs, prefix);
25  }
26 
27  void
29  {
30  Base::init();
31  }
32 
35  {
36  // convert ice commitData to aron
37  auto commitDataAron = std::make_shared<aron::data::Dict>(commitData);
38 
39  // we got a skill execution request
40  skills::arondto::SkillExecutionRequest request;
41  request.fromAron(commitDataAron);
42 
44  .skillId = SkillID{.providerId = ProviderID{.providerName = ""}, .skillName = ""},
45  .executorName = ""};
46  armem::fromAron(request, info);
47  return info;
48  }
49 
50  void
53  {
54  // override directly execution to add a request to the memory
55  armem::Commit comm;
56 
57  skills::arondto::SkillExecutionRequest request;
58  armem::toAron(request, info);
59 
60  auto aron = request.toAron();
61 
62  {
63  auto& entityUpdate = comm.add();
64 
65  armem::MemoryID skillExecutionMemID = id();
66  skillExecutionMemID.providerSegmentName = request.skillId.providerId.providerName;
67  skillExecutionMemID.entityName = request.skillId.skillName;
68 
69  entityUpdate.entityID = skillExecutionMemID;
70  entityUpdate.instancesData = {aron};
71  entityUpdate.confidence = 1.0;
72  entityUpdate.referencedTime = armem::Time::Now();
73  }
74 
75  {
76  auto& entityUpdate = comm.add();
77 
78  armem::MemoryID skillExecutionMemID = id();
79  skillExecutionMemID.providerSegmentName = "All Skill Execution Requests";
80  skillExecutionMemID.entityName = "All Skill Execution Requests";
81 
82  entityUpdate.entityID = skillExecutionMemID;
83  entityUpdate.instancesData = {aron};
84  entityUpdate.confidence = 1.0;
85  entityUpdate.referencedTime = armem::Time::Now();
86  }
87 
88 
90  }
91 } // namespace armarx::skills::segment
skills
This file is part of ArmarX.
armarx::skills::SkillExecutionRequest::skillId
skills::SkillID skillId
Definition: SkillExecutionRequest.h:33
armarx::armem::MemoryID::providerSegmentName
std::string providerSegmentName
Definition: MemoryID.h:52
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
armarx::armem::server::MemoryToIceAdapter
Helps connecting a Memory server to the Ice interface.
Definition: MemoryToIceAdapter.h:19
armarx::skills::segment::SkillExecutionRequestCoreSegment::SkillExecutionRequestCoreSegment
SkillExecutionRequestCoreSegment(armem::server::MemoryToIceAdapter &iceMemory)
Definition: SkillExecutionRequestSegment.cpp:13
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:55
armarx::skills::segment::SkillExecutionRequestCoreSegment::convertCommit
skills::SkillExecutionRequest convertCommit(const aron::data::dto::DictPtr &commitData)
Definition: SkillExecutionRequestSegment.cpp:34
armarx::armem::toAron
void toAron(arondto::MemoryID &dto, const MemoryID &bo)
Definition: aron_conversions.cpp:19
armarx::skills::ProviderID::providerName
std::string providerName
Definition: ProviderID.h:31
armarx::skills::SkillID::providerId
std::optional< ProviderID > providerId
Definition: SkillID.h:59
armarx::skills::segment::SkillExecutionRequestCoreSegment::init
void init()
Definition: SkillExecutionRequestSegment.cpp:28
NLohmannJSONConverter.h
armarx::skills::segment::SkillExecutionRequestCoreSegment::defineProperties
void defineProperties(PropertyDefinitionsPtr defs, const std::string &prefix)
Definition: SkillExecutionRequestSegment.cpp:20
armarx::skills::SkillExecutionRequest
Definition: SkillExecutionRequest.h:21
armarx::skills::ProviderID
Definition: ProviderID.h:15
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
aron_conversions.h
armarx::skills::segment
Definition: ExecutableSkillLibrarySegment.cpp:13
armarx::armem::server::segment::detail::SegmentBase< server::wm::CoreSegment >
armarx::armem::server::segment::SpecializedCoreSegment::init
virtual void init() override
Definition: SpecializedCoreSegment.cpp:49
armarx::armem::MemoryID::entityName
std::string entityName
Definition: MemoryID.h:53
MemoryToIceAdapter.h
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::armem::fromAron
void fromAron(const arondto::MemoryID &dto, MemoryID &bo)
Definition: aron_conversions.cpp:8
armarx::armem::Commit::add
EntityUpdate & add()
Definition: Commit.cpp:81
armarx::armem::server::segment::detail::SegmentBase< server::wm::CoreSegment >::iceMemory
MemoryToIceAdapter & iceMemory
Definition: SpecializedSegment.h:60
armarx::armem::server::segment::SpecializedCoreSegment::setDefaultMaxHistorySize
void setDefaultMaxHistorySize(int64_t maxHistorySize)
Definition: SpecializedCoreSegment.cpp:75
SkillExecutionRequestSegment.h
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::armem::server::segment::detail::SegmentBase< server::wm::CoreSegment >::id
MemoryID & id()
Definition: SpecializedSegment.h:35
armarx::skills::SkillID
Definition: SkillID.h:17
armarx::skills::segment::SkillExecutionRequestCoreSegment::addSkillExecutionRequest
void addSkillExecutionRequest(const skills::SkillExecutionRequest &info)
Definition: SkillExecutionRequestSegment.cpp:51
armarx::armem::server::segment::SpecializedCoreSegment::defineProperties
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
Definition: SpecializedCoreSegment.cpp:33
armarx::armem::server::MemoryToIceAdapter::commitLocking
data::CommitResult commitLocking(const data::Commit &commitIce, Time timeArrived)
Definition: MemoryToIceAdapter.cpp:166