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