SPFA.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 <optional>
26#include <vector>
27
29
38
39#include "GlobalPlanner.h"
40
42{
43
44 /**
45 * @brief Parameters for AStar
46 *
47 */
49 {
50
52
54
56
57 /**
58 * Diagnostic switches for the post-processing stages. They are deliberately not part of
59 * the Aron (de-)serialization: they exist to bisect the pipeline from tools such as the
60 * `global_planning_analysis` application, not to be configured on the robot.
61 */
62 /// Run the SPFA position smoothing on the resampled path.
64
65 /**
66 * Re-apply the obstacle-aware velocity limit after orientation optimization.
67 *
68 * Disabling this exposes the velocities as the earlier stages left them, which is the
69 * only way to observe whether a stage produced a trajectory that violates the limit.
70 */
72
73 Algorithms algorithm() const override;
74 aron::data::DictPtr toAron() const override;
75
76 static SPFAParams FromAron(const aron::data::DictPtr& dict);
77 };
78
79 // Helper class
81 {
84 std::optional<algorithms::spfa::ShortestPathFasterAlgorithm::Result> plan;
85
86 /// Duration [s] of the SPFA grid search itself, which runs before `calculatePath`.
88 };
89
90 /**
91 * @brief Information about collision recovery
92 *
93 * When the robot starts in collision, this contains information about
94 * the recovery position and the original (collision) start pose.
95 */
97 {
98 core::Pose originalStartPose; ///< The original start pose (collision pose)
99 Eigen::Vector2f recoveryPosition; ///< The found recovery position (collision-free)
100 };
101
102 class SPFA;
103
105 {
106 public:
107 friend class SPFA;
110
111 SPFAImpl(const Params& params,
112 const core::GeneralConfig& generalParams,
113 const std::optional<navigation::algorithms::Costmap>& costmap);
114
115 void updateCostmap(const std::optional<navigation::algorithms::Costmap>& costmap);
116
117 std::optional<GlobalPlannerResult> plan(const core::Pose& start, const core::Pose& goal);
118
120 PlanningResult executePlannerFromPosition(const Eigen::Vector2f& startPosition);
121 std::optional<GlobalPlannerResult>
122 calculatePath(const PlanningResult& planner,
123 const core::Pose& goal,
124 const std::optional<RecoveryInfo>& recovery = std::nullopt);
125
126 /// The obstacle-aware velocity limit this planner applies, for the current costmap.
128
129 protected:
130 std::vector<Eigen::Vector2f> postProcessPath(const std::vector<Eigen::Vector2f>& path);
131
132 private:
133 Params params_;
134 core::GeneralConfig generalConfig_;
135 std::optional<navigation::algorithms::Costmap> costmap_;
136 };
137
138 /**
139 * @class AStar
140 * @ingroup Library-GlobalPlanner
141 *
142 * Implements the A* algorithm
143 */
144 class SPFA : public GlobalPlanner
145 {
146 public:
149
150 SPFA(const Params& params,
151 const core::GeneralConfig& generalParams,
152 const core::Scene& ctx);
153 ~SPFA() override = default;
154
155 std::optional<GlobalPlannerResult> plan(const core::Pose& goal) override;
156 std::optional<GlobalPlannerResult> plan(const core::Pose& start,
157 const core::Pose& goal) override;
158
160 std::optional<GlobalPlannerResult> calculatePath(const PlanningResult& planner,
161 const core::Pose& goal);
162
163 private:
164 SPFAImpl impl_;
165 };
166
167} // namespace armarx::navigation::global_planning
The maximum permissible linear velocity as a function of the distance to the closest obstacle.
GlobalPlanner(const core::GeneralConfig &generalConfig, const core::Scene &scene)
::armarx::navigation::global_planning::PlanningResult PlanningResult
Definition SPFA.h:109
void updateCostmap(const std::optional< navigation::algorithms::Costmap > &costmap)
Definition SPFA.cpp:226
std::optional< GlobalPlannerResult > plan(const core::Pose &start, const core::Pose &goal)
Definition SPFA.cpp:253
SPFAImpl(const Params &params, const core::GeneralConfig &generalParams, const std::optional< navigation::algorithms::Costmap > &costmap)
Definition SPFA.cpp:218
PlanningResult executePlannerFromPosition(const Eigen::Vector2f &startPosition)
Definition SPFA.cpp:382
PlanningResult executePlanner(const core::Pose &start)
Definition SPFA.cpp:338
std::vector< Eigen::Vector2f > postProcessPath(const std::vector< Eigen::Vector2f > &path)
Definition SPFA.cpp:791
std::optional< GlobalPlannerResult > calculatePath(const PlanningResult &planner, const core::Pose &goal, const std::optional< RecoveryInfo > &recovery=std::nullopt)
Definition SPFA.cpp:390
algorithms::ObstacleAwareVelocityLimit velocityLimit() const
The obstacle-aware velocity limit this planner applies, for the current costmap.
Definition SPFA.cpp:239
::armarx::navigation::global_planning::PlanningResult PlanningResult
Definition SPFA.h:148
std::optional< GlobalPlannerResult > calculatePath(const PlanningResult &planner, const core::Pose &goal)
Definition SPFA.cpp:211
std::optional< GlobalPlannerResult > plan(const core::Pose &goal) override
Definition SPFA.cpp:188
PlanningResult executePlanner(const core::Pose &start)
Definition SPFA.cpp:205
SPFA(const Params &params, const core::GeneralConfig &generalParams, const core::Scene &ctx)
Definition SPFA.cpp:176
std::shared_ptr< Dict > DictPtr
Definition Dict.h:42
Eigen::Isometry3f Pose
Definition basic_types.h:31
This file is part of ArmarX.
Definition fwd.h:30
float gridSearchDuration
Duration [s] of the SPFA grid search itself, which runs before calculatePath.
Definition SPFA.h:87
algorithms::spfa::ShortestPathFasterAlgorithm algorithm
Definition SPFA.h:83
std::optional< algorithms::spfa::ShortestPathFasterAlgorithm::Result > plan
Definition SPFA.h:84
Information about collision recovery.
Definition SPFA.h:97
Eigen::Vector2f recoveryPosition
The found recovery position (collision-free)
Definition SPFA.h:99
core::Pose originalStartPose
The original start pose (collision pose)
Definition SPFA.h:98
optimization::OrientationOptimizerParams optimizerParams
Definition SPFA.h:55
algorithms::spfa::ShortestPathFasterAlgorithm::Parameters algo
Definition SPFA.h:53
aron::data::DictPtr toAron() const override
Definition SPFA.cpp:149
static SPFAParams FromAron(const aron::data::DictPtr &dict)
Definition SPFA.cpp:159
Algorithms algorithm() const override
Definition SPFA.cpp:143
bool enableFinalVelocityClamp
Re-apply the obstacle-aware velocity limit after orientation optimization.
Definition SPFA.h:71
bool enablePositionSmoothing
Diagnostic switches for the post-processing stages.
Definition SPFA.h:63