NavigateToWithObstacleAvoidance.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  * @author Fabian Reister ( fabian dot reister at kit dot edu )
17  * @date 2023
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
23 
24 #include <Eigen/Geometry>
25 
28 
32 
44 
45 //#include <ArmarXCore/core/time/TimeUtil.h>
46 //#include <ArmarXCore/observers/variant/DatafieldRef.h>
47 
49 {
50  // DO NOT EDIT NEXT LINE
51  NavigateToWithObstacleAvoidance::SubClassRegistry
52  NavigateToWithObstacleAvoidance::Registry(NavigateToWithObstacleAvoidance::GetName(),
54 
55  void
57  {
58  // put your user code for the enter-point here
59  // execution time should be short (<100ms)
60  }
61 
62  void
64  {
65  const auto v = in.getTargetPosition();
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 \n" << VAROUT(target.matrix());
73 
75 
76  if (in.isMaxAngularVelocitySet())
77  {
78  globalPlannerParams.angularVelocity = in.getMaxAngularVelocity();
79  }
80 
81  if (in.isMaxLinearVelocitySet())
82  {
83  globalPlannerParams.linearVelocity = in.getMaxLinearVelocity();
84  }
85 
86  if (in.isRotateIntoMovementDirectionSet())
87  {
88  if (not in.getRotateIntoMovementDirection())
89  {
90  ARMARX_INFO << "Will not rotate into movement direction.";
91  globalPlannerParams.optimizerParams.iterations = 1;
92  globalPlannerParams.optimizerParams.movementDirWeightStart = 0.F;
93  globalPlannerParams.optimizerParams.movementDirWeightEnd = 0.F;
94  }
95  }
96  else
97  {
98  globalPlannerParams.optimizerParams.iterations = 1;
99  globalPlannerParams.optimizerParams.movementDirWeightStart = 0.F;
100  globalPlannerParams.optimizerParams.movementDirWeightEnd = 10.F;
101  }
102 
103  if (in.isOrientationOptimizationSmoothnessWeightSet())
104  {
105  ARMARX_CHECK_GREATER_EQUAL(in.getOrientationOptimizationSmoothnessWeight(), 0);
106  globalPlannerParams.optimizerParams.smoothnessWeight =
107  in.getOrientationOptimizationSmoothnessWeight();
108  }
109 
110  if (in.isPredefinedRotationDirectionSet())
111  {
113  ARMARX_INFO << "Using predefined rotation direction: "
114  << (in.getPredefinedRotationDirection() ? "Clockwise" : "CounterClockwise");
115  globalPlannerParams.optimizerParams.predefinedRotationDirection =
116  in.getPredefinedRotationDirection() ? RotationDirection::Clockwise
117  : RotationDirection::CounterClockwise;
118  }
119 
120 
121  // parameterize the navigation stack
124  cfg.globalPlanner(globalPlannerParams);
125 
126  if (in.getUseLocalPlanner())
127  {
129  }
130 
132 
133  // configure the `navigator` which provides a simplified and typed interface to the navigation server
134  client::IceNavigator iceNavigator(getNavigator());
135 
136  armem::client::MemoryNameSystem mns(getMemoryNameSystem());
137 
138  client::MemoryPolling memoryEventPolling(GetName(), mns);
139 
140  // register our config
141  ARMARX_INFO << "Registering config";
142  iceNavigator.createConfig(cfg, GetName());
143 
145  .navigator = &iceNavigator, .subscriber = &memoryEventPolling}};
146 
147  // assemble the path, which might consist of waypoints and a goal (the goal is just the last `waypoint`)
148 
149  // execute
150  ARMARX_INFO << "Sending navigation request";
151  navigator.moveTo(target, core::NavigationFrame::Absolute);
152 
153  // Wait until goal is reached
154  ARMARX_INFO << "Waiting until goal is reached.";
155  client::StopEvent se = navigator.waitForStop();
156  if (se)
157  {
158  ARMARX_INFO << "Goal `" << in.getTargetPosition() << "`reached.";
159  }
160  else
161  {
163  {
164  ARMARX_ERROR << "Safety stop was triggered!";
165  emitFailure();
166  }
167  else if (se.isUserAbortTriggeredEvent())
168  {
169  ARMARX_ERROR << "Aborted by user!";
170  emitFailure();
171  }
172  else if (se.isInternalErrorEvent())
173  {
174  ARMARX_ERROR << "Unknown internal error occured! "
176  emitFailure();
177  }
178  }
179 
180  emitSuccess();
181  }
182 
183  //void NavigateToWithObstacleAvoidance::onBreak()
184  //{
185  // // put your user code for the breaking point here
186  // // execution time should be short (<100ms)
187  //}
188 
189  void
191  {
192  // put your user code for the exit point here
193  // execution time should be short (<100ms)
194  }
195 
196  // DO NOT EDIT NEXT FUNCTION
199  {
201  }
202 } // 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
OrientationOptimizer.h
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
armarx::navigation::global_planning::optimization::OrientationOptimizerParams::movementDirWeightEnd
float movementDirWeightEnd
Definition: OrientationOptimizer.h:41
TimedElasticBandsParams.h
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::NavigateToWithObstacleAvoidance::NavigateToWithObstacleAvoidance
NavigateToWithObstacleAvoidance(const XMLStateConstructorParams &stateData)
Definition: NavigateToWithObstacleAvoidance.h:32
armarx::navigation::global_planning::SPFAParams::optimizerParams
optimization::OrientationOptimizerParams optimizerParams
Definition: SPFA.h:55
IceInternal::Handle
Definition: forward_declarations.h:8
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::global_planning::optimization::OrientationOptimizerParams::iterations
int iterations
Definition: OrientationOptimizer.h:39
armarx::navigation::client::StopEvent::isSafetyStopTriggeredEvent
bool isSafetyStopTriggeredEvent() const
Definition: Navigator.h:64
NavigationStackConfig.h
ManagedIceObject.h
PathBuilder.h
FramedPose.h
armarx::navigation::local_planning::TimedElasticBandsParams
Definition: TimedElasticBandsParams.h:35
armarx::navigation::global_planning::optimization::OrientationOptimizerParams::movementDirWeightStart
float movementDirWeightStart
Definition: OrientationOptimizer.h:40
NavigateToWithObstacleAvoidance.h
IceNavigator.h
armarx::navigation::global_planning::SPFAParams::angularVelocity
float angularVelocity
Definition: SPFA.h:44
TrajectoryFollowingController.h
armarx::navigation::statecharts::navigation_group::NavigateToWithObstacleAvoidance::onEnter
void onEnter() override
Definition: NavigateToWithObstacleAvoidance.cpp:56
armarx::navigation::statecharts::navigation_group::NavigateToWithObstacleAvoidance::Registry
static SubClassRegistry Registry
Definition: NavigateToWithObstacleAvoidance.h:45
SimpleEventHandler.h
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
ARMARX_CHECK_GREATER_EQUAL
#define ARMARX_CHECK_GREATER_EQUAL(lhs, rhs)
This macro evaluates whether lhs is greater or equal (>=) rhs and if it turns out to be false it will...
Definition: ExpressionException.h:123
ExpressionException.h
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
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::navigation::client::MemoryPolling
Definition: MemoryPolling.h:24
armarx::navigation::global_planning::optimization::OrientationOptimizerParams::predefinedRotationDirection
std::optional< RotationDirection > predefinedRotationDirection
Definition: OrientationOptimizer.h:51
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::navigation::global_planning::SPFAParams::linearVelocity
float linearVelocity
Definition: SPFA.h:43
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
armarx::navigation::statecharts::navigation_group::NavigateToWithObstacleAvoidance::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: NavigateToWithObstacleAvoidance.cpp:198
armarx::navigation::statecharts::navigation_group::NavigateToWithObstacleAvoidance::onExit
void onExit() override
Definition: NavigateToWithObstacleAvoidance.cpp:190
armarx::navigation::core::InternalErrorEvent::message
std::string message
Definition: events.h:104
MemoryNameSystem.h
armarx::navigation::client::NavigationStackConfig::localPlanner
NavigationStackConfig & localPlanner(const local_planning::LocalPlannerParams &params)
Definition: NavigationStackConfig.cpp:77
armarx::navigation::global_planning::optimization::RotationDirection
RotationDirection
Definition: OrientationOptimizer.h:31
armarx::navigation::global_planning::optimization::OrientationOptimizerParams::smoothnessWeight
float smoothnessWeight
Definition: OrientationOptimizer.h:43
armarx::navigation::client::GeneralConfig
Definition: NavigationStackConfig.h:42
armarx::navigation::statecharts::navigation_group::NavigateToWithObstacleAvoidance::run
void run() override
Definition: NavigateToWithObstacleAvoidance.cpp:63
armarx::navigation::global_planning::SPFAParams
Parameters for AStar.
Definition: SPFA.h:41
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