Bench-MR
A Motion Planning Benchmark for Wheeled Mobile Robots
OmplSmoother.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <ompl/geometric/PathGeometric.h>
5#include <ompl/geometric/SimpleSetup.h>
6#include <ompl/geometric/planners/AnytimePathShortening.h>
7
9
10namespace ob = ompl::base;
11namespace og = ompl::geometric;
12
14 public:
15 explicit OmplSmoother(og::SimpleSetup *ss, const og::PathGeometric &solution)
16 : ss(ss), _solution(solution) {}
17
18 virtual TimedResult shortcutPath() const {
19 OMPL_INFORM("Running OMPL Shortcutting...");
21 r.status = ss->getLastPlannerStatus();
22 og::PathGeometric path(ss->getSpaceInformation());
23 path.append(_solution);
24// ss->getSpaceInformation()->setStateValidityCheckingResolution(0.2);
25 og::PathSimplifier ps(ss->getSpaceInformation(), ss->getGoal());
26
27 r.start();
28 ps.shortcutPath(path, global::settings.smoothing.ompl.shortcut_max_steps,
32 r.stop();
33
34 // have to reduce resolution
35 // path.interpolate();
36 // ss->getSpaceInformation()->setStateValidityCheckingResolution(0.05);
37 r.trajectory = path;
38 return r;
39 }
40
41 virtual TimedResult smoothBSpline() const {
42 OMPL_INFORM("Running OMPL B-spline smoothing...");
44 r.status = ss->getLastPlannerStatus();
45 og::PathGeometric path(ss->getSpaceInformation());
46 path.append(_solution);
47 // ss->getSpaceInformation()->setStateValidityCheckingResolution(0.2);
48 og::PathSimplifier ps(ss->getSpaceInformation(), ss->getGoal());
49
50 r.start();
51 ps.smoothBSpline(path, global::settings.smoothing.ompl.bspline_max_steps,
53 r.stop();
54
55 // have to reduce resolution
56 // path.interpolate();
57 // ss->getSpaceInformation()->setStateValidityCheckingResolution(0.05);
58 r.trajectory = path;
59 return r;
60 }
61
62 virtual TimedResult simplifyMax() const {
63 OMPL_INFORM("Running OMPL Simplify Max smoothing...");
65 r.status = ss->getLastPlannerStatus();
66 og::PathGeometric path(ss->getSpaceInformation());
67 path.append(_solution);
68 og::PathSimplifier ps(ss->getSpaceInformation(), ss->getGoal());
69
70 r.start();
71 ps.simplifyMax(path);
72 r.stop();
73
74 // path.interpolate();
75 r.trajectory = path;
76 return r;
77 }
78
79// virtual TimedResult anytimePathShortening(ob::Planner *omplPlanner) {
80// OMPL_INFORM("Running OMPL Anytime Path Shortening...");
81// ob::PlannerPtr planner;
82// planner =
83// std::make_shared<og::AnytimePathShortening>(ss->getSpaceInformation());
84// planner->as<og::AnytimePathShortening>()->setHybridize(
85// global::settings.smoothing.ompl.anytime_hybridize);
86// planner->as<og::AnytimePathShortening>()->setShortcut(
87// global::settings.smoothing.ompl.anytime_shortcut);
88// ob::PlannerPtr optimizingPlanner(omplPlanner);
89// planner->as<og::AnytimePathShortening>()->addPlanner(optimizingPlanner);
90// this->ss->setPlanner(planner);
91// this->ss->setup();
92// auto solved = this->ss->solve(global::settings.max_planning_time);
93// std::cout << "OMPL anytime path shortening planning status: "
94// << solved.asString().c_str() << std::endl;
95//
96// TimedResult r;
97// r.status = solved;
98// if (solved) {
99// // ss->simplifySolution(); // TODO define time limit?
100//
101// auto path = ss->getSolutionPath();
102// // path.interpolate();
103// // ss->getSpaceInformation()->setStateValidityCheckingResolution(0.05);
104// r.trajectory = path;
105// } else
106// std::cout << "No solution found." << std::endl;
107//
108// return r;
109// }
110
111 private:
112 og::SimpleSetup *ss{nullptr};
113 og::PathGeometric _solution;
114};
Definition: OmplSmoother.hpp:13
OmplSmoother(og::SimpleSetup *ss, const og::PathGeometric &solution)
Definition: OmplSmoother.hpp:15
virtual TimedResult simplifyMax() const
Definition: OmplSmoother.hpp:62
virtual TimedResult shortcutPath() const
Definition: OmplSmoother.hpp:18
virtual TimedResult smoothBSpline() const
Definition: OmplSmoother.hpp:41
double stop()
Stops the timer.
Definition: Stopwatch.hpp:32
void start()
Starts the timer.
Definition: Stopwatch.hpp:15
Definition: TimedResult.hpp:9
ob::PlannerStatus status
Definition: TimedResult.hpp:12
ompl::geometric::PathGeometric trajectory
Definition: TimedResult.hpp:11
Property< unsigned int > shortcut_max_empty_steps
Definition: PlannerSettings.h:652
Property< double > shortcut_snap_to_vertex
Definition: PlannerSettings.h:655
Property< double > bspline_epsilon
Definition: PlannerSettings.h:649
Property< double > shortcut_range_ratio
Definition: PlannerSettings.h:654
PlannerSettings::GlobalSettings::SmoothingSettings::OmplSettings ompl
PlannerSettings::GlobalSettings::OmplSettings ompl
PlannerSettings::GlobalSettings::SmoothingSettings smoothing
static PlannerSettings::GlobalSettings settings
Definition: PlannerSettings.h:699