25 static void createEmptyEntry(
const std::string &planner_name,
26 nlohmann::json &info) {
28 auto &j = info[
"plans"][planner_name];
30 j[
"stats"] = nlohmann::json(empty_stats)[
"stats"];
32 j[
"intermediary_solutions"] = {};
42 const std::vector<Point> path) {
43 std::vector<Point> &cusps = stats.
cusps.value();
45 auto prev = path.begin();
48 while (next != path.end()) {
50 if (prev->distance(*current) <= 0) {
54 else if (current->distance(*next) <= 0) {
63 const double yaw_change =
67 cusps.emplace_back(*current);
77 const ompl::control::PathControl &path,
84 if (path.getStateCount() < 2) {
93 Point(solution.getStates().back())
119 const ompl::geometric::PathGeometric &path,
126 if (path.getStateCount() < 2) {
131 auto solution = path;
134 if (planner->
name().rfind(
"SBPL", 0) == 0) {
143 Point(solution.getStates().back())
169 template <
class PLANNER>
170 static bool evaluate(PLANNER &planner, nlohmann::json &info) {
172 auto &j = info[
"plans"][planner.name()];
173 OMPL_INFORM((
"Running " + planner.name() +
"...").c_str());
182 createEmptyEntry(planner.name(), info);
183 std::cout <<
"<stats> No solution was found. </stats>\n";
186 }
catch (std::bad_alloc &ba) {
188 OMPL_ERROR(
"<stats> Error </stats>\nPlanner %s ran out of memory: %s.",
189 planner.name().c_str(), ba.what());
190 createEmptyEntry(planner.name(), info);
192 }
catch (ompl::Exception &ex) {
193 OMPL_ERROR(
"Unable to evaluate new planner %s.\n%s",
194 planner.name().c_str(), ex.what());
195 createEmptyEntry(planner.name(), info);
199 "<stats> Error </stats>\nAn unknown exception occurred while running "
201 planner.name().c_str());
202 createEmptyEntry(planner.name(), info);
206 std::cout << stats << std::endl;
207 std::cout <<
"Steer function: "
212 if (planner.name().rfind(
"SBPL", 0) == 0) {
217 j[
"stats"] = nlohmann::json(stats)[
"stats"];
220 std::vector<nlohmann::json> intermediaries;
221 for (
const auto &is : planner.intermediarySolutions) {
223 evaluate(is_stats, is.solution, &planner);
224 nlohmann::json s{{
"time", is.time},
230 {
"stats", nlohmann::json(is_stats)[
"stats"]}};
231 intermediaries.emplace_back(s);
233 j[
"intermediary_solutions"] = intermediaries;
237 template <
class PLANNER>
239 PLANNER *planner =
nullptr;
241 planner =
new PLANNER;
243 }
catch (std::bad_alloc &ba) {
246 "<stats> Error </stats>\nRan out of memory while creating planner "
252 }
catch (ompl::Exception &ex) {
253 OMPL_ERROR(
"Unable to create new planner %s.\n%s",
260 "<stats> Error </stats>\nAn unknown exception occurred while "
261 "creating planner %s.",
267 auto result =
evaluate(*planner, info);
272 template <
class PLANNER>
274 PLANNER *planner =
nullptr;
276 planner =
new PLANNER;
278 }
catch (std::bad_alloc &ba) {
281 "<stats> Error </stats>\nRan out of memory while creating planner "
289 "<stats> Error </stats>\nAn unknown exception occurred while "
290 "creating planner %s.",
296 if (!evaluate<PLANNER>(*planner, info)) {
297 OMPL_WARN(
"Cannot evaluate smoothers since no solution could be found.");
301 auto &j = info[
"plans"][planner->name()][
"smoothing"];
306 const double cached_min_node_dist =
315 og::PathGeometric grips(planner->solution());
318 evaluate(grips_stats, grips, planner);
327 {
"cost", grips.length()},
330 {
"stats", nlohmann::json(grips_stats)[
"stats"]},
339 chomp.
run(planner->solution());
348 {
"cost", chomp.
solution().length()},
351 {
"stats", nlohmann::json(chomp_stats)[
"stats"]}};
355 OmplSmoother smoother(planner->simpleSetup(), planner->solution());
363 j[
"ompl_shortcut"] = {
368 {
"name",
"Shortcut"},
372 {
"stats", nlohmann::json(stats)[
"stats"]}};
381 j[
"ompl_bspline"] = {
386 {
"name",
"B-Spline"},
390 {
"stats", nlohmann::json(stats)[
"stats"]}};
399 j[
"ompl_simplify_max"] = {
404 {
"name",
"SimplifyMax"},
408 {
"stats", nlohmann::json(stats)[
"stats"]}};
421 template <
class PLANNER>
424 const std::vector<double> times =
427 auto &j = info[
"plans"][planner.name()];
428 std::vector<nlohmann::json> intermediaries;
429 bool success =
false;
431 for (
double time : times) {
432 OMPL_INFORM((
"Running " + planner.name() +
" for " +
443 std::cout << stats << std::endl;
444 std::cout <<
"Steer function: "
450 {
"time", planner.planningTime()},
457 {
"stats", nlohmann::json(stats)[
"stats"]}};
458 intermediaries.emplace_back(s);
461 j[
"intermediary_solutions"] = intermediaries;
462 if (planner.name().rfind(
"SBPL", 0) == 0) {
467 j[
"stats"] = nlohmann::json(stats)[
"stats"];
Definition: AbstractPlanner.h:29
bool isValid(const ob::State *state) const
Definition: AbstractPlanner.h:78
virtual nlohmann::json getSettings() const
Definition: AbstractPlanner.h:121
static std::string LastCreatedPlannerName
Stores the name of the planner created last.
Definition: AbstractPlanner.h:38
virtual double planningTime() const =0
virtual std::string name() const =0
ob::PlannerStatus run(const og::PathGeometric &path)
Definition: CHOMP.cpp:38
std::vector< Point > solutionPath() const
Definition: CHOMP.cpp:127
og::PathGeometric solution() const
Definition: CHOMP.cpp:121
double planningTime() const
Definition: CHOMP.cpp:129
static std::vector< double > clearingDistances(const ompl::geometric::PathGeometric &trajectory)
Definition: ClearingMetric.h:8
static int insertedNodes
Definition: GRIPS.h:74
static bool smooth(ompl::geometric::PathGeometric &path, const std::vector< Point > &originalPathIntermediaries)
Definition: GRIPS.cpp:17
static int pruningRounds
Definition: GRIPS.h:75
static std::vector< RoundStats > statsPerRound
Definition: GRIPS.h:77
static double smoothingTime
Definition: GRIPS.h:78
static std::vector< std::array< double, 3 > > serializeTrajectory(const ompl::geometric::PathGeometric &traj, bool interpolate=true)
Definition: Log.cpp:76
Definition: OmplSmoother.hpp:13
virtual TimedResult simplifyMax() const
Definition: OmplSmoother.hpp:62
virtual TimedResult shortcutPath() const
Definition: OmplSmoother.hpp:18
virtual TimedResult smoothBSpline() const
Definition: OmplSmoother.hpp:41
static void configure(PLANNER &planner)
Definition: PlannerConfigurator.hpp:17
static ompl::geometric::PathGeometric interpolated(ompl::geometric::PathGeometric path)
Interpolate path based on its associated state space.
Definition: PlannerUtils.hpp:261
static double slope(const N &x1, const N &y1, const N &x2, const N &y2)
Compute the angular slope between two points.
Definition: PlannerUtils.hpp:39
static double normalizeAngle(double angle)
Normalize angle in radians to the interval .
Definition: PlannerUtils.hpp:572
void reset()
Stops the timer and sets elapsed time to zero.
Definition: Stopwatch.hpp:23
double elapsed() const
Elapsed time in seconds.
Definition: Stopwatch.hpp:41
static double evaluate(const ompl::geometric::PathGeometric &trajectory, double dt=0.1)
Definition: TrajectoryMetric.h:14
Definition: TimedResult.hpp:9
ompl::geometric::PathGeometric trajectory
Definition: TimedResult.hpp:11
std::string to_string(Steering::SteeringType t)
Definition: Steering.h:17
@ STEER_TYPE_CC_DUBINS
Definition: Steering.h:12
std::string to_string(Method m)
Definition: PlannerSettings.h:32
double max(const std::vector< double > &values)
Definition: PathStatistics.hpp:79
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: PathEvaluation.hpp:18
static bool evaluate(PathStatistics &stats, const ompl::control::PathControl &path, const AbstractPlanner *planner)
Definition: PathEvaluation.hpp:76
static void computeCusps(PathStatistics &stats, const std::vector< Point > path)
Identifies cusps in a solution path by comparing the yaw angles between every second state.
Definition: PathEvaluation.hpp:41
static bool evaluateAnytime(nlohmann::json &info)
Evaluates an anytime path planner by running the planner for each of the provided time intervals (in ...
Definition: PathEvaluation.hpp:422
static bool evaluate(nlohmann::json &info)
Definition: PathEvaluation.hpp:238
static bool evaluateSmoothers(nlohmann::json &info)
Definition: PathEvaluation.hpp:273
static bool evaluate(PLANNER &planner, nlohmann::json &info)
Definition: PathEvaluation.hpp:170
static bool evaluate(PathStatistics &stats, const ompl::geometric::PathGeometric &path, const AbstractPlanner *planner)
Definition: PathEvaluation.hpp:118
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
Property< std::vector< double > > anytime_intervals
Time intervals used for the anytime planner benchmark.
Definition: PlannerSettings.h:314
Stopwatch steering_timer
Definition: PlannerSettings.h:414
Property< double > min_node_distance
Definition: PlannerSettings.h:622
PlannerSettings::GlobalSettings::SmoothingSettings::ChompSettings chomp
PlannerSettings::GlobalSettings::SmoothingSettings::GripsSettings grips
Property< double > exact_goal_radius
Radius threshold to evaluate whether the exact goal has been found.
Definition: PlannerSettings.h:262
std::shared_ptr< Environment > environment
Environment used for planning.
Definition: PlannerSettings.h:73
PlannerSettings::GlobalSettings::OmplSettings ompl
PlannerSettings::GlobalSettings::SmoothingSettings smoothing
PlannerSettings::GlobalSettings::BenchmarkSettings benchmark
Property< double > max_planning_time
Definition: PlannerSettings.h:238
Definition: Primitives.h:42
double distance(const Point &p) const
Definition: Primitives.h:74
static std::vector< Point > fromPath(const ompl::geometric::PathGeometric &p, bool interpolate=false)
Definition: Primitives.cpp:25
static PlannerSettings::GlobalSettings settings
Definition: PlannerSettings.h:699