Bench-MR
A Motion Planning Benchmark for Wheeled Mobile Robots
PathStatistics.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <cmath>
5#include <iostream>
6#include <nlohmann/json.hpp>
7#include <params.hpp>
8#include <string>
9#include <utility>
10#include <vector>
11
12#include "Primitives.h"
13
14using namespace params;
15
16struct PathStatistics : public Group {
17 Property<double> planning_time{std::numeric_limits<double>::quiet_NaN(),
18 "planning_time", this};
19 Property<double> collision_time{std::numeric_limits<double>::quiet_NaN(),
20 "collision_time", this};
21 Property<double> steering_time{std::numeric_limits<double>::quiet_NaN(),
22 "steering_time", this};
23 Property<bool> path_found{false, "path_found", this};
24 Property<bool> path_collides{true, "path_collides", this};
25 Property<bool> exact_goal_path{true, "exact_goal_path", this};
26 Property<double> path_length{std::numeric_limits<double>::quiet_NaN(),
27 "path_length", this};
28 Property<double> max_curvature{std::numeric_limits<double>::quiet_NaN(),
29 "max_curvature", this};
30 Property<double> normalized_curvature{
31 std::numeric_limits<double>::quiet_NaN(), "normalized_curvature", this};
32 Property<double> aol{
33 std::numeric_limits<double>::quiet_NaN(), "aol", this};
34 Property<double> smoothness{std::numeric_limits<double>::quiet_NaN(),
35 "smoothness", this};
36 Property<double> mean_clearing_distance{
37 std::numeric_limits<double>::quiet_NaN(), "mean_clearing_distance", this};
38 Property<double> median_clearing_distance{
39 std::numeric_limits<double>::quiet_NaN(), "median_clearing_distance",
40 this};
41 Property<double> min_clearing_distance{
42 std::numeric_limits<double>::quiet_NaN(), "min_clearing_distance", this};
43 Property<double> max_clearing_distance{
44 std::numeric_limits<double>::quiet_NaN(), "max_clearing_distance", this};
45 Property<std::string> planner{"UNKNOWN", "planner", this};
46 Property<nlohmann::json> planner_settings{{}, "planner_settings", this};
47 Property<std::vector<Point>> cusps{{}, "cusps", this};
48 Property<std::vector<Point>> collisions{{}, "collisions", this};
49
50 explicit PathStatistics(const std::string &planner = "UNKNOWN")
51 : Group("stats") {
52 this->planner = planner;
53 }
54};
55
56namespace stat {
57inline double median(std::vector<double> values) {
58 std::sort(values.begin(), values.end());
59 size_t count = values.size();
60 if (count % 2 == 1) return values[count / 2];
61
62 double right = values[count / 2];
63 double left = values[count / 2 - 1];
64 return (right + left) / 2.0;
65}
66
67inline double mean(const std::vector<double> &values) {
68 double avg = 0;
69 for (double v : values) avg += v;
70 return avg / values.size();
71}
72
73inline double min(const std::vector<double> &values) {
75 for (double v : values) m = std::min(m, v);
76 return m;
77}
78
79inline double max(const std::vector<double> &values) {
81 for (double v : values) m = std::max(m, v);
82 return m;
83}
84
85inline double std(const std::vector<double> &values) {
86 double s = 0;
87 double m = mean(values);
88 for (double v : values) s += std::pow(v - m, 2.);
89 return std::sqrt(1. / values.size() * s);
90}
91} // namespace stat
Definition: PathStatistics.hpp:56
double max(const std::vector< double > &values)
Definition: PathStatistics.hpp:79
double std(const std::vector< double > &values)
Definition: PathStatistics.hpp:85
double min(const std::vector< double > &values)
Definition: PathStatistics.hpp:73
double median(std::vector< double > values)
Definition: PathStatistics.hpp:57
double mean(const std::vector< double > &values)
Definition: PathStatistics.hpp:67
Definition: PathStatistics.hpp:16
Property< double > smoothness
Definition: PathStatistics.hpp:34
Property< std::vector< Point > > collisions
Definition: PathStatistics.hpp:48
Property< bool > path_collides
Definition: PathStatistics.hpp:24
Property< double > normalized_curvature
Definition: PathStatistics.hpp:30
Property< double > planning_time
Definition: PathStatistics.hpp:17
Property< std::vector< Point > > cusps
Definition: PathStatistics.hpp:47
Property< double > max_curvature
Definition: PathStatistics.hpp:28
Property< double > aol
Definition: PathStatistics.hpp:32
Property< double > steering_time
Definition: PathStatistics.hpp:21
Property< bool > path_found
Definition: PathStatistics.hpp:23
Property< double > min_clearing_distance
Definition: PathStatistics.hpp:41
Property< double > path_length
Definition: PathStatistics.hpp:26
Property< double > mean_clearing_distance
Definition: PathStatistics.hpp:36
Property< std::string > planner
Definition: PathStatistics.hpp:45
Property< bool > exact_goal_path
Definition: PathStatistics.hpp:25
Property< double > collision_time
Definition: PathStatistics.hpp:19
Property< double > median_clearing_distance
Definition: PathStatistics.hpp:38
Property< double > max_clearing_distance
Definition: PathStatistics.hpp:43
Property< nlohmann::json > planner_settings
Definition: PathStatistics.hpp:46
PathStatistics(const std::string &planner="UNKNOWN")
Definition: PathStatistics.hpp:50