ExecutableSkillLibrarySegment.cpp
Go to the documentation of this file.
2 
3 #include <SimoxUtility/algorithm/string.h>
4 
6 
8 #include <RobotAPI/libraries/armem_skills/aron/Skill.aron.generated.h>
12 
14 {
17  Base(iceMemory, CoreSegmentName, skills::arondto::SkillDescription::ToAronType())
18  {
19  }
20 
21  void
23  const std::string& prefix)
24  {
25  this->setDefaultMaxHistorySize(10);
26  Base::defineProperties(defs, prefix);
27  }
28 
29  void
31  {
32  Base::init();
33  }
34 
35  void
37  {
38  // add skills
39  auto skills = info.providedSkills;
40  auto provId = id().withProviderSegmentName(info.providerId.providerName);
41 
42  for (const auto& [s, d] : skills)
43  {
44  armarx::skills::arondto::SkillDescription skillDescription;
45  armem::toAron(skillDescription, d);
46 
47  armem::Commit commit;
48  auto& entityUpdate = commit.add();
49  entityUpdate.confidence = 1.0;
50  entityUpdate.referencedTime = armem::Time::Now();
51  entityUpdate.sentTime = armem::Time::Now();
52  entityUpdate.arrivedTime = armem::Time::Now();
53  entityUpdate.instancesData = {skillDescription.toAron()};
54  entityUpdate.entityID = provId.withEntityName(d.skillId.skillName);
55 
56  // Commit data to memory and notify
57  iceMemory.commitLocking(commit);
58  }
59  }
60 
61  void
63  {
64  skills.erase(providerName);
65 
66  // TODO also add info about removed provider to memory?
67  }
68 } // namespace armarx::skills::segment
skills
This file is part of ArmarX.
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
armarx::skills::segment::ExecutableSkillLibraryCoreSegment::init
void init()
Definition: ExecutableSkillLibrarySegment.cpp:30
armarx::armem::server::MemoryToIceAdapter
Helps connecting a Memory server to the Ice interface.
Definition: MemoryToIceAdapter.h:19
armarx::skills::SkillDescription
Definition: SkillDescription.h:18
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:55
armarx::skills::ProviderInfo::providedSkills
std::map< SkillID, SkillDescription > providedSkills
Definition: ProviderInfo.h:24
armarx::armem::EntityUpdate::confidence
float confidence
An optional confidence, may be used for things like decay.
Definition: Commit.h:45
armarx::skills::segment::ExecutableSkillLibraryCoreSegment::removeSkillProvider
void removeSkillProvider(const std::string &providerName)
Definition: ExecutableSkillLibrarySegment.cpp:62
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
ExecutableSkillLibrarySegment.h
ice_conversions.h
NLohmannJSONConverter.h
armarx::armem::MemoryID::withProviderSegmentName
MemoryID withProviderSegmentName(const std::string &name) const
Definition: MemoryID.cpp:412
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
DatatypeConverterVisitor.h
MemoryToIceAdapter.h
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
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::armem::server::segment::detail::SegmentBase< server::wm::CoreSegment >::id
MemoryID & id()
Definition: SpecializedSegment.h:35
armarx::skills::ProviderInfo
Definition: ProviderInfo.h:19
armarx::skills::segment::ExecutableSkillLibraryCoreSegment::defineProperties
void defineProperties(PropertyDefinitionsPtr defs, const std::string &prefix)
Definition: ExecutableSkillLibrarySegment.cpp:22
armarx::skills::ProviderInfo::providerId
ProviderID providerId
Definition: ProviderInfo.h:22
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
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
armarx::skills::segment::ExecutableSkillLibraryCoreSegment::ExecutableSkillLibraryCoreSegment
ExecutableSkillLibraryCoreSegment(armem::server::MemoryToIceAdapter &iceMemory)
Definition: ExecutableSkillLibrarySegment.cpp:15
armarx::skills::segment::ExecutableSkillLibraryCoreSegment::addSkillProvider
void addSkillProvider(const skills::ProviderInfo &info)
Definition: ExecutableSkillLibrarySegment.cpp:36