NavigateRelative.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package navigation::NavigationGroup
17 * @author Fabian Reister ( fabian dot reister at kit dot edu )
18 * @date 2022
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#include "NavigateRelative.h"
24
28
38
40{
41 // DO NOT EDIT NEXT LINE
42 NavigateRelative::SubClassRegistry
44
45 void
47 {
48 // put your user code for the enter-point here
49 // execution time should be short (<100ms)
50 }
51
52 void
54 {
55 const core::Pose relativeTarget(in.getrelativePose()->toEigen());
56
57 ARMARX_INFO << "moving to relative target " << VAROUT(relativeTarget.matrix());
58
59 // parameterize the navigation stack
61 cfg.general(core::GeneralConfig{}); //TODO: set velocity limits
63
64 // configure the `navigator` which provides a simplified and typed interface to the navigation server
65 client::IceNavigatorFactory iceNavigatorFactory(getNavigator());
66
67 armem::client::MemoryNameSystem mns(getMemoryNameSystem());
68
69 client::MemoryPolling memoryEventPolling(GetName(), mns);
70
71 // register our config
72 ARMARX_INFO << "Registering config";
73 client::NavigatorHandlePtr iceNavigator = iceNavigatorFactory.createConfig(cfg, GetName());
74
76 .navigator = iceNavigator.get(), .subscriber = &memoryEventPolling}};
77
78 // execute
79 ARMARX_INFO << "Sending navigation request";
80 navigator.moveTo(relativeTarget, core::NavigationFrame::Relative);
81
82 // Wait until goal is reached
83 ARMARX_INFO << "Waiting until goal is reached.";
84 client::StopEvent se = navigator.waitForStop();
85 if (se)
86 {
87 ARMARX_INFO << "Goal " << QUOTED(relativeTarget.matrix()) << "reached.";
88 }
89 else
90 {
92 {
93 ARMARX_ERROR << "Safety stop was triggered!";
94 emitFailure();
95 }
96 else if (se.isUserAbortTriggeredEvent())
97 {
98 ARMARX_ERROR << "Aborted by user!";
99 emitFailure();
100 }
101 else if (se.isInternalErrorEvent())
102 {
103 ARMARX_ERROR << "Unknown internal error occured! "
105 emitFailure();
106 }
107 }
108
109 emitSuccess();
110 }
111
112 //void NavigateRelative::onBreak()
113 //{
114 // // put your user code for the breaking point here
115 // // execution time should be short (<100ms)
116 //}
117
118 void
120 {
121 // put your user code for the exit point here
122 // execution time should be short (<100ms)
123 }
124
125 // DO NOT EDIT NEXT FUNCTION
128 {
129 return {new NavigateRelative(stateData)};
130 }
131} // namespace armarx::navigation::statecharts::navigation_group
#define VAROUT(x)
#define QUOTED(x)
The memory name system (MNS) client.
NavigatorHandlePtr createConfig(const client::NavigationStackConfig &config, const std::string &configId) override
Create a Config object.
NavigationStackConfig & globalPlanner(const global_planning::GlobalPlannerParams &params)
NavigationStackConfig & general(const core::GeneralConfig &cfg)
core::InternalErrorEvent & toInternalErrorEvent()
Definition Navigator.h:95
NavigateRelative(const XMLStateConstructorParams &stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
std::unique_ptr< core::NavigatorInterface > NavigatorHandlePtr
Eigen::Isometry3f Pose
Definition basic_types.h:31
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64