GlobalPlanner.h
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 * @author Christian R. G. Dreher ( c dot dreher 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#pragma once
24
25#include <map>
26#include <memory>
27#include <optional>
28#include <string>
29
32
38
40{
41
43 {
45
46 /**
47 * Optional helper trajectory that can be used for visualization or debugging purposes.
48 * It is not meant to be executed by the robot.
49 * This can be helpful when using some indermediate trajectory representations for the planning that should also be visualized.
50 */
51 std::optional<core::GlobalTrajectory> helperTrajectory;
52
53 /**
54 * Wall-clock duration [s] of each stage of the planning pipeline, keyed by stage name.
55 * Empty for planners that are not instrumented.
56 */
57 std::map<std::string, float> timings{};
58
59 /**
60 * The raw path as it came out of the grid search, before resampling, smoothing and
61 * orientation optimization. Cell centres, so it is a staircase. For visualization and
62 * debugging only; empty for planners that do not search a grid.
63 */
65
66 /**
67 * Whether the position smoothing stage ran *and* its result was adopted. False when the
68 * stage was disabled, or when it produced a trajectory that still had collisions and the
69 * unsmoothed path was kept instead — which is not otherwise visible in the result.
70 */
72
73 /**
74 * Why the position smoothing stage ended the way it did.
75 *
76 * `positionSmoothingApplied` alone cannot distinguish a result rejected for residual
77 * collisions from one rejected for folding back on itself, and the two call for
78 * different fixes. Populated by planners that smooth; left at its defaults otherwise.
79 */
81 {
82 /// The stage ran at all (i.e. was enabled and the trajectory was long enough).
83 bool ran{false};
84
85 /// The smoothed path passed the collision check.
86 bool collisionFree{false};
87
88 /// The smoothed path was free of folds and degenerate segments.
89 bool geometryValid{true};
90
91 /// Waypoints dropped to repair a fold. Non-zero implies the path did fold, even
92 /// when `geometryValid` ends up true because the repair succeeded.
93 std::size_t repairedWaypoints{0};
94
95 /**
96 * Sharpest direction change [deg] in the trajectory *handed to* the smoother.
97 *
98 * Without it the only turn measurable from outside is the one in the returned
99 * path, which is the smoothed path when smoothing succeeded and the unsmoothed
100 * one when it did not -- two different things, so comparing them across the
101 * accept/reject split says nothing. This is the same quantity for both.
102 */
104
105 /// Number of places the rejected smoothed path fell below the clearance.
106 std::size_t collisions{0};
107
108 /**
109 * Of those, how many were at a commanded endpoint or on the segment adjoining it.
110 *
111 * The optimizer holds the start and goal fixed -- the start is where the robot is
112 * and the goal is what was asked for -- so a violation there is not something it
113 * could have avoided. Counted apart so a rejection rate can distinguish a path the
114 * smoother got wrong from a request it was never able to satisfy.
115 */
116 std::size_t endpointCollisions{0};
117
118 /// Worst clearance found at any violating sample [mm].
120
121 /// Smallest clearance [mm] on the path handed to the smoother, and on its result.
123
125
126 /// The input was already inside the limit, so the result was judged against it.
128 };
129
131 };
132
133 /**
134 * @brief Parameters for GlobalPlanner
135 *
136 */
138 {
139 bool foo;
140
141 virtual ~GlobalPlannerParams() = default;
142
143 virtual Algorithms algorithm() const = 0;
144 virtual aron::data::DictPtr toAron() const = 0;
145 };
146
147 /**
148 * @class GlobalPlanner
149 * @ingroup Library-GlobalPlanner
150 *
151 * Base class of all global planners
152 */
154 {
155 public:
157 virtual ~GlobalPlanner() = default;
158
159 virtual std::optional<GlobalPlannerResult> plan(const core::Pose& goal) = 0;
160 virtual std::optional<GlobalPlannerResult> plan(const core::Pose& start,
161 const core::Pose& goal) = 0;
162
163 virtual void
165 const std::string& vizLayerNamePrefix = "global_planner_debug") {
166 // Default: Do nothing
167 };
168
169 protected:
172
173 private:
174 };
175
176 using GlobalPlannerPtr = std::shared_ptr<GlobalPlanner>;
177} // namespace armarx::navigation::global_planning
GlobalPlanner(const core::GeneralConfig &generalConfig, const core::Scene &scene)
virtual std::optional< GlobalPlannerResult > plan(const core::Pose &goal)=0
virtual void visualizeDebugInfo(viz::Client &vizClient, const std::string &vizLayerNamePrefix="global_planner_debug")
virtual std::optional< GlobalPlannerResult > plan(const core::Pose &start, const core::Pose &goal)=0
std::shared_ptr< Dict > DictPtr
Definition Dict.h:42
std::vector< Position > Positions
Definition basic_types.h:37
Eigen::Isometry3f Pose
Definition basic_types.h:31
This file is part of ArmarX.
Definition fwd.h:30
std::shared_ptr< GlobalPlanner > GlobalPlannerPtr
Definition fwd.h:32
virtual aron::data::DictPtr toAron() const =0
Why the position smoothing stage ended the way it did.
std::size_t repairedWaypoints
Waypoints dropped to repair a fold.
float inputSharpestTurnDeg
Sharpest direction change [deg] in the trajectory handed to the smoother.
bool ran
The stage ran at all (i.e. was enabled and the trajectory was long enough).
std::size_t endpointCollisions
Of those, how many were at a commanded endpoint or on the segment adjoining it.
float worstCollisionClearance
Worst clearance found at any violating sample [mm].
bool judgedAgainstInput
The input was already inside the limit, so the result was judged against it.
std::size_t collisions
Number of places the rejected smoothed path fell below the clearance.
bool geometryValid
The smoothed path was free of folds and degenerate segments.
bool collisionFree
The smoothed path passed the collision check.
float inputMinClearance
Smallest clearance [mm] on the path handed to the smoother, and on its result.
bool positionSmoothingApplied
Whether the position smoothing stage ran and its result was adopted.
std::map< std::string, float > timings
Wall-clock duration [s] of each stage of the planning pipeline, keyed by stage name.
core::Positions gridPath
The raw path as it came out of the grid search, before resampling, smoothing and orientation optimiza...
std::optional< core::GlobalTrajectory > helperTrajectory
Optional helper trajectory that can be used for visualization or debugging purposes.