NavigateTo.cpp
Go to the documentation of this file.
1#include "NavigateTo.h"
2
3#include <chrono>
4#include <future>
5#include <string>
6
7#include <Eigen/Core>
8#include <Eigen/Geometry>
9
13
16
22
24{
27 Base(DefaultSkillDescription()), helper(properties, srv)
28 {
29 }
30
32 NavigateTo::init(const Base::SpecializedInitInput& in)
33 {
34 helper.init(in.parameters.navigatingSkillParams,
35 DefaultSkillDescription().skillId.skillName);
36
37 return ::armarx::skills::Skill::InitResult{
39 }
40
42 NavigateTo::main(const Base::SpecializedMainInput& in)
43 {
44 const Eigen::Isometry3f globalTarget(in.parameters.targetPose);
45
46 ARMARX_INFO << "moving to target " << VAROUT(globalTarget.matrix());
47
48 // execute and wait until goal is reached, re-planning while the retry budget lasts
49 ARMARX_INFO << "Sending navigation request";
50 auto se = helper.moveAndWaitForStop(
51 [&] { helper.getNavigator()->moveTo(globalTarget, core::NavigationFrame::Absolute); },
52 [this] { return shouldSkillTerminate(); });
53 if (se)
54 {
55 ARMARX_INFO << "Goal `" << Eigen::Isometry3f(in.parameters.targetPose).translation()
56 << "`reached.";
57 }
58 else
59 {
60 if (se.isSafetyStopTriggeredEvent())
61 {
62 ARMARX_ERROR << "Safety stop was triggered!";
63
64 return ::armarx::skills::Skill::MainResult{
66 }
67 if (se.isUserAbortTriggeredEvent())
68 {
69 ARMARX_ERROR << "Aborted by user!";
70
71 return ::armarx::skills::Skill::MainResult{
73 }
74 if (se.isInternalErrorEvent())
75 {
76 ARMARX_ERROR << "Unknown internal error occured! "
77 << se.toInternalErrorEvent().message;
78
79 return ::armarx::skills::Skill::MainResult{
81 }
82 if (se.isGlobalPlanningFailedEvent())
83 {
84 ARMARX_ERROR << "Global planning failed! "
85 << se.toGlobalPlanningFailedEvent().message;
86
87 return ::armarx::skills::Skill::MainResult{
89 }
90
91 ARMARX_ERROR << "Unknown event!";
92 return ::armarx::skills::Skill::MainResult{
94 }
95
96
97 return ::armarx::skills::Skill::MainResult{
99 }
100
101 void
102 NavigateTo::onStopRequested()
103 {
104 if (helper.getNavigator().has_value())
105 {
106 ARMARX_CHECK(helper.getNavigator().has_value());
107 helper.getNavigator()->stop();
108 }
109 }
110
111 armarx::skills::SkillDescription
113 {
114 ParamType defaultParameters;
115 defaultParameters.navigatingSkillParams = NavigatingSkillHelper::DefaultSkillDescription();
116 // TODO(): set parameter defaults
117
119 .skillId = {.skillName = constants::skill_names::NavigateTo},
120 .description = "",
121 .rootProfileDefaults = defaultParameters.toAron(),
123 .parametersType = Params::ToAronType()};
124 }
125
126} // namespace armarx::navigation::skills
#define VAROUT(x)
static Duration Hours(std::int64_t hours)
Constructs a duration in hours.
Definition Duration.cpp:120
::armarx::skills::SimpleSpecializedSkill< Params > Base
Definition NavigateTo.h:41
static armarx::skills::SkillDescription DefaultSkillDescription()
NavigateTo(const NavigatingSkillHelper::Properties &properties, const NavigatingSkillHelper::Services &srv)
std::optional< client::Navigator > & getNavigator()
void init(const arondto::NavigatingSkillParams &params, const std::string &id)
static arondto::NavigatingSkillParams DefaultSkillDescription()
client::StopEvent moveAndWaitForStop(IssueNavigationCommandT &&issueNavigationCommand, ShouldTerminateT &&shouldTerminate)
Issues the navigation command and waits for the navigator to stop, polling shouldTerminate meanwhile.
bool shouldSkillTerminate() const override
Returns whether the skill should terminate as soon as possible.
Definition Skill.cpp:469
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:179
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:194
A result struct for skill initialization.
Definition Skill.h:50
A result struct for th main method of a skill.
Definition Skill.h:62