NavigateToChargingStation.cpp
Go to the documentation of this file.
1
#include "
NavigateToChargingStation.h
"
2
3
#include <sstream>
4
5
#include <
ArmarXCore/core/time/Duration.h
>
6
#include <
ArmarXCore/util/CPPUtility/trace.h
>
7
8
#include <
RobotAPI/libraries/skills/core/Skill.h
>
9
#include <
RobotAPI/libraries/skills/core/SkillDescription.h
>
10
11
#include <armarx/navigation/skills/aron/NavigateToNamedLocation.aron.generated.h>
12
#include <
armarx/navigation/skills/skill_ids.h
>
13
14
namespace
armarx::navigation::skills
15
{
16
17
armarx::skills::SkillDescription
18
NavigateToChargingStation::GetSkillDescription
()
19
{
20
ParamType
defaultParameters;
21
22
defaultParameters.inFrontOfChargingStationLocationName =
"charging-station/inFrontOf"
;
23
defaultParameters.chargingLocationName =
"charging-station/charging"
;
24
25
std::stringstream
description
;
26
description
<<
"Go to the charging station and initiate charging."
;
27
description
<<
"\n"
;
28
description
<<
"Optionally the names of the charging-station locations can be changed "
29
"through the skill's parameters."
;
30
description
<<
"\n\n"
;
31
description
32
<<
" - **inFrontOfChargingStationLocationName**: Name of the location the robot will "
33
"first navigate to in order to initiate the movement towards the charging "
34
"station.\n\n"
;
35
description
36
<<
" - **chargingLocationName**: Name of the location where the robot should charge. "
37
"This is just a theoretical location, since the robot will probably have to find a "
38
"very precise placement where the wireless charging will initiate.\n"
;
39
40
return
armarx::skills::SkillDescription
{
41
.
skillId
=
skill_ids::NavigateToChargingStation
,
42
.description =
description
.str(),
43
.
rootProfileDefaults
= defaultParameters.toAron(),
44
.timeout =
armarx::core::time::Duration::Minutes
(3),
45
.parametersType = Params::ToAronType(),
46
};
47
}
48
49
NavigateToChargingStation::Properties::SubSkillIds::SubSkillIds
() :
50
navigateToNamedLocation{
armarx::navigation::skills::skill_ids::NavigateToNamedLocation
}
51
{
52
;
53
}
54
55
NavigateToChargingStation::NavigateToChargingStation
(
const
Properties
& properties) :
56
Base
(
GetSkillDescription
()), properties(properties)
57
{
58
;
59
}
60
61
::armarx::skills::Skill::MainResult
62
NavigateToChargingStation::main
(
const
Base::SpecializedMainInput& in)
63
{
64
ARMARX_TRACE
;
65
throwIfSkillShouldTerminate
();
66
67
// Navigate to inFrontOf charging station location for approach.
68
{
69
arondto::NavigateToNamedLocationParams namedLocationParams;
70
namedLocationParams.locationName = in.parameters.inFrontOfChargingStationLocationName;
71
72
auto
update
=
73
callSubskill
(properties.
subSkillIDs
.
navigateToNamedLocation
, namedLocationParams);
74
if
(not(
update
.has_value() and
update
->hasBeenSucceeded()))
75
{
76
return
MakeFailedResult
();
77
}
78
}
79
80
ARMARX_TRACE
;
81
throwIfSkillShouldTerminate
();
82
83
// Navigate to charging location to initiate charging.
84
{
85
// TODO: Does not work because the location is not reachable.
86
87
// arondto::NavigateToNamedLocationParams namedLocationParams;
88
// namedLocationParams.locationName = in.parameters.chargingLocationName;
89
90
// auto update =
91
// callSubskill(properties.subSkillIDs.navigateToNamedLocation, namedLocationParams);
92
// if (not(update.has_value() and update->hasBeenSucceeded()))
93
// {
94
// return MakeFailedResult();
95
// }
96
}
97
98
ARMARX_TRACE
;
99
throwIfSkillShouldTerminate
();
100
101
return
MakeSucceededResult
();
102
}
103
104
}
// namespace armarx::navigation::skills
armarx::skills::SimpleSpecializedSkill< arondto::NavigateToChargingStationParams >::ParamType
arondto::NavigateToChargingStationParams ParamType
Definition:
SimpleSpecializedSkill.h:14
armarx::navigation::skills::NavigateToChargingStation::Properties::SubSkillIds::navigateToNamedLocation
armarx::skills::SkillID navigateToNamedLocation
Definition:
NavigateToChargingStation.h:39
armarx::skills::SkillDescription
Definition:
SkillDescription.h:17
armarx::navigation::skills::NavigateToChargingStation::Properties
Definition:
NavigateToChargingStation.h:33
trace.h
Duration.h
armarx::navigation::skills::NavigateToChargingStation::GetSkillDescription
::armarx::skills::SkillDescription GetSkillDescription()
Definition:
NavigateToChargingStation.cpp:18
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:32
armarx::navigation::skills::NavigateToChargingStation::Properties::subSkillIDs
SubSkillIds subSkillIDs
Definition:
NavigateToChargingStation.h:42
armarx::skills::Skill::MakeFailedResult
static MainResult MakeFailedResult()
Definition:
Skill.cpp:338
ARMARX_TRACE
#define ARMARX_TRACE
Definition:
trace.h:77
Skill.h
armarx::skills::Skill::description
SkillDescription description
Definition:
Skill.h:300
armarx::skills::SkillDescription::skillId
SkillID skillId
Definition:
SkillDescription.h:19
armarx::skills::SimpleSpecializedSkill
Definition:
SimpleSpecializedSkill.h:10
armarx::core::time::Duration::Minutes
static Duration Minutes(std::int64_t minutes)
Constructs a duration in minutes.
Definition:
Duration.cpp:96
armarx::skills::Skill::MakeSucceededResult
static MainResult MakeSucceededResult(aron::data::DictPtr data=nullptr)
Definition:
Skill.cpp:329
armarx::skills::Skill::MainResult
A result struct for th main method of a skill.
Definition:
Skill.h:39
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition:
mongodb.cpp:68
armarx::skills::SkillDescription::rootProfileDefaults
aron::data::DictPtr rootProfileDefaults
Definition:
SkillDescription.h:21
armarx::skills::SimpleSpecializedSkill< arondto::NavigateToChargingStationParams >::main
Skill::MainResult main() final
Definition:
SimpleSpecializedSkill.h:71
skill_ids.h
armarx::skills::Skill::throwIfSkillShouldTerminate
void throwIfSkillShouldTerminate(const std::string &abortedMessage="")
Definition:
Skill.cpp:305
NavigateToChargingStation.h
armarx::navigation::skills::skill_ids::NavigateToChargingStation
const armarx::skills::SkillID NavigateToChargingStation
Definition:
skill_ids.cpp:71
armarx::navigation::skills::NavigateToChargingStation::Properties::SubSkillIds::SubSkillIds
SubSkillIds()
Definition:
NavigateToChargingStation.cpp:49
armarx::navigation::skills
Definition:
constants.cpp:25
armarx::navigation::skills::skill_ids::NavigateToNamedLocation
const armarx::skills::SkillID NavigateToNamedLocation
Definition:
skill_ids.cpp:66
SkillDescription.h
armarx::navigation::skills::NavigateToChargingStation::NavigateToChargingStation
NavigateToChargingStation(const Properties &properties)
Definition:
NavigateToChargingStation.cpp:55
armarx
navigation
skills
NavigateToChargingStation.cpp
Generated on Sat Mar 29 2025 09:17:35 for armarx_documentation by
1.8.17