27#include <SimoxUtility/algorithm/string.h>
39#include <RobotAPI/interface/skills/SkillManagerInterface.h>
45#include <RobotAPI/libraries/skills/core/aron/FluxioSkill.aron.generated.h>
54 statechartListenerProviderSegment(
iceAdapter()),
69 const std::string prefix =
"mem.";
70 statechartListenerProviderSegment.defineProperties(defs, prefix +
"statechartlistener.");
71 executableSkillCoreSegment.defineProperties(defs, prefix +
"executableskill.");
72 composedSkillCoreSegment.defineProperties(defs, prefix +
"composedskill.");
73 profileCoreSegment.defineProperties(defs, prefix +
"profile.");
74 skillExecutionRequestCoreSegment.defineProperties(defs, prefix +
"executionrequest.");
75 skillEventCoreSegment.defineProperties(defs, prefix +
"event.");
80 defs->topic(debugObserver);
82 p.useDebugObserver,
"useDebugObserver",
"Enable debug observer timing measurements");
96 statechartListenerProviderSegment.init();
97 executableSkillCoreSegment.init();
98 composedSkillCoreSegment.init();
99 profileCoreSegment.init();
100 skillExecutionRequestCoreSegment.init();
101 skillEventCoreSegment.init();
103 ARMARX_INFO <<
"Using debug observer: " << p.useDebugObserver;
110 if (p.useDebugObserver && debugObserver)
113 ARMARX_INFO <<
"Debug observer set for LTM timing measurements";
117 createRemoteGuiTab();
131 armem::data::CommitResult
136 IceUtil::Time startTime = IceUtil::Time::now();
138 armem::data::CommitResult result = ReadWritePluginUser::commit(
commit);
140 skills::callback::dti::SkillProviderCallbackInterfacePrx myPrx;
143 for (
const auto& up :
commit.updates)
145 if (up.entityID.coreSegmentName ==
148 for (
const auto& instance : up.instancesData)
160 skillExecutionRequestCoreSegment.convertCommit(instance);
164 catch (
const std::exception& e)
168 <<
". The local memory commit still proceeds.";
174 if (p.useDebugObserver and debugObserver)
176 debugObserver->setDebugChannel(
179 {
"Memory | t commit [ms]",
180 new Variant((IceUtil::Time::now() - startTime).toMilliSecondsDouble())},
189 const Ice::Current& current)
191 ARMARX_INFO <<
"Adding provider to skill memory: " << info.providerId.providerName;
196 executableSkillCoreSegment.addSkillProvider(p);
201 const Ice::Current& current)
203 executableSkillCoreSegment.removeSkillProvider(provider.providerName);
209 skills::manager::dto::SkillStatusUpdate
211 const Ice::Current& current)
213 IceUtil::Time startTime = IceUtil::Time::now();
216 skillExecutionRequestCoreSegment.addSkillExecutionRequest(e);
218 skills::manager::dto::SkillStatusUpdate result =
221 if (p.useDebugObserver and debugObserver)
223 debugObserver->setDebugChannel(
226 {
"Memory | t executeSkill [ms]",
227 new Variant((IceUtil::Time::now() - startTime).toMilliSecondsDouble())},
234 skills::manager::dto::SkillExecutionID
236 const Ice::Current& current)
238 IceUtil::Time startTime = IceUtil::Time::now();
241 skillExecutionRequestCoreSegment.addSkillExecutionRequest(e);
243 skills::manager::dto::SkillExecutionID result =
246 if (p.useDebugObserver and debugObserver)
248 debugObserver->setDebugChannel(
251 {
"Memory | t executeSkillAsync [ms]",
252 new Variant((IceUtil::Time::now() - startTime).toMilliSecondsDouble())},
261 const skills::callback::dto::ProviderID& providerId,
262 const Ice::Current& current)
264 IceUtil::Time startTime = IceUtil::Time::now();
269 skillEventCoreSegment.addSkillUpdateEvent(u);
272 if (p.useDebugObserver and debugObserver)
274 debugObserver->setDebugChannel(
277 {
"Memory | t updateStatusForSkill [ms]",
278 new Variant((IceUtil::Time::now() - startTime).toMilliSecondsDouble())},
283 IceUtil::Optional<skills::manager::dto::SkillStatusUpdate>
285 const Ice::Current& current)
287 IceUtil::Time startTime = IceUtil::Time::now();
290 auto op = this->skillEventCoreSegment.getSkillStatusUpdate(eid);
292 if (p.useDebugObserver and debugObserver)
294 debugObserver->setDebugChannel(
297 {
"Memory | t getSkillStatusUpdate(eid) [ms]",
298 new Variant((IceUtil::Time::now() - startTime).toMilliSecondsDouble())},
304 return op->toManagerIce();
309 skills::manager::dto::SkillStatusUpdateMap
312 IceUtil::Time startTime = IceUtil::Time::now();
314 skills::manager::dto::SkillStatusUpdateMap ret;
315 auto updates = this->skillEventCoreSegment.getSkillStatusUpdates();
317 if (p.useDebugObserver and debugObserver)
319 debugObserver->setDebugChannel(
322 {
"Memory | t getSkillStatusUpdates [ms]",
323 new Variant((IceUtil::Time::now() - startTime).toMilliSecondsDouble())},
326 startTime = IceUtil::Time::now();
329 for (
const auto& [k, v] : updates)
331 ret.insert({k.toManagerIce(), v.toManagerIce()});
334 if (p.useDebugObserver and debugObserver)
336 debugObserver->setDebugChannel(
339 {
"Memory | t getSkillStatusUpdates.toManagerIce [ms]",
340 new Variant((IceUtil::Time::now() - startTime).toMilliSecondsDouble())},
352 const ProfilerStatechartTransitionWithParameters&
x,
355 statechartListenerProviderSegment.reportStatechartTransitionWithParameters(
x);
360 const ProfilerStatechartTransitionWithParametersList&
x,
363 statechartListenerProviderSegment.reportStatechartTransitionWithParametersList(
x);
368 SkillsMemory::createRemoteGuiTab()
374 tab.clearSkillEventsButton.
setLabel(
"Clear Skill Events WM");
375 root.
addChild(tab.clearSkillEventsButton);
377 tab.clearSkillExecutionRequestsButton.
setLabel(
"Clear Skill Execution Requests WM");
378 root.
addChild(tab.clearSkillExecutionRequestsButton);
384 SkillsMemory::RemoteGui_update()
388 clearSkillEventsWorkingMemory();
390 if (tab.clearSkillExecutionRequestsButton.wasClicked())
392 clearSkillExecutionRequestsWorkingMemory();
397 SkillsMemory::clearSkillEventsWorkingMemory()
399 bool consolidated =
false;
400 const std::size_t snapshotCount = skillEventCoreSegment.clearAndConsolidate(
403 ARMARX_IMPORTANT <<
"Cleared SkillEvent working memory: removed " << snapshotCount
404 <<
" snapshot(s). Consolidated to LTM: "
405 << (consolidated ?
"yes" :
"no (recording disabled)") <<
".";
409 SkillsMemory::clearSkillExecutionRequestsWorkingMemory()
411 bool consolidated =
false;
412 const std::size_t snapshotCount = skillExecutionRequestCoreSegment.clearAndConsolidate(
415 ARMARX_IMPORTANT <<
"Cleared SkillExecutionRequest working memory: removed "
416 << snapshotCount <<
" snapshot(s). Consolidated to LTM: "
417 << (consolidated ?
"yes" :
"no (recording disabled)") <<
".";
427 composedSkillCoreSegment.addSkill(skill);
430 std::optional<std::vector<skills::manager::arondto::FluxioSkill>>
433 return composedSkillCoreSegment.getSkills();
436 std::optional<std::vector<skills::manager::arondto::FluxioSkill>>
439 return composedSkillCoreSegment.getSkillsOfProvider(providerId);
445 profileCoreSegment.addProfile(profile);
448 std::optional<std::vector<skills::manager::arondto::FluxioProfile>>
451 return profileCoreSegment.getProfiles();
Default component property definition container.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
std::string getName() const
Retrieve name of object.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
void removeProvider(const skills::manager::dto::ProviderID &provider, const Ice::Current ¤t) override
void addProvider(const skills::manager::dto::ProviderInfo &providerInfo, const Ice::Current ¤t) override
skills::manager::dto::SkillExecutionID executeSkillAsync(const skills::manager::dto::SkillExecutionRequest &skillExecutionRequest, const Ice::Current ¤t) override
SkillManagerComponentPluginUser()
skills::manager::dto::SkillStatusUpdate executeSkill(const skills::manager::dto::SkillExecutionRequest &info, const Ice::Current ¤t) override
void onInitComponent() override
void addProvider(const skills::manager::dto::ProviderInfo &info, const Ice::Current ¤t) override
void removeProvider(const skills::manager::dto::ProviderID &provider, const Ice::Current ¤t) override
armem::data::CommitResult commit(const armem::data::Commit &commit, const Ice::Current &) override
skills::manager::dto::SkillStatusUpdateMap getSkillExecutionStatuses(const Ice::Current ¤t) override
std::optional< std::vector< skills::manager::arondto::FluxioProfile > > loadProfiles() override
std::optional< std::vector< skills::manager::arondto::FluxioSkill > > loadCompositeSkillsOfProvider(const std::string &providerId) override
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void updateStatusForSkill(const skills::provider::dto::SkillStatusUpdate &update, const skills::callback::dto::ProviderID &id, const Ice::Current ¤t) override
void reportStatechartTransitionWithParameters(const ProfilerStatechartTransitionWithParameters &, const Ice::Current &) override
void addProfile(const skills::manager::arondto::FluxioProfile &profile) override
skills::manager::dto::SkillStatusUpdate executeSkill(const skills::manager::dto::SkillExecutionRequest &info, const Ice::Current ¤t) override
void onConnectComponent() override
IceUtil::Optional< skills::manager::dto::SkillStatusUpdate > getSkillExecutionStatus(const skills::manager::dto::SkillExecutionID &executionId, const Ice::Current ¤t) override
void reportStatechartTransitionWithParametersList(const ProfilerStatechartTransitionWithParametersList &, const Ice::Current &) override
void onExitComponent() override
skills::manager::dto::SkillExecutionID executeSkillAsync(const skills::manager::dto::SkillExecutionRequest &info, const Ice::Current ¤t) override
std::optional< std::vector< skills::manager::arondto::FluxioSkill > > loadCompositeSkills() override
void saveSkill(const skills::manager::arondto::FluxioSkill &skillt) override
std::string getDefaultName() const override
StatechartListenerComponentPluginUser()
The Variant class is described here: Variants.
void setDebugObserver(DebugObserverInterfacePrx observer)
Set an optional debug observer for timing measurements.
server::ltm::Memory & longtermMemory()
void setMemoryName(const std::string &memoryName)
server::wm::Memory & workingMemory()
MemoryToIceAdapter & iceAdapter()
static ProviderID FromIce(const manager::dto::ProviderID &)
static ProviderInfo FromIce(const manager::dto::ProviderInfo &)
manager::dto::SkillExecutionRequest toManagerIce() const
static SkillExecutionRequest FromIce(const manager::dto::SkillExecutionRequest &)
static constexpr const char * CoreSegmentName
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
void RemoteGui_startRunningTask()
void RemoteGui_createTab(std::string const &name, RemoteGui::Client::Widget const &rootWidget, RemoteGui::Client::Tab *tab)
static SkillExecutionID FromIce(const skills::manager::dto::SkillExecutionID &)
static SkillStatusUpdate FromIce(const provider::dto::SkillStatusUpdate &update, const std::optional< skills::ProviderID > &providerId=std::nullopt)