7#include <range/v3/algorithm/all_of.hpp>
9#include <VirtualRobot/Robot.h>
13#include <ArmarXCore/interface/serialization/Eigen/Eigen_fdi.h>
21#include <armarx/navigation/global_planning/aron/Point2PointParams.aron.generated.h>
31 std::vector<core::GlobalTrajectoryPoint>
38 (goal.translation().head<2>() - start.translation().head<2>()).norm();
42 return {core::GlobalTrajectoryPoint{.waypoint = core::Waypoint{.pose = start},
43 .velocity = velocity},
44 core::GlobalTrajectoryPoint{.waypoint = core::Waypoint{.pose = goal},
45 .velocity = velocity}};
48 const int numSegments =
static_cast<int>(std::ceil(
distance / eps));
49 const int numPoints = numSegments + 1;
54 std::vector<core::GlobalTrajectoryPoint> points;
55 points.reserve(numPoints);
57 for (
int i = 0; i < numPoints; i++)
59 const float t =
static_cast<float>(i) /
static_cast<float>(numSegments);
61 const Eigen::Vector3f position =
62 (1.F - t) * start.translation() + t * goal.translation();
67 pose.translation() = position;
68 pose.linear() = orientation.toRotationMatrix();
70 points.push_back(core::GlobalTrajectoryPoint{
71 .waypoint = core::Waypoint{.pose = pose}, .velocity = velocity});
78 checkCollisions(
const std::vector<core::GlobalTrajectoryPoint>& trajectory,
79 const navigation::algorithms::Costmap& costmap)
81 const auto isCollisionFree =
82 [&costmap](
const core::GlobalTrajectoryPoint& point) ->
bool
85 costmap.toVertex(point.waypoint.pose.translation().head<2>()).index;
86 return costmap.isValid(idx);
89 return ranges::all_of(trajectory, isCollisionFree);
105 arondto::Point2PointParams dto;
118 arondto::Point2PointParams dto;
135 ctx.staticScene.has_value() ? ctx.staticScene->distanceToObstaclesCostmap
141 std::optional<GlobalPlannerResult>
147 std::optional<GlobalPlannerResult>
150 if (
scene.staticScene.has_value())
152 impl_.updateCostmap(
scene.staticScene->distanceToObstaclesCostmap);
154 return impl_.plan(start, goal);
161 const std::optional<navigation::algorithms::Costmap>& costmap,
163 params_(params), generalConfig_(generalConfig), costmap_(costmap), robot_(robot)
170 if (costmap.has_value())
172 costmap_.emplace(costmap.value());
180 std::optional<GlobalPlannerResult>
184 resampleStraightLine(start, goal, 100.F, generalConfig_.maxVel.linear);
186 if (params_.checkCollisionsAlongTrajectory)
188 ARMARX_INFO <<
"Checking collision along trajectory";
191 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