NavigateTo.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 Markus Grotz ( Markus Grotz <markus dot grotz 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 "NavigateTo.h"
24 
25 #include <Eigen/Geometry>
26 
28 
32 
42 
43 
44 //#include <ArmarXCore/core/time/TimeUtil.h>
45 //#include <ArmarXCore/observers/variant/DatafieldRef.h>
46 
48 {
49  // DO NOT EDIT NEXT LINE
50  NavigateTo::SubClassRegistry NavigateTo::Registry(NavigateTo::GetName(),
52 
53  void
55  {
56  // put your user code for the enter-point here
57  // execution time should be short (<100ms)
58  }
59 
60  void
62  {
63  const auto v = in.getTargetPosition();
64 
65 
66  ARMARX_INFO << VAROUT(v);
67 
69  target.linear() = Eigen::AngleAxisf(v->z, Eigen::Vector3f::UnitZ()).toRotationMatrix();
70  target.translation().head<2>() = Eigen::Vector2f(v->x, v->y);
71 
72  ARMARX_INFO << "moving to target " << VAROUT(target.matrix());
73 
74  // parameterize the navigation stack
80 
81  // configure the `navigator` which provides a simplified and typed interface to the navigation server
82  client::IceNavigator iceNavigator(getNavigator());
83 
84  armem::client::MemoryNameSystem mns(getMemoryNameSystem());
85 
86  client::MemoryPolling memoryEventPolling(GetName(), mns);
87 
88  // register our config
89  ARMARX_INFO << "Registering config";
90  iceNavigator.createConfig(cfg, GetName());
91 
93  .navigator = &iceNavigator, .subscriber = &memoryEventPolling}};
94 
95  // assemble the path, which might consist of waypoints and a goal (the goal is just the last `waypoint`)
96 
97  // execute
98  ARMARX_INFO << "Sending navigation request";
99  navigator.moveTo(target, core::NavigationFrame::Absolute);
100 
101  // Wait until goal is reached
102  ARMARX_INFO << "Waiting until goal is reached.";
103  client::StopEvent se = navigator.waitForStop();
104  if (se)
105  {
106  ARMARX_INFO << "Goal `" << in.getTargetPosition() << "`reached.";
107  }
108  else
109  {
111  {
112  ARMARX_ERROR << "Safety stop was triggered!";
113  emitFailure();
114  }
115  else if (se.isUserAbortTriggeredEvent())
116  {
117  ARMARX_ERROR << "Aborted by user!";
118  emitFailure();
119  }
120  else if (se.isInternalErrorEvent())
121  {
122  ARMARX_ERROR << "Unknown internal error occured! "
124  emitFailure();
125  }
126  }
127 
128  emitSuccess();
129  }
130 
131  //void NavigateTo::onBreak()
132  //{
133  // // put your user code for the breaking point here
134  // // execution time should be short (<100ms)
135  //}
136 
137  void
139  {
140  // put your user code for the exit point here
141  // execution time should be short (<100ms)
142  }
143 
144 
145  // DO NOT EDIT NEXT FUNCTION
148  {
149  return XMLStateFactoryBasePtr(new NavigateTo(stateData));
150  }
151 } // namespace armarx::navigation::statecharts::navigation_group
SPFA.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
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:688
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
armarx::navigation::statecharts::navigation_group::NavigateTo::run
void run() override
Definition: NavigateTo.cpp:61
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::navigation::statecharts::navigation_group::NavigateTo::onEnter
void onEnter() override
Definition: NavigateTo.cpp:54
armarx::navigation::core::NavigationFrame::Absolute
@ Absolute
armarx::navigation::client::StopEvent
Definition: Navigator.h:42
armarx::navigation::client::StopEvent::isUserAbortTriggeredEvent
bool isUserAbortTriggeredEvent() const
Definition: Navigator.h:76
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::navigation::client::StopEvent::isSafetyStopTriggeredEvent
bool isSafetyStopTriggeredEvent() const
Definition: Navigator.h:64
NavigationStackConfig.h
ManagedIceObject.h
PathBuilder.h
armarx::navigation::statecharts::navigation_group::NavigateTo::NavigateTo
NavigateTo(const XMLStateConstructorParams &stateData)
Definition: NavigateTo.h:32
FramedPose.h
IceNavigator.h
TrajectoryFollowingController.h
SimpleEventHandler.h
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
NavigateTo.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::navigation::client::MemoryPolling
Definition: MemoryPolling.h:24
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
armarx::navigation::statecharts::navigation_group::NavigateTo::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: NavigateTo.cpp:147
MemoryNameSystem.h
armarx::navigation::client::GeneralConfig
Definition: NavigationStackConfig.h:42
armarx::navigation::global_planning::SPFAParams
Parameters for AStar.
Definition: SPFA.h:41
armarx::navigation::statecharts::navigation_group::NavigateTo::onExit
void onExit() override
Definition: NavigateTo.cpp:138
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
armarx::navigation::statecharts::navigation_group::NavigateTo::Registry
static SubClassRegistry Registry
Definition: NavigateTo.h:45