6#include "../base/PlannerSettings.h"
26 static double evMetric(
const std::vector<Point>& path,
27 bool visualize =
false) {
28 double x1, x2, x3, y1, y2, y3, v1x, v2x, v1y, v2y, v1, v2;
30 double normalized_k = 0;
32 size_t traj_size = path.size();
41 if (traj_size < 3)
return 0;
45 for (
int i = 0; i < (traj_size - 2); i++) {
53 if (i >= path.size())
return normalized_k;
56 }
while (distance(x1, y1, x2, y2) < 0.3);
60 if (i >= path.size())
return normalized_k;
63 }
while (distance(x2, y2, x3, y3) < 0.3);
66 if (x1 == x2 && y1 == y2 || x2 == x3 && y2 == y3)
continue;
70 if (x1 == x3 && y1 == y3) {
71 OMPL_WARN(
"Undefined curvature. Skipping three steps...");
77 (std::pow(x3, 2.) * (-y1 + y2) + std::pow(x2, 2.) * (y1 - y3) -
78 (std::pow(x1, 2.) + (y1 - y2) * (y1 - y3)) * (y2 - y3)) /
79 (2. * (x3 * (-y1 + y2) + x2 * (y1 - y3) + x1 * (-y2 + y3)));
81 (-(std::pow(x2, 2.) * x3) + std::pow(x1, 2.) * (-x2 + x3) +
82 x3 * (std::pow(y1, 2.) - std::pow(y2, 2.)) +
83 x1 * (std::pow(x2, 2.) - std::pow(x3, 2.) + std::pow(y2, 2.) -
85 x2 * (std::pow(x3, 2.) - std::pow(y1, 2.) + std::pow(y3, 2.))) /
86 (2. * (x3 * (y1 - y2) + x1 * (y2 - y3) + x2 * (-y1 + y3)));
89 double radius = std::sqrt(std::pow(x1 - cx, 2.) + std::pow(y1 - cy, 2.));
90 double ki = 1. / radius;
94 if (visualize && ki > 0.5) {
96 x1, y1, QColor(255,
std::max(0, (
int)(255 - ki * 10)), 0, 50), .8);
98 x2, y2, QColor(255,
std::max(0, (
int)(255 - ki * 10)), 0, 50), .8);
100 x3, y3, QColor(255,
std::max(0, (
int)(255 - ki * 10)), 0, 50), .8);
108 ki * (distance(x1, y1, x2, y2) + distance(x2, y2, x3, y3));
115 double,
bool visualize =
false) {
121 double,
bool visualize =
false) {
129 static double distance(
double x1,
double y1,
double x2,
double y2) {
130 return std::sqrt(std::pow(x2 - x1, 2.) + std::pow(y2 - y1, 2.));
Definition: NormalizedCurvatureMetric.h:13
static double evaluateMetric(const ompl::control::PathControl &trajectory, double, bool visualize=false)
Definition: NormalizedCurvatureMetric.h:120
static double evMetric(const std::vector< Point > &path, bool visualize=false)
Definition: NormalizedCurvatureMetric.h:26
static double max_curvature
Computes a normalized curvature metric of the given trajectory.
Definition: NormalizedCurvatureMetric.h:24
static const bool MoreIsBetter
Definition: NormalizedCurvatureMetric.h:126
static double evaluateMetric(const ompl::geometric::PathGeometric &trajectory, double, bool visualize=false)
Definition: NormalizedCurvatureMetric.h:114
static void drawNode(const ompl::base::State *state, const QColor &color=Qt::red, double radius=0.3, bool drawArrow=true)
Definition: QtVisualizer.cpp:147
Definition: TrajectoryMetric.h:10
double max(const std::vector< double > &values)
Definition: PathStatistics.hpp:79
double min(const std::vector< double > &values)
Definition: PathStatistics.hpp:73
static std::vector< Point > fromPath(const ompl::geometric::PathGeometric &p, bool interpolate=false)
Definition: Primitives.cpp:25