Metrics.h
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#include <iosfwd>
20#include <optional>
21#include <string>
22#include <vector>
23
24#include <SimoxUtility/json/json.hpp>
25
28
29#include "Sampling.h"
30
32{
33
34 /// What one planning request produced.
35 struct Record
36 {
38
39 bool planned{false};
40
41 /// Straight-line start-to-goal distance and the length actually planned [mm].
42 float separation{0.F};
43
44 float pathLength{0.F};
45
46 int waypoints{0};
47
49
50 bool smoothingApplied{false};
51
52 /// Folds in the trajectory the planner returned, measured independently of the
53 /// smoother's own gate: the accepted path is what the robot would drive.
55
56 /// Smallest costmap clearance along the returned path [mm], sampled at waypoints and
57 /// along the segments between them.
58 float minClearance{0.F};
59
60 float plannedSeconds{0.F};
61
62 /// Costmap clearance at the requested start and goal [mm]. A request whose endpoint is
63 /// closer to an obstacle than the checker's clearance cannot produce an acceptable
64 /// path however well the middle is smoothed, so a rejection rate that does not
65 /// separate these says nothing about the smoother.
66 float startClearance{0.F};
67
68 float goalClearance{0.F};
69
70 /**
71 * Sharpest direction change between consecutive segments [deg], and how many exceed
72 * 30 deg.
73 *
74 * `foldsInResult` uses the smoother's own detector, whose threshold reports only a
75 * reversal of 90 deg or more. The folds reported from the robot are small ones, and
76 * the harm they do downstream -- a collapsing spline tangent in the reparametrization
77 * -- grows continuously with the turn rather than switching on at 90 deg. Recording
78 * the angle directly lets a sweep be read without inheriting that threshold.
79 */
80 float sharpestTurnDeg{0.F};
81
82 int sharpTurns{0};
83
84 /// The same, measured on the raw grid-search output before resampling and smoothing.
86
87 /**
88 * Total turning along the path [deg] -- the sum of the absolute direction change at
89 * every interior waypoint.
90 *
91 * The sharpest single turn says how bad the worst corner is; this says how much the
92 * path wanders overall. A path can have no severe corner and still be visibly ragged,
93 * and that is what the robot feels: every direction change is a lateral acceleration.
94 */
95 float totalTurningDeg{0.F};
96
97 /// Mean absolute direction change per interior waypoint [deg].
98 float meanTurnDeg{0.F};
99
100 /// Longest / shortest segment. 1.0 is perfectly even; large values mean bunching.
101 float spacingRatio{1.F};
102
103 /// Straight-line distance divided by path length. 1.0 is a straight run.
104 float directness{0.F};
105 };
106
107 /// One JSON object per line, so a sweep streams to disk and can be diffed across revisions.
108 void writeRecord(std::ostream& out, const Record& record);
109
110 /**
111 * @brief Aggregate over a sweep, grouped by request kind.
112 *
113 * @param checkerClearance The clearance [mm] the trajectory checker enforces, used to
114 * separate requests the smoother could never have satisfied from ones it failed.
115 */
116 std::string summarize(const std::vector<Record>& records, float checkerClearance);
117
118 /// Measure a planning result against the costmap.
119 Record measure(const Request& request,
120 const std::optional<global_planning::GlobalPlannerResult>& result,
121 const algorithms::Costmap& costmap,
122 float plannedSeconds);
123
124} // namespace armarx::navigation::evaluation
This file is part of ArmarX.
Definition Metrics.cpp:30
Record measure(const Request &request, const std::optional< global_planning::GlobalPlannerResult > &result, const algorithms::Costmap &costmap, const float plannedSeconds)
Measure a planning result against the costmap.
Definition Metrics.cpp:137
std::string summarize(const std::vector< Record > &records, const float checkerClearance)
Aggregate over a sweep, grouped by request kind.
Definition Metrics.cpp:294
void writeRecord(std::ostream &out, const Record &record)
One JSON object per line, so a sweep streams to disk and can be diffed across revisions.
Definition Metrics.cpp:245
What one planning request produced.
Definition Metrics.h:36
float sharpestGridTurnDeg
The same, measured on the raw grid-search output before resampling and smoothing.
Definition Metrics.h:85
float spacingRatio
Longest / shortest segment. 1.0 is perfectly even; large values mean bunching.
Definition Metrics.h:101
float meanTurnDeg
Mean absolute direction change per interior waypoint [deg].
Definition Metrics.h:98
float separation
Straight-line start-to-goal distance and the length actually planned [mm].
Definition Metrics.h:42
float startClearance
Costmap clearance at the requested start and goal [mm].
Definition Metrics.h:66
global_planning::GlobalPlannerResult::SmoothingOutcome smoothing
Definition Metrics.h:48
int foldsInResult
Folds in the trajectory the planner returned, measured independently of the smoother's own gate: the ...
Definition Metrics.h:54
float totalTurningDeg
Total turning along the path [deg] – the sum of the absolute direction change at every interior waypo...
Definition Metrics.h:95
float directness
Straight-line distance divided by path length. 1.0 is a straight run.
Definition Metrics.h:104
float sharpestTurnDeg
Sharpest direction change between consecutive segments [deg], and how many exceed 30 deg.
Definition Metrics.h:80
float minClearance
Smallest costmap clearance along the returned path [mm], sampled at waypoints and along the segments ...
Definition Metrics.h:58
Why the position smoothing stage ended the way it did.