13 #include <ompl/geometric/planners/est/EST.h>
14 #include <ompl/geometric/planners/kpiece/BKPIECE1.h>
15 #include <ompl/geometric/planners/kpiece/KPIECE1.h>
16 #include <ompl/geometric/planners/kpiece/LBKPIECE1.h>
17 #include <ompl/geometric/planners/prm/PRM.h>
18 #include <ompl/geometric/planners/rrt/RRT.h>
19 #include <ompl/geometric/planners/rrt/RRTConnect.h>
20 #include <ompl/geometric/planners/rrt/RRTstar.h>
21 #include <ompl/geometric/planners/sbl/SBL.h>
36 static const char *ProblemTypeStrings[3] = {
"Barriers",
"Cubicles",
"Easy"};
47 static const char *OptTypeStrings[4] = {
"Shortcut",
"Hybridize",
"Alternating",
"None"};
64 static const char *PlannerTypeStrings[10] = {
"RRT",
"RRT*",
"EST",
"SBL",
"RRTConnect",
65 "PRM",
"PRM*",
"KPIECE",
"BKPIECE",
"LBKPIECE"};
67 void readArgsFromFile(
const char *filename, ProblemType &probType, OptimizationType &optType,
double &runtime,
68 std::vector<PlannerType> &planners)
70 std::cout << __func__ <<
" " << filename << std::endl;
72 std::ifstream fin(filename);
75 OMPL_ERROR(
"FATAL: Failed to open %s", filename);
79 std::string problem, optimization;
83 if (problem ==
"barriers")
85 else if (problem ==
"cubicles")
87 else if (problem ==
"easy")
90 if (optimization ==
"shortcut")
92 else if (optimization ==
"hybridize")
94 else if (optimization ==
"alternate")
99 std::string plannerArg;
100 while (!fin.eof() && fin.good())
104 if (plannerArg ==
"")
107 if (plannerArg ==
"rrt")
108 planners.push_back(RRT);
109 else if (plannerArg ==
"rrtstar")
110 planners.push_back(RRTSTAR);
111 else if (plannerArg ==
"est")
112 planners.push_back(EST);
113 else if (plannerArg ==
"sbl")
114 planners.push_back(SBL);
115 else if (plannerArg ==
"rrtconnect")
116 planners.push_back(RRTCONNECT);
117 else if (plannerArg ==
"prm")
118 planners.push_back(PRM);
119 else if (plannerArg ==
"prmstar")
120 planners.push_back(PRMSTAR);
121 else if (plannerArg ==
"kpiece")
122 planners.push_back(KPIECE);
123 else if (plannerArg ==
"bkpiece")
124 planners.push_back(BKPIECE);
125 else if (plannerArg ==
"lbkpiece")
126 planners.push_back(LBKPIECE);
128 std::cout <<
"Unknown planner argument: " << plannerArg <<
". Skipping..." << std::endl;
134 void parseArguments(
int argc,
char **argv, ProblemType &probType, OptimizationType &optType,
double &runtime,
135 std::vector<PlannerType> &planners)
139 readArgsFromFile(argv[1], probType, optType, runtime, planners);
143 std::string problem(argv[1]);
144 std::string optimization(argv[2]);
145 runtime = atof(argv[3]);
147 probType = INVALID_PROBLEM;
148 optType = INVALID_OPTIMIZATION;
150 if (problem ==
"barriers")
152 else if (problem ==
"cubicles")
154 else if (problem ==
"easy")
157 if (optimization ==
"shortcut")
159 else if (optimization ==
"hybridize")
161 else if (optimization ==
"alternate")
163 else if (optimization ==
"none")
166 for (
int i = 4; i < argc; ++i)
168 std::string plannerArg(argv[i]);
169 if (plannerArg ==
"rrt")
170 planners.push_back(RRT);
171 else if (plannerArg ==
"rrtstar")
172 planners.push_back(RRTSTAR);
173 else if (plannerArg ==
"est")
174 planners.push_back(EST);
175 else if (plannerArg ==
"sbl")
176 planners.push_back(SBL);
177 else if (plannerArg ==
"rrtconnect")
178 planners.push_back(RRTCONNECT);
179 else if (plannerArg ==
"prm")
180 planners.push_back(PRM);
181 else if (plannerArg ==
"prmstar")
182 planners.push_back(PRMSTAR);
183 else if (plannerArg ==
"kpiece")
184 planners.push_back(KPIECE);
185 else if (plannerArg ==
"bkpiece")
186 planners.push_back(BKPIECE);
187 else if (plannerArg ==
"lbkpiece")
188 planners.push_back(LBKPIECE);
190 std::cout <<
"Unknown planner argument: " << plannerArg <<
". Skipping..." << std::endl;
194 bool validArguments(
const ProblemType &probType,
const OptimizationType &optType,
const double &runtime,
195 const std::vector<PlannerType> &planners)
198 if (probType == INVALID_PROBLEM)
200 std::cout <<
"FATAL: Problem type is invalid!" << std::endl;
204 if (optType == INVALID_OPTIMIZATION)
206 std::cout <<
"FATAL: Optimization type is invalid!" << std::endl;
212 std::cout <<
"FATAL: Runtime must be strictly positive!" << std::endl;
216 if (planners.size() == 0)
218 std::cout <<
"FATAL: At least one planner must be declared!" << std::endl;
224 std::cout <<
"Solving the " << ProblemTypeStrings[probType] <<
" problem using " << OptTypeStrings[optType]
225 <<
" optimization for " << runtime <<
" seconds with " << std::endl;
226 for (
const auto &planner : planners)
227 std::cout << PlannerTypeStrings[planner] <<
" ";
228 std::cout << std::endl;
234 base::PlannerPtr allocPlanner(PlannerType type,
const base::SpaceInformationPtr &si)
236 assert(type != INVALID_PLANNER);
238 base::PlannerPtr planner;
244 planner = std::make_shared<geometric::RRT>(si);
248 planner = std::make_shared<geometric::RRTstar>(si);
252 planner = std::make_shared<geometric::EST>(si);
256 planner = std::make_shared<geometric::SBL>(si);
260 planner = std::make_shared<geometric::RRTConnect>(si);
264 planner = std::make_shared<geometric::PRM>(si);
268 planner = std::make_shared<geometric::PRM>(si,
true);
272 planner = std::make_shared<geometric::KPIECE1>(si);
276 planner = std::make_shared<geometric::BKPIECE1>(si);
280 planner = std::make_shared<geometric::LBKPIECE1>(si);