Chaining.cpp
Go to the documentation of this file.
1
2
3#include "Chaining.h"
4
5#include <unistd.h>
6
8{
9
13
16 {
17 armarx::skills::Example::ChainingSkillParams defaultParams;
18 defaultParams.numberOfSkills = 25;
19 defaultParams.waitForXSeconds = 0;
20
21 return SkillDescription{
22 .skillId = armarx::skills::SkillID{.skillName = "Chaining"},
23 .description = "This skill calls the Timeout skill several times. At some point the "
24 "execution is aborted due to a timeout of this skill.",
25 .rootProfileDefaults = defaultParams.toAron(),
26 .timeout = armarx::core::time::Duration::MilliSeconds(10000000000000000),
27 .parametersType = armarx::skills::Example::ChainingSkillParams::ToAronType(),
28 .resultType = armarx::skills::Example::ChainingSkillParams::ToAronType()};
29 }
30
32 ChainingSkill::main(const SpecializedMainInput& in)
33 {
34 const int numberOfSkills = in.parameters.numberOfSkills;
35
36 skills::SkillID skillId{.providerId = *getSkillId().providerId, .skillName = "Timeout"};
37
38 for (int i = 0; i < numberOfSkills; i++)
39 {
41
42 ARMARX_INFO << "Call subskill number " << i;
43 callSubskill(skillId); // Call the Timeout skill and wait for it to finish
44 sleep(in.parameters.waitForXSeconds); // we wait for x seconds
45 ARMARX_INFO << "Waiting for " << in.parameters.waitForXSeconds << "seconds.";
46 }
47
49
50 return {TerminatedSkillStatus::Succeeded, nullptr};
51 }
52} // 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 Chaining.cpp:15
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
A result struct for th main method of a skill.
Definition Skill.h:62