NavigateToLocation.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 armar-user ( armar-user at kit dot edu )
18  * @date 2021
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #include "NavigateToLocation.h"
24 
26 
30 
41 
42 //#include <ArmarXCore/core/time/TimeUtil.h>
43 //#include <ArmarXCore/observers/variant/DatafieldRef.h>
44 
46 {
47  // DO NOT EDIT NEXT LINE
48  NavigateToLocation::SubClassRegistry
49  NavigateToLocation::Registry(NavigateToLocation::GetName(),
51 
52  void
54  {
55  ARMARX_INFO << "onEnter ...";
56  // put your user code for the enter-point here
57  // execution time should be short (<100ms)
58  }
59 
60  void
62  {
63  ARMARX_IMPORTANT << "Navigating to location `" << in.getlocation() << "`";
64 
65  // parameterize the navigation stack
71 
72  // configure the `navigator` which provides a simplified and typed interface to the navigation server
73  client::IceNavigator iceNavigator(getNavigator());
74 
75  armem::client::MemoryNameSystem mns(getMemoryNameSystem());
76 
77  client::MemoryPolling memoryEventPolling(GetName(), mns);
78 
79  // register our config
80  ARMARX_INFO << "Registering config";
81  iceNavigator.createConfig(cfg, GetName());
82 
84  .navigator = &iceNavigator, .subscriber = &memoryEventPolling}};
85 
86  ARMARX_CHECK_NOT_EMPTY(in.getlocation());
87 
88  // execute
89  ARMARX_INFO << "Sending navigation request";
90  navigator.moveToLocation(in.getlocation());
91 
92  // Wait until goal is reached
93  ARMARX_INFO << "Waiting until goal is reached.";
94  client::StopEvent se = navigator.waitForStop();
95  if (se)
96  {
97  ARMARX_INFO << "Goal `" << in.getlocation() << "`reached.";
98  }
99  else
100  {
102  {
103  ARMARX_ERROR << "Safety stop was triggered!";
104  emitFailure();
105  }
106  else if (se.isUserAbortTriggeredEvent())
107  {
108  ARMARX_ERROR << "Aborted by user!";
109  emitFailure();
110  }
111  else if (se.isInternalErrorEvent())
112  {
113  ARMARX_ERROR << "Unknown internal error occured! "
115  emitFailure();
116  }
117  }
118 
119  emitSuccess();
120  }
121 
122  //void NavigateToLocation::onBreak()
123  //{
124  // // put your user code for the breaking point here
125  // // execution time should be short (<100ms)
126  //}
127 
128  void
130  {
131  // put your user code for the exit point here
132  // execution time should be short (<100ms)
133  }
134 
135 
136  // DO NOT EDIT NEXT FUNCTION
139  {
140  return XMLStateFactoryBasePtr(new NavigateToLocation(stateData));
141  }
142 
143 } // namespace armarx::navigation::statecharts::navigation_group
armarx::navigation::statecharts::navigation_group::NavigateToLocation::onEnter
void onEnter() override
Definition: NavigateToLocation.cpp:53
armarx::navigation::global_planning::AStarParams
Parameters for AStar.
Definition: AStar.h:35
Navigator.h
armarx::navigation::client::Navigator
Definition: Navigator.h:115
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::navigation::client::Navigator::InjectedServices
Definition: Navigator.h:119
armarx::navigation::traj_ctrl::local::TrajectoryFollowingControllerParams
Definition: TrajectoryFollowingController.h:35
types.h
TrajectoryController.h
armarx::navigation::statecharts::navigation_group
This file is part of ArmarX.
Definition: NavigateRelative.cpp:39
armarx::navigation::client::StopEvent::isInternalErrorEvent
bool isInternalErrorEvent() const
Definition: Navigator.h:88
armarx::navigation::client::StopEvent::toInternalErrorEvent
core::InternalErrorEvent & toInternalErrorEvent()
Definition: Navigator.h:94
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
MemoryPolling.h
ARMARX_CHECK_NOT_EMPTY
#define ARMARX_CHECK_NOT_EMPTY(c)
Definition: ExpressionException.h:224
MemoryNameSystem.h
armarx::navigation::client::NavigationStackConfig
Definition: NavigationStackConfig.h:55
armarx::navigation::client::IceNavigator
Definition: IceNavigator.h:17
armarx::navigation::client::Navigator::InjectedServices::navigator
core::NavigatorInterface * navigator
Definition: Navigator.h:121
armarx::navigation::client::NavigationStackConfig::globalPlanner
NavigationStackConfig & globalPlanner(const global_planning::GlobalPlannerParams &params)
Definition: NavigationStackConfig.cpp:63
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::navigation::client::StopEvent
Definition: Navigator.h:42
armarx::navigation::client::StopEvent::isUserAbortTriggeredEvent
bool isUserAbortTriggeredEvent() const
Definition: Navigator.h:76
armarx::navigation::client::StopEvent::isSafetyStopTriggeredEvent
bool isSafetyStopTriggeredEvent() const
Definition: Navigator.h:64
NavigationStackConfig.h
ManagedIceObject.h
PathBuilder.h
FramedPose.h
NavigateToLocation.h
IceNavigator.h
TrajectoryFollowingController.h
SimpleEventHandler.h
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::navigation::statecharts::navigation_group::NavigateToLocation::Registry
static SubClassRegistry Registry
Definition: NavigateToLocation.h:47
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::navigation::client::MemoryPolling
Definition: MemoryPolling.h:24
armarx::navigation::client::IceNavigator::createConfig
void createConfig(const client::NavigationStackConfig &config, const std::string &configId)
Definition: IceNavigator.cpp:45
armarx::navigation::statecharts::navigation_group::NavigateToLocation::onExit
void onExit() override
Definition: NavigateToLocation.cpp:129
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
armarx::navigation::core::InternalErrorEvent::message
std::string message
Definition: events.h:104
MemoryNameSystem.h
armarx::navigation::statecharts::navigation_group::NavigateToLocation::NavigateToLocation
NavigateToLocation(const XMLStateConstructorParams &stateData)
Definition: NavigateToLocation.h:33
armarx::navigation::client::GeneralConfig
Definition: NavigationStackConfig.h:42
armarx::navigation::statecharts::navigation_group::NavigateToLocation::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: NavigateToLocation.cpp:138
armarx::navigation::client::NavigationStackConfig::trajectoryController
NavigationStackConfig & trajectoryController(const traj_ctrl::local::TrajectoryControllerParams &params)
Definition: NavigationStackConfig.cpp:91
armarx::navigation::statecharts::navigation_group::NavigateToLocation::run
void run() override
Definition: NavigateToLocation.cpp:61
armarx::navigation::client::NavigationStackConfig::general
NavigationStackConfig & general(const GeneralConfig &cfg)
Definition: NavigationStackConfig.cpp:56
AStar.h