3#include <ompl/base/SpaceInformation.h>
4#include <ompl/base/objectives/MaximizeMinClearanceObjective.h>
5#include <ompl/base/objectives/PathLengthOptimizationObjective.h>
6#include <ompl/base/objectives/StateCostIntegralObjective.h>
7#include <ompl/base/spaces/DubinsStateSpace.h>
8#include <ompl/base/spaces/RealVectorStateSpace.h>
9#include <ompl/base/spaces/ReedsSheppStateSpace.h>
10#include <ompl/base/spaces/SE2StateSpace.h>
11#include <ompl/geometric/PathGeometric.h>
12#include <ompl/geometric/PathSimplifier.h>
13#include <ompl/geometric/SimpleSetup.h>
15#include <ompl/control/planners/est/EST.h>
16#include <ompl/control/planners/kpiece/KPIECE1.h>
17#include <ompl/control/planners/pdst/PDST.h>
18#include <ompl/control/planners/rrt/RRT.h>
19#include <ompl/control/planners/sst/SST.h>
21#include <ompl/geometric/planners/informedtrees/BITstar.h>
22#include <ompl/geometric/planners/cforest/CForest.h>
23#include <ompl/geometric/planners/est/EST.h>
24#include <ompl/geometric/planners/fmt/BFMT.h>
25#include <ompl/geometric/planners/fmt/FMT.h>
26#include <ompl/geometric/planners/kpiece/KPIECE1.h>
27#include <ompl/geometric/planners/pdst/PDST.h>
28#include <ompl/geometric/planners/prm/PRMstar.h>
29#include <ompl/geometric/planners/prm/SPARS.h>
30#include <ompl/geometric/planners/prm/SPARStwo.h>
31#include <ompl/geometric/planners/rrt/InformedRRTstar.h>
32#include <ompl/geometric/planners/rrt/RRT.h>
33#include <ompl/geometric/planners/rrt/RRTsharp.h>
34#include <ompl/geometric/planners/rrt/RRTstar.h>
35#include <ompl/geometric/planners/rrt/SORRTstar.h>
36#include <ompl/geometric/planners/sbl/SBL.h>
37#include <ompl/geometric/planners/sst/SST.h>
38#include <ompl/geometric/planners/stride/STRIDE.h>
47namespace ob = ompl::base;
48namespace og = ompl::geometric;
49namespace oc = ompl::control;
51template <
class PLANNER>
55 _omplPlanner = ob::PlannerPtr(
new PLANNER(
ss->getSpaceInformation()));
59 ob::PlannerStatus
run()
override {
62 ss->setPlanner(_omplPlanner);
66 auto problem = _omplPlanner->getProblemDefinition();
67 problem->setIntermediateSolutionCallback(
69 const std::vector<const ob::State *> &states,
const ob::Cost cost) {
73 for (
const auto *state : states)
solution.append(state);
82 OMPL_INFORM(
"OMPL %s planning status: %s", _omplPlanner->getName().c_str(),
83 solved.asString().c_str());
89 const auto &path =
ss->getSolutionPath();
90 for (std::size_t i = 0; i < path.getStateCount(); ++i) {
91 _solution.append(path.getState(i));
95 "%s found a solution of length %f with an optimization objective "
97 _omplPlanner->getName().c_str(), _solution.length(),
98 _solution.cost(
ss->getOptimizationObjective()));
100 OMPL_WARN(
"No solution found.");
104 std::string
name()
const override {
return _omplPlanner->getName(); }
107 og::PathGeometric path(_solution);
108 return og::PathGeometric(_solution);
112 return ss->haveExactSolutionPath();
116 return ss->getLastPlanComputationTime();
122 nlohmann::json settings;
123 const auto ¶m_map = _omplPlanner->params().getParams();
124 for (
const auto &[key, value_ptr] : param_map) {
125 settings[key] = value_ptr->getValue();
131 ob::PlannerPtr _omplPlanner;
OMPLPlanner< og::EST > ESTPlanner
Definition: OMPLPlanner.hpp:149
OMPLPlanner< og::SORRTstar > SORRTstarPlanner
Definition: OMPLPlanner.hpp:141
OMPLPlanner< og::PRMstar > PRMstarPlanner
Definition: OMPLPlanner.hpp:147
OMPLPlanner< og::PDST > PDSTPlanner
Definition: OMPLPlanner.hpp:154
OMPLPlanner< og::STRIDE > STRIDEPlanner
Definition: OMPLPlanner.hpp:151
OMPLPlanner< og::KPIECE1 > KPIECEPlanner
Definition: OMPLPlanner.hpp:150
OMPLPlanner< og::SPARS > SPARSPlanner
Definition: OMPLPlanner.hpp:152
OMPLPlanner< og::PRM > PRMPlanner
Definition: OMPLPlanner.hpp:145
OMPLPlanner< og::InformedRRTstar > InformedRRTstarPlanner
Definition: OMPLPlanner.hpp:140
OMPLPlanner< og::SPARStwo > SPARS2Planner
Definition: OMPLPlanner.hpp:153
OMPLPlanner< og::RRT > RRTPlanner
Definition: OMPLPlanner.hpp:136
OMPLPlanner< og::BFMT > BFMTPlanner
Definition: OMPLPlanner.hpp:144
OMPLPlanner< og::SST > SSTPlanner
Definition: OMPLPlanner.hpp:137
OMPLPlanner< og::RRTstar > RRTstarPlanner
Definition: OMPLPlanner.hpp:138
OMPLPlanner< og::SBL > SBLPlanner
Definition: OMPLPlanner.hpp:146
OMPLPlanner< og::BITstar > BITstarPlanner
Definition: OMPLPlanner.hpp:142
OMPLPlanner< og::RRTsharp > RRTsharpPlanner
Definition: OMPLPlanner.hpp:139
OMPLPlanner< og::CForest > CForestPlanner
Definition: OMPLPlanner.hpp:148
OMPLPlanner< og::FMT > FMTPlanner
Definition: OMPLPlanner.hpp:143
Definition: AbstractPlanner.h:29
std::vector< IntermediarySolution > intermediarySolutions
Definition: AbstractPlanner.h:56
og::SimpleSetup * ss
Definition: AbstractPlanner.h:114
static std::string LastCreatedPlannerName
Stores the name of the planner created last.
Definition: AbstractPlanner.h:38
Definition: OMPLPlanner.hpp:52
double planningTime() const override
Definition: OMPLPlanner.hpp:115
ob::Planner * omplPlanner() override
Definition: OMPLPlanner.hpp:119
virtual nlohmann::json getSettings() const override
Definition: OMPLPlanner.hpp:121
OMPLPlanner()
Definition: OMPLPlanner.hpp:54
std::string name() const override
Definition: OMPLPlanner.hpp:104
ob::PlannerStatus run() override
Definition: OMPLPlanner.hpp:59
og::PathGeometric solution() const override
Returns the solution of the planner, which is a sparse PathGeometric.
Definition: OMPLPlanner.hpp:106
bool hasReachedGoalExactly() const override
Definition: OMPLPlanner.hpp:111
Stopwatch implementation to measure elapsed time.
Definition: Stopwatch.hpp:8
void start()
Starts the timer.
Definition: Stopwatch.hpp:15
double elapsed() const
Elapsed time in seconds.
Definition: Stopwatch.hpp:41
Planner
Definition: PlannerSettings.h:16
ompl::base::SpaceInformationPtr space_info
Definition: PlannerSettings.h:407
PlannerSettings::GlobalSettings::OmplSettings ompl
static PlannerSettings::GlobalSettings settings
Definition: PlannerSettings.h:699