AStarWithOrientation.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 Niklas Arlt ( niklas dot arlt at kit dot edu )
17 * @date 2025
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <optional>
25
27
35
37{
38
39 /**
40 * @brief Parameters for AStarWithOrientation
41 *
42 */
44 {
45 bool includeStartPose{true};
46
47 Algorithms algorithm() const override;
48 aron::data::DictPtr toAron() const override;
49
51 };
52
53 // Implementation class with only the necessary interface
55 {
56 public:
58
60 const Params& params,
62 const std::optional<navigation::algorithms::orientation_aware::Costmap3D>& costmap,
64
65 void updateCostmap(const std::optional<navigation::algorithms::orientation_aware::Costmap3D>& costmap);
66
67 std::optional<GlobalPlannerResult> plan(const core::Pose& start, const core::Pose& goal);
68
69 void visualizeDebugInfo(viz::Client& vizClient,
70 const std::string& vizLayerNamePrefix = "global_planner_debug");
71
72 /**
73 * @brief Override the parameters that `plan()` otherwise loads from the package config
74 * files, for the offline planner ablation.
75 *
76 * Unset (the default) means the parameters are loaded from
77 * `algorithms/astarwithorientation.cfg` and `algorithms/orientation-aware-smoothing.cfg`
78 * exactly as before, so deployed behaviour is unchanged.
79 */
80 void
82 std::optional<algorithms::orientation_aware::io::AStarWithOrientationParams> aStar,
83 std::optional<algorithms::orientation_aware::smoothing::io::SmoothingParams> smoothing)
84 {
85 aStarParamsOverride = std::move(aStar);
86 smoothingParamsOverride = std::move(smoothing);
87 }
88
89 /// Run the Ceres smoother after A*. Enabled by default, matching deployed behaviour.
90 void
91 setSmoothingEnabled(bool enabled) noexcept
92 {
93 smoothingEnabled = enabled;
94 }
95
96 /// Nodes expanded by A* during the last `plan()` call.
97 std::size_t
98 lastExpandedNodes() const noexcept
99 {
100 return expandedNodes;
101 }
102
103 /// Wall-clock seconds spent in A* / in the smoother during the last `plan()` call.
104 double
105 lastAStarSeconds() const noexcept
106 {
107 return aStarSeconds;
108 }
109
110 double
111 lastSmootherSeconds() const noexcept
112 {
113 return smootherSeconds;
114 }
115
116 protected:
119 std::optional<navigation::algorithms::orientation_aware::Costmap3D> costmap;
121
122 private:
123 // Offline-evaluation overrides; unset means "load from the package config files".
124 std::optional<algorithms::orientation_aware::io::AStarWithOrientationParams>
125 aStarParamsOverride;
126 std::optional<algorithms::orientation_aware::smoothing::io::SmoothingParams>
127 smoothingParamsOverride;
128 bool smoothingEnabled{true};
129
130 // instrumentation from last execution
131 std::size_t expandedNodes{0};
132 double aStarSeconds{0.0};
133 double smootherSeconds{0.0};
134
135 // state from last execution
136 std::vector<core::GlobalTrajectoryPoint> lastPointsInCollision;
137 core::GlobalTrajectory lastRawTrajectory;
138 core::GlobalTrajectory lastPreprocessedTrajectory;
139 core::GlobalTrajectory lastSmoothedTrajectory;
140 /// original (in-collision) start pose of the last plan, in the costmap/planning frame
141 std::optional<core::Pose> lastRecoveryOriginalStart;
142 /// collision-free recovery target of the last plan, in the costmap/planning frame
143 std::optional<Eigen::Vector2f> lastRecoveryPosition;
144 };
145
146 /**
147 * @class AStarWithOrientation
148 * @ingroup Library-GlobalPlanner
149 *
150 * Implements an A* planner but is compatible with non-circular robots.
151 * Compared to circular robots, the orientation of non-circular robots is important to not collide with obstacles.
152 *
153 * This class is the integration class for the GlobalPanner base class.
154 */
155 class AStarWithOrientation : virtual public GlobalPlanner
156 {
157 public:
159
160 AStarWithOrientation(const Params& params,
162 const core::Scene& ctx);
163
164 std::optional<GlobalPlannerResult> plan(const core::Pose& goal) override;
165 std::optional<GlobalPlannerResult> plan(const core::Pose& start,
166 const core::Pose& goal) override;
167
169 void
171 const std::string& vizLayerNamePrefix = "global_planner_debug") override;
172
173 protected:
175 };
176
177} // namespace armarx::navigation::global_planning
void setParamOverrides(std::optional< algorithms::orientation_aware::io::AStarWithOrientationParams > aStar, std::optional< algorithms::orientation_aware::smoothing::io::SmoothingParams > smoothing)
Override the parameters that plan() otherwise loads from the package config files,...
std::size_t lastExpandedNodes() const noexcept
Nodes expanded by A* during the last plan() call.
double lastAStarSeconds() const noexcept
Wall-clock seconds spent in A* / in the smoother during the last plan() call.
std::optional< GlobalPlannerResult > plan(const core::Pose &start, const core::Pose &goal)
void updateCostmap(const std::optional< navigation::algorithms::orientation_aware::Costmap3D > &costmap)
std::optional< navigation::algorithms::orientation_aware::Costmap3D > costmap
void setSmoothingEnabled(bool enabled) noexcept
Run the Ceres smoother after A*. Enabled by default, matching deployed behaviour.
AStarWithOrientationImpl(const Params &params, const core::GeneralConfig &generalConfig, const std::optional< navigation::algorithms::orientation_aware::Costmap3D > &costmap, VirtualRobot::RobotPtr robot)
void visualizeDebugInfo(viz::Client &vizClient, const std::string &vizLayerNamePrefix="global_planner_debug")
void visualizeDebugInfo(viz::Client &vizClient, const std::string &vizLayerNamePrefix="global_planner_debug") override
std::optional< GlobalPlannerResult > plan(const core::Pose &goal) override
AStarWithOrientation(const Params &params, const core::GeneralConfig &generalConfig, const core::Scene &ctx)
GlobalPlanner(const core::GeneralConfig &generalConfig, const core::Scene &scene)
virtual void visualizeDebugInfo(viz::Client &vizClient, const std::string &vizLayerNamePrefix="global_planner_debug")
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
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
static AStarWithOrientationParams FromAron(const aron::data::DictPtr &dict)