Bench-MR
A Motion Planning Benchmark for Wheeled Mobile Robots
TrajectoryMetric.h
Go to the documentation of this file.
1#pragma once
2
3#include <ompl/control/PathControl.h>
4#include <ompl/geometric/PathGeometric.h>
5
8
9template <class METRIC, bool MoreIsBetter = false>
10class TMetric {
11 public:
12 static constexpr double ComparisonTolerance = 1e-6;
13
14 static double evaluate(const ompl::geometric::PathGeometric &trajectory,
15 double dt = 0.1) {
16 return METRIC::evaluateMetric(trajectory, dt);
17 }
18
19 static double evaluate(const ompl::control::PathControl &trajectory,
20 double dt = 0.1) {
21 return METRIC::evaluateMetric(trajectory, dt);
22 }
23
31 static int compare(const ompl::geometric::PathGeometric &a,
32 const ompl::geometric::PathGeometric &b, double dt = 0.1) {
33 double va = evaluate(a, dt), vb = evaluate(b, dt);
34 if (std::abs(va - vb) < ComparisonTolerance) return 0;
35 if (MoreIsBetter && va > vb) return 1;
36 return -1;
37 }
38
46 static int compare(const ompl::control::PathControl &a,
47 const ompl::control::PathControl &b, double dt = 0.1) {
48 double va = evaluate(a, dt), vb = evaluate(b, dt);
49 if (std::abs(va - vb) < ComparisonTolerance) return 0;
50 if (MoreIsBetter && va > vb) return 1;
51 return -1;
52 }
53};
Definition: TrajectoryMetric.h:10
static double evaluate(const ompl::geometric::PathGeometric &trajectory, double dt=0.1)
Definition: TrajectoryMetric.h:14
static double evaluate(const ompl::control::PathControl &trajectory, double dt=0.1)
Definition: TrajectoryMetric.h:19
static constexpr double ComparisonTolerance
Definition: TrajectoryMetric.h:12
static int compare(const ompl::control::PathControl &a, const ompl::control::PathControl &b, double dt=0.1)
Compares two trajectories by evaluating this metric on them.
Definition: TrajectoryMetric.h:46
static int compare(const ompl::geometric::PathGeometric &a, const ompl::geometric::PathGeometric &b, double dt=0.1)
Compares two trajectories by evaluating this metric on them.
Definition: TrajectoryMetric.h:31