SkillManagerComponentPluginUser.cpp
Go to the documentation of this file.
2 
3 #include <mutex>
4 #include <optional>
5 #include <string>
6 #include <vector>
7 
8 #include <boost/uuid/uuid_io.hpp>
9 
10 #include <Ice/Exception.h>
11 #include <Ice/OutputStream.h>
12 #include <IceUtil/Exception.h>
13 #include <IceUtil/Optional.h>
14 
18 #include <ArmarXCore/interface/core/time.h>
19 
27 #include <RobotAPI/interface/aron/Aron.h>
28 #include <RobotAPI/interface/skills/SkillManagerInterface.h>
29 #include <RobotAPI/libraries/skills/core/aron/FluxioProfile.aron.generated.h>
30 #include <RobotAPI/libraries/skills/core/aron/FluxioSkill.aron.generated.h>
31 
32 namespace armarx
33 {
35  {
36  addPlugin(plugin);
37  }
38 
39  void
40  SkillManagerComponentPluginUser::addProvider(const skills::manager::dto::ProviderInfo& info,
41  const Ice::Current&)
42  {
43  auto i = skills::ProviderInfo::FromIce(info);
44  this->plugin->addProvider(i);
45  std::string providerId = boost::uuids::to_string(
46  armarx::plugins::SkillManagerComponentPlugin::createUuidWithString(
47  info.providerId.providerName));
48  std::optional<std::vector<skills::manager::arondto::FluxioSkill>> opt =
50 
51  if (!opt.has_value())
52  {
53  ARMARX_ERROR << "Failed to load composite skills for provider "
54  << info.providerId.providerName;
55  return;
56  }
57 
58  for (const auto& skill : opt.value())
59  {
60  // TODO: Implement a proper way to load all skills from memory without breaking dependencies etc.
61  }
62  }
63 
64  void
66  const skills::manager::dto::ProviderID& provider,
67  const Ice::Current&)
68  {
69  auto i = skills::ProviderID::FromIce(provider);
70  this->plugin->removeProvider(i);
71  }
72 
73  skills::manager::dto::SkillStatusUpdate
75  const skills::manager::dto::SkillExecutionRequest& info,
76  const Ice::Current&)
77  {
79  return this->plugin->executeSkill(e).toManagerIce();
80  }
81 
82  skills::manager::dto::SkillExecutionID
84  const skills::manager::dto::SkillExecutionRequest& info,
85  const Ice::Current& current)
86  {
88  return this->plugin->executeSkillAsync(e).toManagerIce();
89  }
90 
91  skills::provider::dto::ParameterUpdateResult
93  const skills::manager::dto::SkillExecutionID& info,
94  const aron::data::dto::DictPtr& params,
95  const Ice::Current& current)
96  {
97  skills::provider::dto::ParameterUpdateResult ret;
99  auto e = skills::SkillExecutionID::FromIce(info);
100  ret.success = this->plugin->updateSkillParameters(e, a);
101  return ret;
102  }
103 
104  skills::provider::dto::AbortSkillResult
105  SkillManagerComponentPluginUser::abortSkill(const skills::manager::dto::SkillExecutionID& id,
106  const Ice::Current& current)
107  {
108  skills::provider::dto::AbortSkillResult ret;
110  ret.success = this->plugin->abortSkill(i);
111  return ret;
112  }
113 
114  skills::provider::dto::AbortSkillResult
116  const skills::manager::dto::SkillExecutionID& id,
117  const Ice::Current& /*unused*/)
118  {
119  skills::provider::dto::AbortSkillResult ret;
121  ret.success = this->plugin->abortSkillAsync(i);
122  return ret;
123  }
124 
125  std::vector<skills::provider::dto::AbortSkillResult>
127  {
128  ARMARX_IMPORTANT << "Stopping all running executions.";
129 
130  std::vector<skills::provider::dto::AbortSkillResult> results;
131 
132  skills::manager::dto::SkillStatusUpdateMap executions;
133 
134  // we ALWAYS want the newest information when stopping all!
135  // e.g. there is some new skill not known to the GUI which we explicitely want to stop too.
136  // the stop-all function is often used in an emergency, so we'll live with the extra call...
137  try
138  {
139  executions = this->getSkillExecutionStatuses(current);
140  }
141  catch (...) // if any error occurs, we use the snapshot as backup. better to miss a skill
142  // than to not do anything.
143  {
144  executions = this->getSkillExecutionStatuses(current);
145  }
146 
147  for (auto& [executionId, status] : executions)
148  {
149  // select all running executions...
150  if (status.status != armarx::skills::core::dto::Execution::Aborted and
151  status.status != armarx::skills::core::dto::Execution::Failed)
152  {
153  // ... and kill them.
154  results.push_back(this->abortSkill(executionId, current));
155  }
156  }
157  return results;
158  }
159 
160  std::vector<skills::provider::dto::AbortSkillResult>
162  {
163  ARMARX_IMPORTANT << "Stopping all running executions.";
164  std::vector<skills::provider::dto::AbortSkillResult> results;
165 
166  skills::manager::dto::SkillStatusUpdateMap executions;
167 
168  // we ALWAYS want the newest information when stopping all!
169  // e.g. there is some new skill not known to the GUI which we explicitely want to stop too.
170  // the stop-all function is often used in an emergency, so we'll live with the extra call...
171  try
172  {
173  executions = this->getSkillExecutionStatuses(current);
174  }
175  catch (...) // if any error occurs, we use the snapshot as backup. better to miss a skill
176  // than to not do anything.
177  {
178  executions = this->getSkillExecutionStatuses(current);
179  }
180 
181  for (auto& [executionId, status] : executions)
182  {
183  // select all running executions...
184  if (status.status != armarx::skills::core::dto::Execution::Aborted and
185  status.status != armarx::skills::core::dto::Execution::Failed)
186  {
187  // ... and kill them.
188  results.push_back(this->abortSkillAsync(executionId, current));
189  }
190  }
191  return results;
192  }
193 
194  void
196  const skills::provider::dto::SkillStatusUpdate& statusUpdate,
197  const skills::callback::dto::ProviderID& pid,
198  const Ice::Current&)
199  {
200  (void)statusUpdate;
201  (void)pid;
202  // If you want to use the status, implement this method!
203  }
204 
205  skills::manager::dto::SkillDescriptionMap
207  {
208  skills::manager::dto::SkillDescriptionMap ret;
209 
210  auto m = this->plugin->getSkillDescriptions();
211 
212  for (const auto& [k, v] : m)
213  {
214  ret.insert({k.toManagerIce(), v.toManagerIce()});
215  }
216 
217  return ret;
218  }
219 
220  IceUtil::Optional<skills::manager::dto::SkillDescription>
221  SkillManagerComponentPluginUser::getSkillDescription(const skills::manager::dto::SkillID& id,
222  const Ice::Current& current)
223  {
224  auto e = skills::SkillID::FromIce(id);
225  auto o = this->plugin->getSkillDescription(e);
226  if (o.has_value())
227  {
228  return o->toManagerIce();
229  }
230  return {};
231  }
232 
233  IceUtil::Optional<skills::manager::dto::SkillStatusUpdate>
235  const skills::manager::dto::SkillExecutionID& executionId,
236  const Ice::Current& current)
237  {
238  auto e = skills::SkillExecutionID::FromIce(executionId);
239  auto o = this->plugin->getSkillExecutionStatus(e);
240  if (o.has_value())
241  {
242  return o->toManagerIce();
243  }
244  return {};
245  }
246 
247  skills::manager::dto::SkillStatusUpdateMap
249  {
250  skills::manager::dto::SkillStatusUpdateMap ret;
251 
252  auto m = this->plugin->getSkillExecutionStatuses();
253 
254  for (const auto& [k, v] : m)
255  {
256  ret.insert({k.toManagerIce(), v.toManagerIce()});
257  }
258 
259  return ret;
260  }
261 
262  //****************************//
263  //** Fluxio related methods **//
264  //****************************//
265 
266  aron::type::dto::AronObjectPtr
267  SkillManagerComponentPluginUser::getTypes(const Ice::Current& current)
268  {
269  const auto& res = this->plugin->getTypes();
270  return res->toAronObjectDTO();
271  }
272 
273  IceUtil::Optional<std::string>
275  const std::string& profileId,
276  const Ice::Current& current)
277  {
278  const auto& res = this->plugin->executeFluxioSkill(skillId, profileId, "Fluxio");
279  if (!res.isSuccess())
280  {
281  auto e = res.getError();
282  e.addToContext(std::nullopt, "SkillManagerComponentPluginUser", __FUNCTION__, __LINE__);
283  throw e.toManagerIce();
284  }
285  if (res.getResult() == nullptr)
286  {
287  auto e = res.getError();
288  e.addToContext(std::nullopt, "SkillManagerComponentPluginUser", __FUNCTION__, __LINE__);
289  throw e.toManagerIce();
290  }
291 
292  return res.getResult()->id;
293  }
294 
295  void
297  const Ice::Current& current)
298  {
299  this->plugin->abortFluxioSkill(executionId);
300  }
301 
302  IceUtil::Optional<skills::manager::dto::FluxioSkillStatusUpdateList>
304  const Ice::Current& current)
305  {
306  auto l = this->plugin->getFluxioSkillExecutionStatus(executionId);
307  if (!l.isSuccess())
308  {
309  ARMARX_WARNING << "Error getting FluxioSkillExecutionStatus";
310 
311  auto e = l.getError();
312  e.addToContext(std::nullopt, "SkillManagerComponentPluginUser", __FUNCTION__, __LINE__);
313  throw e.toManagerIce();
314  }
315 
316  skills::manager::dto::FluxioSkillStatusUpdateList ret;
317 
318  for (const auto& s : l.getResult())
319  {
320  ret.push_back(s.toManagerIce());
321  }
322 
323  return ret;
324  }
325 
326  skills::manager::dto::FluxioSkillList
328  {
329  skills::manager::dto::FluxioSkillList ret;
330 
331  auto l = this->plugin->getSkillList();
332 
333  if (!l.isSuccess())
334  {
335  auto e = l.getError();
336  e.addToContext(std::nullopt, "SkillManagerComponentPluginUser", __FUNCTION__, __LINE__);
337  throw e.toManagerIce();
338  }
339 
340  for (const auto& s : l.getResult())
341  {
342  if (s == nullptr)
343  {
344  ARMARX_WARNING << "Unexpected nullptr!";
345  continue;
346  }
347 
348  const auto& skill = s->toManagerIce();
349 
350  if (!skill.has_value())
351  {
352  ARMARX_WARNING << "Skill with id " << s->id << " could not be converted";
353  continue;
354  }
355 
356  ret.push_back(skill.value());
357  }
358 
359  return ret;
360  }
361 
362  IceUtil::Optional<skills::manager::dto::FluxioSkill>
363  SkillManagerComponentPluginUser::getSkill(const std::string& id, const Ice::Current& current)
364  {
365  auto result = this->plugin->getSkill(id);
366 
367  if (!result.isSuccess())
368  {
369  auto e = result.getError();
370  e.addToContext(std::nullopt, "SkillManagerComponentPluginUser", __FUNCTION__, __LINE__);
371  throw e.toManagerIce();
372  }
373  const auto& skill = result.getResult();
374  if (skill == nullptr)
375  {
376  return {};
377  }
378 
379  const auto& s = skill->toManagerIce();
380 
381  if (!s.has_value())
382  {
383  return {};
384  }
385 
386  return s.value();
387  }
388 
389  bool
391  const skills::manager::dto::FluxioSkill& skill,
392  const Ice::Current& current)
393  {
394  std::scoped_lock l(this->plugin->fluxioDC.skillsMutex,
395  this->plugin->fluxioDC.profilesMutex,
396  this->plugin->fluxioDC.providersMutex,
397  this->plugin->fluxioDC.typesMutex);
398  auto& skillsMap = this->plugin->fluxioDC.skills;
399  auto& providersMap = this->plugin->fluxioDC.providers;
400  auto& profilesMap = this->plugin->fluxioDC.profiles;
401  auto& typesMap = this->plugin->fluxioDC.types;
402  const auto& s = skillsMap.find(skill.id);
403 
404  // Check if the skill exists
405  if (s == skillsMap.end())
406  {
407  ARMARX_WARNING << "Skill with id " << skill.id << " not found";
408  return false;
409  }
410 
411  // Check if the user has the mutex for the skill
412  auto res = this->plugin->getSkillMutex(skill.id, userId);
413  if (!res.isSuccess())
414  {
415  ARMARX_WARNING << "User " << userId << "User does not have Mutex for this Skill"
416  << skill.id;
417 
418  auto error = res.getError();
419  error.addToContext(skills::error::createErrorMessage(
421  "SkillManagerComponentPluginUser",
422  __FUNCTION__,
423  __LINE__);
424  throw error.toManagerIce();
425  }
426 
427  const bool ret =
428  s->second.updateFromIce(skill, providersMap, profilesMap, skillsMap, typesMap);
429 
430  std::optional<skills::manager::arondto::FluxioSkill> opt = s->second.toAronXml();
431 
432  if (!opt.has_value())
433  {
434  ARMARX_WARNING << "Skill with id " << skill.id << " could not be converted";
435  return false;
436  }
437 
438  saveSkill(opt.value());
439 
440  return ret;
441  }
442 
443  bool
445  const std::string& userId,
446  const std::string& skillId,
447  const skills::manager::dto::FluxioParameterList& parameters,
448  const Ice::Current& current)
449  {
450  // updateSkillParameterValues for all params
451  for (const auto& param : parameters)
452  {
453  const auto& res =
454  this->updateSkillParameterValues(userId, skillId, param.id, param.values, current);
455  if (!res)
456  {
457  ARMARX_WARNING << "Parameter value of param " << param.id << " and skill "
458  << skillId << " could not be converted";
459  return false;
460  }
461  }
462 
463 
464  return true;
465  }
466 
467  bool
469  const std::string& userId,
470  const std::string& skillId,
471  const std::string& parameterId,
472  const skills::manager::dto::FluxioValueList& values,
473  const Ice::Current& current)
474  {
475  std::scoped_lock l(this->plugin->fluxioDC.skillsMutex,
476  this->plugin->fluxioDC.profilesMutex);
477  auto& skillsMap = this->plugin->fluxioDC.skills;
478  auto& profilesMap = this->plugin->fluxioDC.profiles;
479 
480  // check if skill exists
481  const auto& skill = skillsMap.find(skillId);
482 
483  if (skill == skillsMap.end())
484  {
485  ARMARX_WARNING << "Skill with id " << skillId << " not found";
486  return false;
487  }
488 
489  // Check if the user has the mutex for the skill
490  auto res = this->plugin->getSkillMutex(skillId, userId);
491  if (!res.isSuccess())
492  {
493  ARMARX_WARNING << "User " << userId << "User does not have Mutex for this Skill"
494  << skillId;
495 
496  auto error = res.getError();
497  error.addToContext(skills::error::createErrorMessage(
499  "SkillManagerComponentPluginUser",
500  __FUNCTION__,
501  __LINE__);
502  throw error.toManagerIce();
503  }
504 
505  // check if parameter exists in skill
506  const auto& p = skill->second.parameters.find(parameterId);
507  if (p == skill->second.parameters.end())
508  {
509  ARMARX_WARNING << "Parameter with id " << parameterId << " not found in skill with id "
510  << skillId;
511  return false;
512  }
513 
514  // update values of parameter
515  p->second.updateValuesFromIce(values, profilesMap);
516  return true;
517  }
518 
519  IceUtil::Optional<skills::manager::dto::FluxioIdentificatorList>
521  const std::string& userId,
522  const bool dryRun,
523  const Ice::Current& current)
524  {
525  skills::manager::dto::FluxioIdentificatorList ret;
528  res = this->plugin->getSkill(skillId);
529  if (!res.isSuccess())
530  {
531  ARMARX_WARNING << "Error getting skill with id " << skillId;
532  return {};
533  }
535  res.getResult();
536  std::optional<skills::manager::arondto::FluxioSkill> opt = skillptr->toAronXml();
537  if (!opt.has_value())
538  {
539  ARMARX_WARNING << "Skill with id " << skillId << " could not be converted";
540  return {};
541  }
542  skills::manager::arondto::FluxioSkill skill = opt.value();
543 
544  auto l = this->plugin->deleteSkill(skillId, userId, dryRun);
545 
546  if (!l.has_value())
547  {
548  return {};
549  }
550 
551  for (const auto& s : l.value())
552  {
553  if (s == nullptr)
554  {
555  ARMARX_WARNING << "Unexpected nullptr!";
556  continue;
557  }
558  ret.push_back(s->toFluxioIdentificatorIce());
559  }
560 
561  if (!dryRun)
562  {
563  skill.deleted = true;
564  saveSkill(skill);
565  }
566 
567  return ret;
568  }
569 
570  bool
572  const std::string& userId,
573  const Ice::Current& current)
574  {
575  return this->plugin->getSkillMutex(skillId, userId).getResult();
576  }
577 
578  void
580  const std::string& userId,
581  const Ice::Current& current)
582  {
583  this->plugin->deleteSkillMutex(skillId, userId);
584  }
585 
586  IceUtil::Optional<skills::manager::dto::FluxioIdentificatorList>
588  const std::string& parameterId,
589  const std::string& userId,
590  bool dryRun,
591  const Ice::Current& current)
592  {
593  skills::manager::dto::FluxioIdentificatorList ret;
594  auto res = this->plugin->deleteSkillParameter(skillId, parameterId, userId, dryRun);
595 
596  if (!res.isSuccess())
597  {
598  throw res.getError().toManagerIce();
599  }
600 
601  for (const auto& s : res.getResult())
602  {
603  if (s == nullptr)
604  {
605  ARMARX_WARNING << "Unexpected nullptr!";
606  continue;
607  }
608  ret.push_back(s->toFluxioIdentificatorIce());
609  }
610 
611  return ret;
612  }
613 
614  IceUtil::Optional<skills::manager::dto::FluxioIdentificatorList>
616  const std::string& skillId,
617  const skills::manager::dto::FluxioParameter& parameter,
618  const std::string& userId,
619  bool dryRun,
620  const Ice::Current& current)
621  {
622  skills::manager::dto::FluxioIdentificatorList ret;
623  auto res = this->plugin->updateSkillParameter(skillId, parameter, userId, dryRun);
624 
625  if (!res.isSuccess())
626  {
627  throw res.getError().toManagerIce();
628  }
629 
630  for (const auto& s : res.getResult())
631  {
632  if (s == nullptr)
633  {
634  ARMARX_WARNING << "Unexpected nullptr!";
635  continue;
636  }
637  ret.push_back(s->toFluxioIdentificatorIce());
638  }
639 
640  return ret;
641  }
642 
643  skills::manager::dto::FluxioProfileList
645  {
646  skills::manager::dto::FluxioProfileList ret;
647 
648  auto l = this->plugin->getProfileList();
649 
650  for (const auto& p : l.getResult())
651  {
652  if (p == nullptr)
653  {
654  ARMARX_WARNING << "Unexpected nullptr!";
655  continue;
656  }
657  ret.push_back(p->toManagerIce());
658  }
659 
660  return ret;
661  }
662 
663  IceUtil::Optional<skills::manager::dto::FluxioProfile>
664  SkillManagerComponentPluginUser::getProfile(const std::string& id, const Ice::Current& current)
665  {
666  auto profile = this->plugin->getProfile(id);
667 
668  if (!profile.isSuccess())
669  {
670  auto e = profile.getError();
671  e.addToContext(std::nullopt, "SkillManagerComponentPluginUser", __FUNCTION__, __LINE__);
672  throw e.toManagerIce();
673  }
674  return profile.getResult().toManagerIce();
675  }
676 
677  skills::manager::dto::FluxioProfile
679  const skills::manager::dto::FluxioProfile& profile,
680  const Ice::Current& current)
681  {
682  std::unique_lock l(this->plugin->fluxioDC.profilesMutex);
683  auto& profilesMap = this->plugin->fluxioDC.profiles;
684 
685  const auto& converted = skills::FluxioProfile::FromIce(profile, profilesMap);
686  l.unlock();
687 
688  armarx::skills::FluxioProfile ret = this->plugin->createProfile(converted).getResult();
689 
690  addProfile(ret.toManagerAron());
691 
692  return ret.toManagerIce();
693  }
694 
695  void
697  const skills::manager::dto::FluxioProfile& profile,
698  const Ice::Current& current)
699  {
700  std::unique_lock l(this->plugin->fluxioDC.profilesMutex);
701  auto& profilesMap = this->plugin->fluxioDC.profiles;
702  l.unlock();
703 
704  this->plugin->updateProfile(skills::FluxioProfile::FromIce(profile, profilesMap));
705  }
706 
707  skills::manager::dto::FluxioProviderList
709  {
710  skills::manager::dto::FluxioProviderList ret;
711 
712  auto l = this->plugin->getProviderList();
713  if (!l.isSuccess())
714  {
715  auto e = l.getError();
716  e.addToContext(std::nullopt, "SkillManagerComponentPluginUser", __FUNCTION__, __LINE__);
717  throw e.toManagerIce();
718  }
719 
720  for (const auto& p : l.getResult())
721  {
722  if (p == nullptr)
723  {
724  ARMARX_WARNING << "Unexpected nullptr!";
725  continue;
726  }
727  ret.push_back(p->toManagerIce());
728  }
729 
730  return ret;
731  }
732 
733  IceUtil::Optional<skills::manager::dto::FluxioProvider>
734  SkillManagerComponentPluginUser::getProvider(const std::string& id, const Ice::Current& current)
735  {
736  auto provider = this->plugin->getProvider(id);
737 
738  if (provider.isSuccess())
739  {
740  auto e = provider.getError();
741  e.addToContext(std::nullopt, "SkillManagerComponentPluginUser", __FUNCTION__, __LINE__);
742  throw e.toManagerIce();
743  }
744  return provider.getResult().toManagerIce();
745  }
746 
747  IceUtil::Optional<skills::manager::dto::FluxioSkillList>
749  const Ice::Current& current)
750  {
751  skills::manager::dto::FluxioSkillList ret;
752 
753  auto l = this->plugin->getSkillsOfProvider(id);
754 
755  if (!l.isSuccess())
756  {
757  auto error = l.getError();
758  error.addToContext(
759  std::nullopt, "SkillManagerComponentPluginUser", __FUNCTION__, __LINE__);
760  throw error.toManagerIce();
761  }
762 
763  for (const auto& s : l.getResult())
764  {
765  if (s == nullptr)
766  {
767  ARMARX_WARNING << "Unexpected nullptr!";
768  continue;
769  }
770 
771  const auto& skill = s->toManagerIce();
772 
773  if (!skill.has_value())
774  {
776  << "SkillManagerComponentPluginUser::getSkillsOfProvider: Skill with id "
777  << s->id << " could not be converted";
778  continue;
779  }
780 
781  ret.push_back(skill.value());
782  }
783 
784  return ret;
785  }
786 
787  IceUtil::Optional<skills::manager::dto::FluxioSkill>
789  const std::string& userId,
790  const std::string& providerId,
791  const skills::manager::dto::FluxioSkill& skill,
792  const Ice::Current& current)
793  {
794  std::unique_lock skillsLock(this->plugin->fluxioDC.skillsMutex, std::defer_lock);
795  std::unique_lock profilesLock(this->plugin->fluxioDC.profilesMutex, std::defer_lock);
796  std::unique_lock providersLock(this->plugin->fluxioDC.providersMutex, std::defer_lock);
797  std::unique_lock typesLock(this->plugin->fluxioDC.typesMutex, std::defer_lock);
798  std::lock(skillsLock, profilesLock, providersLock, typesLock);
799 
800  auto& skillsMap = this->plugin->fluxioDC.skills;
801  auto& providersMap = this->plugin->fluxioDC.providers;
802  auto& profilesMap = this->plugin->fluxioDC.profiles;
803  auto& typesMap = this->plugin->fluxioDC.types;
804  auto skillBO =
805  skills::FluxioSkill::FromIce(skill, providersMap, profilesMap, skillsMap, typesMap);
806 
807  if (skillBO == nullptr)
808  {
809  ARMARX_WARNING << "Skill with id " << skill.id << " could not be converted";
810 
813  {skill.id}),
815  "SkillManagerComponentPluginUser",
816  __FUNCTION__,
817  __LINE__)
818  .toManagerIce();
819  }
820 
821  skillsLock.unlock();
822  profilesLock.unlock();
823  providersLock.unlock();
824  typesLock.unlock();
825 
826  auto& skillReleased = *skillBO.release();
827  const auto res =
828  this->plugin->addSkillToProvider(userId, providerId, std::move(skillReleased));
829  if (!res.isSuccess())
830  {
831  ARMARX_WARNING << "Skill with id " << skill.id
832  << " could not be added to provider with id " << providerId;
833 
834  auto error = res.getError();
835  error.addToContext(
837  {skill.id, providerId})),
838  "SkillManagerComponentPluginUser",
839  __FUNCTION__,
840  __LINE__);
841  throw error.toManagerIce();
842  }
843 
844  const auto& s = res.getResult();
845 
846  if (s == nullptr)
847  {
848  ARMARX_WARNING << "Skill with id " << skill.id
849  << " could not be added to provider with id " << providerId;
850  return {};
851  }
852 
853  const auto& ret = s->toManagerIce();
854  if (!ret.has_value())
855  {
856  ARMARX_WARNING << "Skill with id " << skill.id << " could not be converted";
857  return {};
858  }
859 
860  const std::optional<skills::manager::arondto::FluxioSkill> aronSkill = s->toAronXml();
861 
862  if (!aronSkill.has_value())
863  {
864  ARMARX_WARNING << "Skill with id " << skill.id << " could not be converted to Aron";
865  return {};
866  }
867 
868  saveSkill(aronSkill.value());
869 
870  return ret.value();
871  }
872 
873  void
874  SkillManagerComponentPluginUser::saveSkill(const skills::manager::arondto::FluxioSkill& skill)
875  {
876  // Implemented in derived class
877  }
878 
879  std::optional<std::vector<skills::manager::arondto::FluxioSkill>>
881  {
882  // Implemented in derived class
883  return {};
884  }
885 
886  std::optional<std::vector<skills::manager::arondto::FluxioSkill>>
888  {
889  // Implemented in derived class
890  return {};
891  }
892 
893  void
895  const skills::manager::arondto::FluxioProfile& profile)
896  {
897  // Implemented in derived class
898  }
899 
900  std::optional<std::vector<skills::manager::arondto::FluxioProfile>>
902  {
903  // Implemented in derived class
904  return {};
905  }
906 } // namespace armarx
armarx::SkillManagerComponentPluginUser::createProfile
skills::manager::dto::FluxioProfile createProfile(const skills::manager::dto::FluxioProfile &profile, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:678
armarx::skills::error::FluxioException::toManagerIce
skills::manager::dto::FluxioException toManagerIce() const
Definition: FluxioException.cpp:43
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:13
armarx::skills::SkillStatusUpdate::toManagerIce
manager::dto::SkillStatusUpdate toManagerIce() const
Definition: SkillStatusUpdate.cpp:289
armarx::SkillManagerComponentPluginUser::getProfile
IceUtil::Optional< skills::manager::dto::FluxioProfile > getProfile(const std::string &id, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:664
armarx::SkillManagerComponentPluginUser::addSkillToProvider
IceUtil::Optional< skills::manager::dto::FluxioSkill > addSkillToProvider(const std::string &userId, const std::string &providerId, const skills::manager::dto::FluxioSkill &skill, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:788
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:190
LocalException.h
armarx::SkillManagerComponentPluginUser::loadProfiles
virtual std::optional< std::vector< skills::manager::arondto::FluxioProfile > > loadProfiles()
Definition: SkillManagerComponentPluginUser.cpp:901
armarx::SkillManagerComponentPluginUser::getSkillExecutionStatus
IceUtil::Optional< skills::manager::dto::SkillStatusUpdate > getSkillExecutionStatus(const skills::manager::dto::SkillExecutionID &executionId, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:234
armarx::SkillManagerComponentPluginUser::executeSkill
skills::manager::dto::SkillStatusUpdate executeSkill(const skills::manager::dto::SkillExecutionRequest &info, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:74
FluxioSkill.h
armarx::skills::error::FluxioException
A base class for skill exceptions.
Definition: FluxioException.h:24
armarx::SkillManagerComponentPluginUser::deleteSkillParameter
IceUtil::Optional< skills::manager::dto::FluxioIdentificatorList > deleteSkillParameter(const std::string &skillId, const std::string &parameterId, const std::string &userId, bool dryRun, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:587
armarx::skills::error::ErrorCode::UserHasNoMutexError
@ UserHasNoMutexError
armarx::skills::error::createErrorMessage
std::string createErrorMessage(ErrorCode code, const std::vector< std::string > &args)
Definition: FluxioErrorMessages.cpp:25
armarx::plugins::SkillManagerComponentPlugin::deleteSkillMutex
void deleteSkillMutex(const std::string &skillId, const std::string &userId)
Definition: SkillManagerComponentPlugin.cpp:1488
armarx::SkillManagerComponentPluginUser::getSkillsOfProvider
IceUtil::Optional< skills::manager::dto::FluxioSkillList > getSkillsOfProvider(const std::string &id, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:748
armarx::plugins::SkillManagerComponentPlugin::getSkillDescription
std::optional< skills::SkillDescription > getSkillDescription(const skills::SkillID &id)
Definition: SkillManagerComponentPlugin.cpp:444
SkillManagerComponentPluginUser.h
armarx::skills::SkillExecutionRequest::FromIce
static SkillExecutionRequest FromIce(const manager::dto::SkillExecutionRequest &)
Definition: SkillExecutionRequest.cpp:29
FluxioProvider.h
armarx::plugins::SkillManagerComponentPlugin::getFluxioSkillExecutionStatus
skills::Result< std::vector< skills::FluxioSkillStatusUpdate >, skills::error::FluxioException > getFluxioSkillExecutionStatus(const std::string &executionId)
Definition: SkillManagerComponentPlugin.cpp:878
armarx::SkillManagerComponentPluginUser::getSkillDescriptions
skills::manager::dto::SkillDescriptionMap getSkillDescriptions(const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:206
armarx::plugins::SkillManagerComponentPlugin::getSkillMutex
skills::Result< bool, skills::error::FluxioException > getSkillMutex(const std::string &skillId, const std::string &userId)
Definition: SkillManagerComponentPlugin.cpp:1481
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::skills::ProviderInfo::FromIce
static ProviderInfo FromIce(const manager::dto::ProviderInfo &)
Definition: ProviderInfo.cpp:22
armarx::SkillManagerComponentPluginUser::getProfileList
skills::manager::dto::FluxioProfileList getProfileList(const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:644
armarx::SkillManagerComponentPluginUser::saveSkill
virtual void saveSkill(const skills::manager::arondto::FluxioSkill &skill)
Definition: SkillManagerComponentPluginUser.cpp:874
armarx::skills::error::ErrorCode::AddSkillError
@ AddSkillError
armarx::plugins::SkillManagerComponentPlugin::getSkillDescriptions
std::map< skills::SkillID, skills::SkillDescription > getSkillDescriptions()
Definition: SkillManagerComponentPlugin.cpp:499
armarx::plugins::SkillManagerComponentPlugin::getProfileList
skills::Result< std::vector< std::experimental::observer_ptr< const skills::FluxioProfile > >, skills::error::FluxioException > getProfileList()
Definition: SkillManagerComponentPlugin.cpp:1497
FluxioProfile.h
armarx::ManagedIceObject::addPlugin
PluginT * addPlugin(const std::string prefix="", ParamsT &&... params)
Definition: ManagedIceObject.h:186
armarx::SkillManagerComponentPluginUser::addProfile
virtual void addProfile(const skills::manager::arondto::FluxioProfile &profile)
Definition: SkillManagerComponentPluginUser.cpp:894
armarx::plugins::SkillManagerComponentPlugin::abortSkill
bool abortSkill(const skills::SkillExecutionID &id)
Definition: SkillManagerComponentPlugin.cpp:356
armarx::SkillManagerComponentPluginUser::loadCompositeSkills
virtual std::optional< std::vector< skills::manager::arondto::FluxioSkill > > loadCompositeSkills()
Definition: SkillManagerComponentPluginUser.cpp:880
armarx::plugins::SkillManagerComponentPlugin::executeFluxioSkill
skills::Result< std::experimental::observer_ptr< skills::FluxioExecutor >, skills::error::FluxioException > executeFluxioSkill(const std::string &skillId, const std::string &profileId, const std::string &executorName, armarx::aron::data::DictPtr parameters=nullptr)
Definition: SkillManagerComponentPlugin.cpp:697
armarx::skills::error::FluxioException::create
static FluxioException create(const std::string &message, const FluxioExceptionType &type, const std::string &className, const char *function, int line)
Definition: FluxioException.cpp:31
armarx::SkillManagerComponentPluginUser::executeSkillAsync
skills::manager::dto::SkillExecutionID executeSkillAsync(const skills::manager::dto::SkillExecutionRequest &skillExecutionRequest, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:83
std::experimental::fundamentals_v2::observer_ptr
Definition: ManagedIceObject.h:53
armarx::SkillManagerComponentPluginUser::getProviderList
skills::manager::dto::FluxioProviderList getProviderList(const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:708
armarx::plugins::SkillManagerComponentPlugin::deleteSkill
std::optional< std::vector< std::experimental::observer_ptr< const skills::FluxioSkill > > > deleteSkill(const std::string &skillId, const std::string &userId, bool dryRun)
Definition: SkillManagerComponentPlugin.cpp:1163
Dict.h
armarx::plugins::SkillManagerComponentPlugin::getSkill
skills::Result< std::experimental::observer_ptr< const skills::FluxioSkill >, skills::error::FluxioException > getSkill(const std::string &id)
Definition: SkillManagerComponentPlugin.cpp:1141
armarx::skills::FluxioProfile::FromIce
static FluxioProfile FromIce(const manager::dto::FluxioProfile &i, std::map< std::string, FluxioProfile > &profilesMap)
Definition: FluxioProfile.cpp:111
armarx::aron::data::Dict::FromAronDictDTO
static PointerType FromAronDictDTO(const data::dto::DictPtr &aron)
Definition: Dict.cpp:130
armarx::SkillManagerComponentPluginUser::getSkillExecutionStatuses
skills::manager::dto::SkillStatusUpdateMap getSkillExecutionStatuses(const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:248
SkillManagerComponentPlugin.h
armarx::skills::error::ErrorCode::ConverterError
@ ConverterError
armarx::skills::SkillExecutionID::toManagerIce
skills::manager::dto::SkillExecutionID toManagerIce() const
Definition: SkillExecutionID.cpp:11
armarx::plugins::SkillManagerComponentPlugin::executeSkill
skills::SkillStatusUpdate executeSkill(const skills::SkillExecutionRequest &req)
Definition: SkillManagerComponentPlugin.cpp:175
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::SkillManagerComponentPluginUser::abortAllSkillsAsync
std::vector< skills::provider::dto::AbortSkillResult > abortAllSkillsAsync(const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:161
armarx::plugins::SkillManagerComponentPlugin::removeProvider
void removeProvider(const skills::ProviderID &id)
Definition: SkillManagerComponentPlugin.cpp:159
armarx::skills::Result::isSuccess
bool isSuccess() const
Definition: FluxioResult.h:31
armarx::status
status
Definition: FiniteStateMachine.h:244
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
armarx::SkillManagerComponentPluginUser::getSkillDescription
IceUtil::Optional< skills::manager::dto::SkillDescription > getSkillDescription(const skills::manager::dto::SkillID &id, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:221
ManagedIceObject.h
armarx::SkillManagerComponentPluginUser::abortSkill
skills::provider::dto::AbortSkillResult abortSkill(const skills::manager::dto::SkillExecutionID &id, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:105
FluxioException.h
armarx::plugins::SkillManagerComponentPlugin::updateSkillParameters
bool updateSkillParameters(const skills::SkillExecutionID &id, const aron::data::DictPtr &data)
Definition: SkillManagerComponentPlugin.cpp:309
armarx::skills::FluxioSkill::FromIce
static std::unique_ptr< FluxioSkill > FromIce(const manager::dto::FluxioSkill &i, std::map< std::string, FluxioProvider > &providersMap, std::map< std::string, FluxioProfile > &profilesMap, std::map< std::string, FluxioSkill > &skillsMap, std::map< std::string, aron::type::ObjectPtr > &typesMap)
Definition: FluxioSkill.cpp:515
armarx::SkillManagerComponentPluginUser::getProvider
IceUtil::Optional< skills::manager::dto::FluxioProvider > getProvider(const std::string &id, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:734
armarx::SkillManagerComponentPluginUser::getFluxioSkillExecutionStatus
IceUtil::Optional< skills::manager::dto::FluxioSkillStatusUpdateList > getFluxioSkillExecutionStatus(const std::string &executionId, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:303
armarx::skills::Result::getResult
T getResult() const
Definition: FluxioResult.h:37
armarx::skills::SkillID::FromIce
static SkillID FromIce(const manager::dto::SkillID &)
Definition: SkillID.cpp:36
armarx::SkillManagerComponentPluginUser::removeProvider
void removeProvider(const skills::manager::dto::ProviderID &provider, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:65
armarx::plugins::SkillManagerComponentPlugin::deleteSkillParameter
skills::Result< std::vector< std::experimental::observer_ptr< const skills::FluxioSkill > >, skills::error::FluxioException > deleteSkillParameter(const std::string &skillId, const std::string &parameterId, const std::string &userId, bool dryRun)
Definition: SkillManagerComponentPlugin.cpp:1295
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:196
armarx::plugins::SkillManagerComponentPlugin::addSkillToProvider
skills::Result< std::experimental::observer_ptr< const skills::FluxioSkill >, skills::error::FluxioException > addSkillToProvider(const std::string &userId, const std::string &providerId, skills::FluxioSkill &&skill)
Definition: SkillManagerComponentPlugin.cpp:1738
armarx::plugins::SkillManagerComponentPlugin::getSkillsOfProvider
skills::Result< std::vector< std::experimental::observer_ptr< const skills::FluxioSkill > >, skills::error::FluxioException > getSkillsOfProvider(const std::string &id)
Definition: SkillManagerComponentPlugin.cpp:1697
armarx::plugins::SkillManagerComponentPlugin::updateProfile
void updateProfile(const skills::FluxioProfile &profile)
Definition: SkillManagerComponentPlugin.cpp:1605
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:41
armarx::SkillManagerComponentPluginUser::abortAllSkills
std::vector< skills::provider::dto::AbortSkillResult > abortAllSkills(const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:126
armarx::plugins::SkillManagerComponentPlugin::getSkillExecutionStatus
std::optional< skills::SkillStatusUpdate > getSkillExecutionStatus(const skills::SkillExecutionID &id)
Definition: SkillManagerComponentPlugin.cpp:547
armarx::SkillManagerComponentPluginUser::executeFluxioSkill
IceUtil::Optional< std::string > executeFluxioSkill(const std::string &skillId, const std::string &profileId, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:274
armarx::SkillManagerComponentPluginUser::abortFluxioSkill
void abortFluxioSkill(const std::string &executionId, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:296
armarx::plugins::SkillManagerComponentPlugin::getProviderList
skills::Result< std::vector< std::experimental::observer_ptr< const skills::FluxioProvider > >, skills::error::FluxioException > getProviderList()
Definition: SkillManagerComponentPlugin.cpp:1650
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
armarx::plugins::SkillManagerComponentPlugin::getProfile
skills::Result< skills::FluxioProfile, skills::error::FluxioException > getProfile(const std::string &id)
Definition: SkillManagerComponentPlugin.cpp:1506
armarx::SkillManagerComponentPluginUser::updateStatusForSkill
void updateStatusForSkill(const skills::provider::dto::SkillStatusUpdate &update, const skills::callback::dto::ProviderID &id, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:195
armarx::SkillManagerComponentPluginUser::deleteSkill
IceUtil::Optional< skills::manager::dto::FluxioIdentificatorList > deleteSkill(const std::string &skillId, const std::string &userId, bool dryRun, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:520
armarx::skills::FluxioProfile
Definition: FluxioProfile.h:14
armarx::plugins::SkillManagerComponentPlugin::createProfile
skills::Result< skills::FluxioProfile, skills::error::FluxioException > createProfile(const skills::FluxioProfile &profile)
Definition: SkillManagerComponentPlugin.cpp:1527
armarx::SkillManagerComponentPluginUser::addProvider
void addProvider(const skills::manager::dto::ProviderInfo &providerInfo, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:40
armarx::SkillManagerComponentPluginUser::updateSkillValues
bool updateSkillValues(const std::string &userId, const std::string &skillId, const skills::manager::dto::FluxioParameterList &parameters, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:444
armarx::plugins::SkillManagerComponentPlugin::abortSkillAsync
bool abortSkillAsync(const skills::SkillExecutionID &id)
Definition: SkillManagerComponentPlugin.cpp:401
armarx::SkillManagerComponentPluginUser::updateSkillParameterValues
bool updateSkillParameterValues(const std::string &userId, const std::string &skillId, const std::string &parameterId, const skills::manager::dto::FluxioValueList &values, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:468
armarx::skills::SkillExecutionID::FromIce
static SkillExecutionID FromIce(const skills::manager::dto::SkillExecutionID &)
Definition: SkillExecutionID.cpp:31
armarx::plugins::SkillManagerComponentPlugin::getProvider
skills::Result< skills::FluxioProvider, skills::error::FluxioException > getProvider(const std::string &id)
Definition: SkillManagerComponentPlugin.cpp:1673
armarx::plugins::SkillManagerComponentPlugin::getTypes
aron::type::ObjectPtr getTypes()
Definition: SkillManagerComponentPlugin.cpp:1917
armarx::SkillManagerComponentPluginUser::updateSkillParameter
IceUtil::Optional< skills::manager::dto::FluxioIdentificatorList > updateSkillParameter(const std::string &skillId, const skills::manager::dto::FluxioParameter &parameter, const std::string &userId, bool dryRun, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:615
armarx::SkillManagerComponentPluginUser::updateProfile
void updateProfile(const skills::manager::dto::FluxioProfile &profile, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:696
armarx::plugins::SkillManagerComponentPlugin::addProvider
void addProvider(const skills::ProviderInfo &info)
Definition: SkillManagerComponentPlugin.cpp:133
Logging.h
armarx::plugins::SkillManagerComponentPlugin::executeSkillAsync
skills::SkillExecutionID executeSkillAsync(const skills::SkillExecutionRequest &req)
Definition: SkillManagerComponentPlugin.cpp:241
armarx::SkillManagerComponentPluginUser::updateSkillParameters
skills::provider::dto::ParameterUpdateResult updateSkillParameters(const skills::manager::dto::SkillExecutionID &executionId, const aron::data::dto::DictPtr &params, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:92
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::plugins::SkillManagerComponentPlugin::updateSkillParameter
skills::Result< std::vector< std::experimental::observer_ptr< const skills::FluxioSkill > >, skills::error::FluxioException > updateSkillParameter(const std::string &skillId, const skills::manager::dto::FluxioParameter &parameter, const std::string &userId, bool dryRun)
Definition: SkillManagerComponentPlugin.cpp:1305
armarx::plugins::SkillManagerComponentPlugin::getSkillList
skills::Result< std::vector< std::experimental::observer_ptr< const skills::FluxioSkill > >, skills::error::FluxioException > getSkillList()
Definition: SkillManagerComponentPlugin.cpp:1134
armarx::SkillManagerComponentPluginUser::loadCompositeSkillsOfProvider
virtual std::optional< std::vector< skills::manager::arondto::FluxioSkill > > loadCompositeSkillsOfProvider(const std::string &providerId)
Definition: SkillManagerComponentPluginUser.cpp:887
armarx::SkillManagerComponentPluginUser::getSkill
IceUtil::Optional< skills::manager::dto::FluxioSkill > getSkill(const std::string &id, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:363
armarx::SkillManagerComponentPluginUser::abortSkillAsync
skills::provider::dto::AbortSkillResult abortSkillAsync(const skills::manager::dto::SkillExecutionID &id, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:115
armarx::SkillManagerComponentPluginUser::updateSkill
bool updateSkill(const std::string &userId, const skills::manager::dto::FluxioSkill &skill, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:390
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::skills::ProviderID::FromIce
static ProviderID FromIce(const manager::dto::ProviderID &)
Definition: ProviderID.cpp:32
armarx::skills::Result
Definition: FluxioResult.h:12
armarx::SkillManagerComponentPluginUser::getSkillList
skills::manager::dto::FluxioSkillList getSkillList(const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:327
armarx::skills::error::FluxioExceptionType::BAD_REQUEST
@ BAD_REQUEST
armarx::SkillManagerComponentPluginUser::getTypes
aron::type::dto::AronObjectPtr getTypes(const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:267
armarx::SkillManagerComponentPluginUser::getSkillMutex
bool getSkillMutex(const std::string &skillId, const std::string &userId, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:571
FluxioErrorMessages.h
armarx::plugins::SkillManagerComponentPlugin::abortFluxioSkill
void abortFluxioSkill(const std::string &executionId)
Definition: SkillManagerComponentPlugin.cpp:854
armarx::plugins::SkillManagerComponentPlugin::getSkillExecutionStatuses
std::map< skills::SkillExecutionID, skills::SkillStatusUpdate > getSkillExecutionStatuses()
Definition: SkillManagerComponentPlugin.cpp:605
armarx::SkillManagerComponentPluginUser::deleteSkillMutex
void deleteSkillMutex(const std::string &skillId, const std::string &userId, const Ice::Current &current) override
Definition: SkillManagerComponentPluginUser.cpp:579
armarx::SkillManagerComponentPluginUser::SkillManagerComponentPluginUser
SkillManagerComponentPluginUser()
Definition: SkillManagerComponentPluginUser.cpp:34