Recursive.cpp
Go to the documentation of this file.
1 #include "Recursive.h"
2 
4 
6 {
7 
8  RecursiveSkill::RecursiveSkill() : SimpleSpecializedSkill<skills::Example::RecursiveSkillParams>(GetSkillDescription())
9  {
10  }
11 
14  {
15  armarx::skills::Example::RecursiveSkillParams root_profile_params;
16  root_profile_params.n = 10;
17 
18  return SkillDescription{.skillId = skills::SkillID{.skillName = "Recursive"},
19  .description = "This skill calls itself recursively {n} times",
20  .rootProfileDefaults = root_profile_params.toAron(),
22  .parametersType =
23  armarx::skills::Example::RecursiveSkillParams::ToAronType(),
24  .resultType = armarx::skills::Example::RecursiveSkillParams::ToAronType()};
25  }
26 
28  RecursiveSkill::main(const SpecializedMainInput& in)
29  {
30  const int n = in.parameters.n;
31 
32  if (n > 0)
33  {
34  SkillProxy prx(manager,
35  skills::SkillID{.providerId = *getSkillId().providerId, .skillName = "Recursive"});
36 
37  armarx::skills::Example::RecursiveSkillParams params;
38  params.n = n - 1;
39 
40  std::this_thread::sleep_for(std::chrono::milliseconds(100));
41 
42  callSubskill(prx, params.toAron());
43  }
44 
46 
47  return {TerminatedSkillStatus::Succeeded, nullptr};
48  }
49 } // namespace armarx::skills::provider
armarx::skills::Skill::manager
manager::dti::SkillManagerInterfacePrx manager
Definition: Skill.h:327
armarx::skills::provider::RecursiveSkill::RecursiveSkill
RecursiveSkill()
Definition: Recursive.cpp:8
armarx::skills::TerminatedSkillStatus::Succeeded
@ Succeeded
skills
This file is part of ArmarX.
armarx::skills::SkillID::skillName
std::string skillName
Definition: SkillID.h:60
armarx::skills::SkillDescription
Definition: SkillDescription.h:18
armarx::skills::SkillID::providerId
std::optional< ProviderID > providerId
Definition: SkillID.h:59
armarx::skills::Skill::callSubskill
std::optional< TerminatedSkillStatusUpdate > callSubskill(const skills::SkillProxy &proxy)
Call a subskill with default parameters and block until the subskill terminates.
Definition: Skill.cpp:22
armarx::skills::SkillProxy
Definition: SkillProxy.h:11
Recursive.h
armarx::skills::provider::RecursiveSkill::GetSkillDescription
static SkillDescription GetSkillDescription()
Definition: Recursive.cpp:13
armarx::skills::SkillDescription::skillId
SkillID skillId
Definition: SkillDescription.h:20
armarx::skills::SimpleSpecializedSkill
Definition: SimpleSpecializedSkill.h:10
armarx::skills::provider
Definition: BusyWaiting.cpp:6
armarx::skills::Skill::MainResult
A result struct for th main method of a skill.
Definition: Skill.h:48
armarx::skills::SimpleSpecializedSkill< skills::Example::RecursiveSkillParams >::main
Skill::MainResult main() final
Definition: SimpleSpecializedSkill.h:71
armarx::skills::Skill::throwIfSkillShouldTerminate
void throwIfSkillShouldTerminate(const std::string &abortedMessage="")
Definition: Skill.cpp:291
armarx::skills::SkillID
Definition: SkillID.h:17
armarx::skills::Skill::getSkillId
SkillID getSkillId() const
Get the id of the skill.
Definition: Skill.h:74
armarx::core::time::Duration::MilliSeconds
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
Definition: Duration.cpp:55
SkillDescription.h