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{
20
21 void
23 const std::string& prefix)
24 {
26 Base::defineProperties(defs, prefix);
27 }
28
29 void
34
35 void
37 {
38 // add skills
39 auto skills = info.providedSkills;
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
62 ExecutableSkillLibraryCoreSegment::removeSkillProvider(const std::string& /*providerName*/)
63 {
64 // Nothing to do here right now: this segment commits provider
65 // skills into the underlying memory in addSkillProvider() and
66 // does not maintain any per-provider in-memory bookkeeping.
67 // Removing the provider's skills from the memory itself is not
68 // implemented yet (TODO: add info about removed provider to
69 // memory).
70 //
71 // A previously-present `skills` std::map member was erased here
72 // without any locking, while addSkillProvider() shadowed that
73 // member with a local of the same name and never populated it,
74 // making the data structure dead. The dead member and the
75 // associated data race were removed; this function is kept as
76 // part of the public API surface called from
77 // SkillsMemory::removeProvider().
78 }
79} // namespace armarx::skills::segment
MemoryID withProviderSegmentName(const std::string &name) const
Definition MemoryID.cpp:417
Helps connecting a Memory server to the Ice interface.
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
static DateTime Now()
Definition DateTime.cpp:51
std::map< SkillID, SkillDescription > providedSkills
ExecutableSkillLibraryCoreSegment(armem::server::MemoryToIceAdapter &iceMemory)
void defineProperties(PropertyDefinitionsPtr defs, const std::string &prefix)
void toAron(arondto::MemoryID &dto, const MemoryID &bo)
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
This file is part of ArmarX.
A bundle of updates to be sent to the memory.
Definition Commit.h:90
EntityUpdate & add()
Definition Commit.cpp:80
float confidence
An optional confidence, may be used for things like decay.
Definition Commit.h:43