8#include <range/v3/algorithm/all_of.hpp>
10#include <VirtualRobot/Robot.h>
14#include <ArmarXCore/interface/serialization/Eigen/Eigen_fdi.h>
22#include <armarx/navigation/global_planning/aron/Point2PointParams.aron.generated.h>
32 constexpr float maxWaypointSpacing = 100.F;
33 constexpr int minWaypointSegments = 9;
34 constexpr float minWaypointSpacing = 5.F;
36 std::vector<core::GlobalTrajectoryPoint>
43 (goal.translation().head<2>() - start.translation().head<2>()).norm();
50 ? std::clamp(
distance /
static_cast<float>(minWaypointSegments),
57 return {core::GlobalTrajectoryPoint{.waypoint = core::Waypoint{.pose = start},
58 .velocity = velocity},
59 core::GlobalTrajectoryPoint{.waypoint = core::Waypoint{.pose = goal},
60 .velocity = velocity}};
63 const int numSegments =
static_cast<int>(std::ceil(
distance / spacing));
64 const int numPoints = numSegments + 1;
69 std::vector<core::GlobalTrajectoryPoint> points;
70 points.reserve(numPoints);
72 for (
int i = 0; i < numPoints; i++)
74 const float t =
static_cast<float>(i) /
static_cast<float>(numSegments);
76 const Eigen::Vector3f position =
77 (1.F - t) * start.translation() + t * goal.translation();
82 pose.translation() = position;
83 pose.linear() = orientation.toRotationMatrix();
85 points.push_back(core::GlobalTrajectoryPoint{
86 .waypoint = core::Waypoint{.pose = pose}, .velocity = velocity});
93 checkCollisions(
const std::vector<core::GlobalTrajectoryPoint>& trajectory,
94 const navigation::algorithms::Costmap& costmap)
96 const auto isCollisionFree =
97 [&costmap](
const core::GlobalTrajectoryPoint& point) ->
bool
100 costmap.toVertex(point.waypoint.pose.translation().head<2>()).index;
101 return costmap.isValid(idx);
104 return ranges::all_of(trajectory, isCollisionFree);
120 arondto::Point2PointParams dto;
133 arondto::Point2PointParams dto;
150 ctx.staticScene.has_value() ? ctx.staticScene->distanceToObstaclesCostmap
156 std::optional<GlobalPlannerResult>
162 std::optional<GlobalPlannerResult>
165 if (
scene.staticScene.has_value())
167 impl_.updateCostmap(
scene.staticScene->distanceToObstaclesCostmap);
169 return impl_.plan(start, goal);
176 const std::optional<navigation::algorithms::Costmap>& costmap,
178 params_(params), generalConfig_(generalConfig), costmap_(costmap), robot_(robot)
185 if (costmap.has_value())
187 costmap_.emplace(costmap.value());
195 std::optional<GlobalPlannerResult>
199 resampleStraightLine(start, goal, maxWaypointSpacing, generalConfig_.maxVel.linear);
201 if (params_.checkCollisionsAlongTrajectory)
203 ARMARX_INFO <<
"Checking collision along trajectory";
206 if (not checkCollisions(
trajectory, costmap_.value()))
core::GeneralConfig generalConfig
GlobalPlanner(const core::GeneralConfig &generalConfig, const core::Scene &scene)
const core::Scene & scene
void updateCostmap(const std::optional< navigation::algorithms::Costmap > &costmap)
std::optional< GlobalPlannerResult > plan(const core::Pose &start, const core::Pose &goal)
Point2PointImpl(const Params ¶ms, const core::GeneralConfig &generalConfig, const std::optional< navigation::algorithms::Costmap > &costmap, VirtualRobot::RobotPtr robot)
std::optional< GlobalPlannerResult > plan(const core::Pose &goal) override
Point2Point(const Params ¶ms, const core::GeneralConfig &generalConfig, const core::Scene &ctx)
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
@ Point2Point
see Point2Point
#define ARMARX_INFO
The normal logging level.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Quaternion< float, 0 > Quaternionf
std::shared_ptr< class Robot > RobotPtr
std::shared_ptr< Dict > DictPtr
void toAron(arondto::GlobalPlannerParams &dto, const GlobalPlannerParams &bo)
void fromAron(const arondto::GlobalPlannerParams &dto, GlobalPlannerParams &bo)
This file is part of ArmarX.
double distance(const Point &a, const Point &b)
Parameters for Point2Point.
static Point2PointParams FromAron(const aron::data::DictPtr &dict)
aron::data::DictPtr toAron() const override
Algorithms algorithm() const override