Recursive.cpp
Go to the documentation of this file.
1#include "Recursive.h"
2
4
6{
7
9 SimpleSpecializedSkill<skills::Example::RecursiveSkillParams>(GetSkillDescription())
10 {
11 }
12
15 {
16 armarx::skills::Example::RecursiveSkillParams root_profile_params;
17 root_profile_params.n = 10;
18
19 return SkillDescription{
20 .skillId = skills::SkillID{.skillName = "Recursive"},
21 .description = "This skill calls itself recursively {n} times",
22 .rootProfileDefaults = root_profile_params.toAron(),
24 .parametersType = armarx::skills::Example::RecursiveSkillParams::ToAronType(),
25 .resultType = armarx::skills::Example::RecursiveSkillParams::ToAronType()};
26 }
27
29 RecursiveSkill::main(const SpecializedMainInput& in)
30 {
31 const int n = in.parameters.n;
32
33 if (n > 0)
34 {
35 skills::SkillID skillId{.providerId = *getSkillId().providerId,
36 .skillName = "Recursive"};
37
38 armarx::skills::Example::RecursiveSkillParams params;
39 params.n = n - 1;
40
41 std::this_thread::sleep_for(std::chrono::milliseconds(100));
42
43 callSubskill(skillId, params.toAron());
44 }
45
47
48 return {TerminatedSkillStatus::Succeeded, nullptr};
49 }
50} // namespace armarx::skills::provider
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
Definition Duration.cpp:48
std::optional< ProviderID > providerId
Definition SkillID.h:40
std::optional< TerminatedSkillStatusUpdate > callSubskill(const SkillID &skillId)
Call a subskill with the given ID and its default parameters.
Definition Skill.cpp:119
virtual MainResult main()
Override this method with the actual implementation.
Definition Skill.cpp:542
void throwIfSkillShouldTerminate(const std::string &abortedMessage="") const
Definition Skill.cpp:389
SkillID getSkillId() const
Get the id of the skill.
Definition Skill.cpp:587
static SkillDescription GetSkillDescription()
Definition Recursive.cpp:14
This file is part of ArmarX.
A result struct for th main method of a skill.
Definition Skill.h:62