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
37
38#include "GlobalPlanner.h"
39
41{
42
43 /**
44 * @brief Parameters for AStar
45 *
46 */
61
62 // Helper class
64 {
67 std::optional<algorithms::spfa::ShortestPathFasterAlgorithm::Result> plan;
68 };
69
70 /**
71 * @brief Information about collision recovery
72 *
73 * When the robot starts in collision, this contains information about
74 * the recovery position and the original (collision) start pose.
75 */
77 {
78 core::Pose originalStartPose; ///< The original start pose (collision pose)
79 Eigen::Vector2f recoveryPosition; ///< The found recovery position (collision-free)
80 };
81
82 class SPFA;
83
85 {
86 public:
87 friend class SPFA;
90
91 SPFAImpl(const Params& params,
92 const core::GeneralConfig& generalParams,
93 const std::optional<navigation::algorithms::Costmap>& costmap);
94
95 void updateCostmap(const std::optional<navigation::algorithms::Costmap>& costmap);
96
97 std::optional<GlobalPlannerResult> plan(const core::Pose& start, const core::Pose& goal);
98
100 PlanningResult executePlannerFromPosition(const Eigen::Vector2f& startPosition);
101 std::optional<GlobalPlannerResult>
102 calculatePath(const PlanningResult& planner,
103 const core::Pose& goal,
104 const std::optional<RecoveryInfo>& recovery = std::nullopt);
105
106 protected:
107 std::vector<Eigen::Vector2f> postProcessPath(const std::vector<Eigen::Vector2f>& path);
108
109 private:
110 Params params_;
111 core::GeneralConfig generalConfig_;
112 std::optional<navigation::algorithms::Costmap> costmap_;
113 };
114
115 /**
116 * @class AStar
117 * @ingroup Library-GlobalPlanner
118 *
119 * Implements the A* algorithm
120 */
121 class SPFA : public GlobalPlanner
122 {
123 public:
126
127 SPFA(const Params& params,
128 const core::GeneralConfig& generalParams,
129 const core::Scene& ctx);
130 ~SPFA() override = default;
131
132 std::optional<GlobalPlannerResult> plan(const core::Pose& goal) override;
133 std::optional<GlobalPlannerResult> plan(const core::Pose& start,
134 const core::Pose& goal) override;
135
137 std::optional<GlobalPlannerResult> calculatePath(const PlanningResult& planner,
138 const core::Pose& goal);
139
140 private:
141 SPFAImpl impl_;
142 };
143
144} // namespace armarx::navigation::global_planning
GlobalPlanner(const core::GeneralConfig &generalConfig, const core::Scene &scene)
::armarx::navigation::global_planning::PlanningResult PlanningResult
Definition SPFA.h:89
void updateCostmap(const std::optional< navigation::algorithms::Costmap > &costmap)
Definition SPFA.cpp:133
std::optional< GlobalPlannerResult > plan(const core::Pose &start, const core::Pose &goal)
Definition SPFA.cpp:146
SPFAImpl(const Params &params, const core::GeneralConfig &generalParams, const std::optional< navigation::algorithms::Costmap > &costmap)
Definition SPFA.cpp:125
PlanningResult executePlannerFromPosition(const Eigen::Vector2f &startPosition)
Definition SPFA.cpp:272
PlanningResult executePlanner(const core::Pose &start)
Definition SPFA.cpp:231
std::vector< Eigen::Vector2f > postProcessPath(const std::vector< Eigen::Vector2f > &path)
Definition SPFA.cpp:610
std::optional< GlobalPlannerResult > calculatePath(const PlanningResult &planner, const core::Pose &goal, const std::optional< RecoveryInfo > &recovery=std::nullopt)
Definition SPFA.cpp:280
::armarx::navigation::global_planning::PlanningResult PlanningResult
Definition SPFA.h:125
std::optional< GlobalPlannerResult > calculatePath(const PlanningResult &planner, const core::Pose &goal)
Definition SPFA.cpp:118
std::optional< GlobalPlannerResult > plan(const core::Pose &goal) override
Definition SPFA.cpp:95
PlanningResult executePlanner(const core::Pose &start)
Definition SPFA.cpp:112
SPFA(const Params &params, const core::GeneralConfig &generalParams, const core::Scene &ctx)
Definition SPFA.cpp:83
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
algorithms::spfa::ShortestPathFasterAlgorithm algorithm
Definition SPFA.h:66
std::optional< algorithms::spfa::ShortestPathFasterAlgorithm::Result > plan
Definition SPFA.h:67
Information about collision recovery.
Definition SPFA.h:77
Eigen::Vector2f recoveryPosition
The found recovery position (collision-free)
Definition SPFA.h:79
core::Pose originalStartPose
The original start pose (collision pose)
Definition SPFA.h:78
optimization::OrientationOptimizerParams optimizerParams
Definition SPFA.h:54
algorithms::spfa::ShortestPathFasterAlgorithm::Parameters algo
Definition SPFA.h:52
aron::data::DictPtr toAron() const override
Definition SPFA.cpp:56
static SPFAParams FromAron(const aron::data::DictPtr &dict)
Definition SPFA.cpp:66
Algorithms algorithm() const override
Definition SPFA.cpp:50