8 #include <Eigen/Geometry>
10 #include <VirtualRobot/Robot.h>
11 #include <VirtualRobot/RobotNodeSet.h>
12 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
29 #include <armarx/navigation/global_planning/aron/SPFAParams.aron.generated.h>
34 #include <range/v3/range/conversion.hpp>
35 #include <range/v3/view/transform.hpp>
51 arondto::SPFAParams dto;
65 arondto::SPFAParams dto;
81 std::optional<GlobalPlannerResult>
85 return plan(start, goal);
88 std::optional<GlobalPlannerResult>
102 const Eigen::Vector2f goalPos =
conv::to2D(goal.translation());
104 const auto timeStart = IceUtil::Time::now();
114 ARMARX_INFO <<
"Could not plan collision-free path from"
115 <<
"(" << start.translation().x() <<
"," << start.translation().y() <<
")"
117 <<
"(" << goal.translation().x() <<
"," << goal.translation().y() <<
")"
122 const auto timeEnd = IceUtil::Time::now();
124 ARMARX_VERBOSE <<
"A* planning took " << (timeEnd - timeStart).toMilliSeconds() <<
" ms";
127 ARMARX_DEBUG <<
"The plan consists of the following positions:";
128 for (
const auto& position :
plan.path)
136 std::vector<core::Position> wpts;
138 if (plan3d.size() >= 2)
140 for (
size_t i = 1; i < (plan3d.size() - 1); i++)
142 wpts.push_back(plan3d.at(i));
155 const std::vector<float> velocities = [&]()
160 positions.reserve(wpts.size() + 2);
162 positions.emplace_back(start.translation());
163 positions.insert(positions.end(), wpts.begin(), wpts.end());
164 positions.emplace_back(goal.translation());
166 const auto maxVelocityBasedOnObstacles = [&](
const core::Position& position) ->
float
168 const auto minDistanceToObstaclesOpt =
170 Eigen::Vector2f{position.head<2>()});
172 if (not minDistanceToObstaclesOpt.has_value())
174 return defaultVelocity;
177 const float clippedObstacleDistance =
186 return defaultVelocity * obstacleFactor;
199 std::optional<core::GlobalTrajectory> resampledTrajectory;
205 resampledTrajectory = trajectory.resample(200);
216 resampledTrajectory = trajectory;
219 ARMARX_VERBOSE <<
"Resampled trajectory contains " << resampledTrajectory->points().size()
227 if (resampledTrajectory->points().size() == 2)
229 ARMARX_INFO <<
"Only start and goal provided. Not optimizing orientation";
251 const auto& costmap =
scene.
staticScene->distanceToObstaclesCostmap.value();
254 for (
auto& point : result.trajectory->mutablePoints())
256 const float distance = std::min<float>(
258 costmap.value(Eigen::Vector2f{point.waypoint.pose.translation().head<2>()})
275 std::vector<Eigen::Vector2f>
282 const auto p = approx.approximatedChain();