Bench-MR
A Motion Planning Benchmark for Wheeled Mobile Robots
SpeedArcLengthMetric.h
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
4#include <vector>
5
6#include "../TrajectoryMetric.h"
7
8#pragma warning "The SpeedArcLengthMetric is not supported at the moment."
9
10#if 0
11class SpeedArcLengthMetric : public TMetric<SpeedArcLengthMetric> {
12 public:
13 static double evaluateMetric(const ompl::geometric::PathGeometric &trajectory,
14 double dt) {
15 double metric = 0;
16 double T = 0;
17
18 double pmetric = 0;
19
20 // TODO don't be wasteful...
21 double v_x[60000];
22 double v_y[60000];
23
24 double acc_x[60000];
25 double acc_y[60000];
26
28
30 double Vmax = 100;
31 int maxV = 0;
32 int j = 0;
33 unsigned long vsize = trajectory->getV().size();
34 double *vel = new double[vsize];
35 for (auto vi : trajectory->getV()) {
36 vel[j] = vi;
37 T += dt;
38 // cout<<"Vel_i: "<<vi<<endl;
39 j++;
40 }
41
42 for (int k = 0; k < vsize; k++) {
43 if (vel[k] > vel[maxV]) maxV = k;
44 }
45 Vmax = vel[maxV];
46
47 // cout<<"Debug VMAX: "<<Vmax<<endl;
48 // cout<<"Debug T: "<<T<<endl;
49
50 const auto path = Point::fromPath(trajectory);
51
52 for (std::size_t i = 0; i < path.size() - 1; i++) {
53 v_x[i] = (path[i + 1].x - path[i].x) / dt;
54 v_y[i] = (path[i + 1].y - path[i].y) / dt;
55 v_x[i] = v_x[i] / Vmax;
56 v_y[i] = v_y[i] / Vmax;
57 }
58
59 for (std::size_t i = 1; i < path.size() - 2; i++) {
60 acc_x[i] = (v_x[i + 1] - v_x[i - 1]) / (2 * dt);
61 acc_y[i] = (v_y[i + 1] - v_y[i - 1]) / (2 * dt);
62
63 pmetric += (std::sqrt((1 / T) * (1 / T) +
64 (acc_x[i] * acc_x[i] + acc_y[i] * acc_y[i])) *
65 dt);
66 }
67
69 metric = -std::log(pmetric);
70 delete[] vel;
71 return metric;
72 }
73};
74#endif
Definition: TrajectoryMetric.h:10
static std::vector< Point > fromPath(const ompl::geometric::PathGeometric &p, bool interpolate=false)
Definition: Primitives.cpp:25