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
43  NavigateRelative::Registry(NavigateRelative::GetName(), &NavigateRelative::CreateInstance);
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
65 
66  // configure the `navigator` which provides a simplified and typed interface to the navigation server
67  client::IceNavigator iceNavigator(getNavigator());
68 
69  armem::client::MemoryNameSystem mns(getMemoryNameSystem());
70 
71  client::MemoryPolling memoryEventPolling(GetName(), mns);
72 
73  // register our config
74  ARMARX_INFO << "Registering config";
75  iceNavigator.createConfig(cfg, GetName());
76 
78  .navigator = &iceNavigator, .subscriber = &memoryEventPolling}};
79 
80  // execute
81  ARMARX_INFO << "Sending navigation request";
82  navigator.moveTo(relativeTarget, core::NavigationFrame::Relative);
83 
84  // Wait until goal is reached
85  ARMARX_INFO << "Waiting until goal is reached.";
86  client::StopEvent se = navigator.waitForStop();
87  if (se)
88  {
89  ARMARX_INFO << "Goal `" << relativeTarget.matrix() << "`reached.";
90  }
91  else
92  {
94  {
95  ARMARX_ERROR << "Safety stop was triggered!";
96  emitFailure();
97  }
98  else if (se.isUserAbortTriggeredEvent())
99  {
100  ARMARX_ERROR << "Aborted by user!";
101  emitFailure();
102  }
103  else if (se.isInternalErrorEvent())
104  {
105  ARMARX_ERROR << "Unknown internal error occured! "
107  emitFailure();
108  }
109  }
110 
111  emitSuccess();
112  }
113 
114  //void NavigateRelative::onBreak()
115  //{
116  // // put your user code for the breaking point here
117  // // execution time should be short (<100ms)
118  //}
119 
120  void
122  {
123  // put your user code for the exit point here
124  // execution time should be short (<100ms)
125  }
126 
127 
128  // DO NOT EDIT NEXT FUNCTION
131  {
132  return {new NavigateRelative(stateData)};
133  }
134 } // namespace armarx::navigation::statecharts::navigation_group
armarx::navigation::statecharts::navigation_group::NavigateRelative::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: NavigateRelative.cpp:130
NavigateRelative.h
Navigator.h
armarx::navigation::client::Navigator
Definition: Navigator.h:115
armarx::navigation::client::Navigator::InjectedServices
Definition: Navigator.h:119
armarx::navigation::traj_ctrl::local::TrajectoryFollowingControllerParams
Definition: TrajectoryFollowingController.h:35
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
types.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
armarx::navigation::statecharts::navigation_group::NavigateRelative::run
void run() override
Definition: NavigateRelative.cpp:53
MemoryPolling.h
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
Point2Point.h
armarx::navigation::statecharts::navigation_group::NavigateRelative::NavigateRelative
NavigateRelative(const XMLStateConstructorParams &stateData)
Definition: NavigateRelative.h:32
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
PathBuilder.h
FramedPose.h
IceNavigator.h
TrajectoryFollowingController.h
armarx::navigation::statecharts::navigation_group::NavigateRelative::onEnter
void onEnter() override
Definition: NavigateRelative.cpp:46
SimpleEventHandler.h
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::navigation::client::MemoryPolling
Definition: MemoryPolling.h:24
armarx::navigation::global_planning::Point2PointParams
Parameters for Point2Point.
Definition: Point2Point.h:35
armarx::navigation::core::NavigationFrame::Relative
@ Relative
VAROUT
#define VAROUT(x)
Definition: StringHelpers.h:182
armarx::navigation::client::IceNavigator::createConfig
void createConfig(const client::NavigationStackConfig &config, const std::string &configId)
Definition: IceNavigator.cpp:45
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::NavigateRelative::Registry
static SubClassRegistry Registry
Definition: NavigateRelative.h:45
armarx::navigation::client::GeneralConfig
Definition: NavigationStackConfig.h:42
armarx::navigation::statecharts::navigation_group::NavigateRelative::onExit
void onExit() override
Definition: NavigateRelative.cpp:121
armarx::navigation::client::NavigationStackConfig::trajectoryController
NavigationStackConfig & trajectoryController(const traj_ctrl::local::TrajectoryControllerParams &params)
Definition: NavigationStackConfig.cpp:91
armarx::navigation::client::NavigationStackConfig::general
NavigationStackConfig & general(const GeneralConfig &cfg)
Definition: NavigationStackConfig.cpp:56